mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-19 08:29:48 +00:00
Tweak code list view
Still not right, but it's at least you can tell which lines are selected now. I never thought I'd miss owner-drawn ListViews. I was mistaken. Yay WPF.
This commit is contained in:
parent
bca1585571
commit
7bed043869
@ -284,7 +284,7 @@ namespace SourceGenWPF {
|
||||
return FormattedParts.Create("off" + index, "addr" + index, "12 34",
|
||||
"vncidmx", "", "yup:", "LDA", "$1234", "a & b");
|
||||
} else {
|
||||
return FormattedParts.Create("offN This is a long comment line");
|
||||
return FormattedParts.Create("yup: This is a long comment line");
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ namespace SourceGenWPF {
|
||||
public string Opcode { get; private set; }
|
||||
public string Operand { get; private set; }
|
||||
public string Comment { get; private set; }
|
||||
public bool SingleLine { get; private set; }
|
||||
public bool IsSingleLine { get; private set; }
|
||||
|
||||
// Construct with factory methods.
|
||||
private FormattedParts() { }
|
||||
@ -316,7 +316,7 @@ namespace SourceGenWPF {
|
||||
parts.Opcode = opcode;
|
||||
parts.Operand = operand;
|
||||
parts.Comment = comment;
|
||||
parts.SingleLine = false;
|
||||
parts.IsSingleLine = false;
|
||||
|
||||
return parts;
|
||||
}
|
||||
@ -324,7 +324,7 @@ namespace SourceGenWPF {
|
||||
public static FormattedParts Create(string longComment) {
|
||||
FormattedParts parts = new FormattedParts();
|
||||
parts.Comment = longComment;
|
||||
parts.SingleLine = true;
|
||||
parts.IsSingleLine = true;
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
@ -38,6 +38,72 @@ limitations under the License.
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
ListView tweaks from https://stackoverflow.com/a/4472061/294248 . This is
|
||||
necessary to get long comments and notes to start in the Label column. The
|
||||
approach feels a little wobbly, but it seems to work.
|
||||
|
||||
MSFT GridViewRowPresenter example is promising, but I haven't figured out how to
|
||||
make long-comment rows follow the same header (maybe manual update in code-behind?).
|
||||
https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.gridviewrowpresenter?view=netframework-4.8
|
||||
(in examples: snippets\csharp\VS_Snippets_Wpf\ListViewItemStyleSnippet)
|
||||
|
||||
https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/how-to-display-data-by-using-gridviewrowpresenter
|
||||
|
||||
Item Template Selectors are another possibility, maybe?
|
||||
https://stackoverflow.com/q/5416946/294248
|
||||
|
||||
Getting more custom:
|
||||
-->
|
||||
<Style x:Key="codeListViewItemStyle" TargetType="ListViewItem">
|
||||
<Style.Resources>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red"/>
|
||||
</Style.Resources>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSingleLine}" Value="True">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[0].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[1].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[2].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[3].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[4].ActualWidth}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="5" Padding="8,2" Text="{Binding Comment}"
|
||||
Background="{TemplateBinding Background}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Trigger.Setters>
|
||||
<Setter Property="Background" Value="LightBlue"/>
|
||||
</Trigger.Setters>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
|
||||
<!--
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Grid>
|
||||
<GridViewRowPresenter />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
-->
|
||||
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.CommandBindings>
|
||||
@ -215,27 +281,11 @@ limitations under the License.
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!--
|
||||
ListView tweaks from https://stackoverflow.com/a/4472061/294248 . This is
|
||||
necessary to get long comments and notes to start in the Label column. The
|
||||
approach feels a little wobbly, but it seems to work.
|
||||
|
||||
MSFT GridViewRowPresenter example is promising, but I haven't figured out how to
|
||||
make long-comment rows follow the same header (maybe manual update in code-behind?).
|
||||
https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.gridviewrowpresenter?view=netframework-4.8
|
||||
(in examples: snippets\csharp\VS_Snippets_Wpf\ListViewItemStyleSnippet)
|
||||
|
||||
https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/how-to-display-data-by-using-gridviewrowpresenter
|
||||
|
||||
Item Template Selectors are another possibility, maybe?
|
||||
https://stackoverflow.com/q/5416946/294248
|
||||
|
||||
Getting more custom:
|
||||
-->
|
||||
<ListView Name="codeListView" Grid.Column="2"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
Visibility="{Binding Path=CodeListVisibility}"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling" >
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||
ItemContainerStyle="{StaticResource codeListViewItemStyle}" SelectionChanged="CodeListView_SelectionChanged">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridViewColumn Header="Offset" DisplayMemberBinding="{Binding Offset}"/>
|
||||
@ -250,48 +300,6 @@ limitations under the License.
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
|
||||
<!-- https://stackoverflow.com/a/4472061/294248 -->
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SingleLine}" Value="True">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[0].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[1].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[2].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[3].ActualWidth}"/>
|
||||
<ColumnDefinition Width="{Binding ElementName=codeListView, Path=View.Columns[4].ActualWidth}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="5" Padding="8,2" Text="{Binding Comment}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
|
||||
<!--
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Grid>
|
||||
<GridViewRowPresenter />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
-->
|
||||
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
</ListView>
|
||||
|
||||
<Grid Name="RightPanel" Grid.Column="4">
|
||||
|
@ -121,5 +121,9 @@ namespace SourceGenWPF.ProjWin {
|
||||
Debug.WriteLine("Recent project #" + recentIndex);
|
||||
mUI.OpenRecentProject(recentIndex);
|
||||
}
|
||||
|
||||
private void CodeListView_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||
Debug.WriteLine("SEL: add " + e.AddedItems.Count + ", rem " + e.RemovedItems.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user