mirror of
https://github.com/fadden/6502bench.git
synced 2024-09-06 17:54:25 +00:00
Merge ListView style from DisasmUiTest project
Long comments and notes now occupy the correct columns.
This commit is contained in:
parent
7bed043869
commit
c4a056bd0a
@ -298,9 +298,9 @@ namespace SourceGenWPF {
|
||||
public string Opcode { get; private set; }
|
||||
public string Operand { get; private set; }
|
||||
public string Comment { get; private set; }
|
||||
public bool IsSingleLine { get; private set; }
|
||||
public bool IsLongComment { get; private set; }
|
||||
|
||||
// Construct with factory methods.
|
||||
// Private constructor -- create instances with factory methods.
|
||||
private FormattedParts() { }
|
||||
|
||||
public static FormattedParts Create(string offset, string addr, string bytes,
|
||||
@ -316,7 +316,7 @@ namespace SourceGenWPF {
|
||||
parts.Opcode = opcode;
|
||||
parts.Operand = operand;
|
||||
parts.Comment = comment;
|
||||
parts.IsSingleLine = false;
|
||||
parts.IsLongComment = false;
|
||||
|
||||
return parts;
|
||||
}
|
||||
@ -324,7 +324,7 @@ namespace SourceGenWPF {
|
||||
public static FormattedParts Create(string longComment) {
|
||||
FormattedParts parts = new FormattedParts();
|
||||
parts.Comment = longComment;
|
||||
parts.IsSingleLine = true;
|
||||
parts.IsLongComment = true;
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
142
SourceGenWPF/ProjWin/CodeListItemStyle.xaml
Normal file
142
SourceGenWPF/ProjWin/CodeListItemStyle.xaml
Normal file
@ -0,0 +1,142 @@
|
||||
<!--
|
||||
Copyright 2019 faddenSoft
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
ListViewItem control template and style. This is used for the main code ListView. The
|
||||
most significant consideration is getting long comments and notes into the 5th column and
|
||||
having them span multiple columns.
|
||||
|
||||
This interacts with DisplayList.FormattedParts.
|
||||
|
||||
See also https://github.com/fadden/DisasmUiTest
|
||||
-->
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!-- some brushes, extracted from the default style -->
|
||||
<LinearGradientBrush x:Key="ListItemHoverFill" EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFF1FBFF" Offset="0"/>
|
||||
<GradientStop Color="#FFD5F1FE" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="ListItemSelectedFill" EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFD9F4FF" Offset="0"/>
|
||||
<GradientStop Color="#FF9BDDFB" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="ListItemSelectedInactiveFill" EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFEEEDED" Offset="0"/>
|
||||
<GradientStop Color="#FFDDDDDD" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<LinearGradientBrush x:Key="ListItemSelectedHoverFill" EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFEAF9FF" Offset="0"/>
|
||||
<GradientStop Color="#FFC9EDFD" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<!-- Column set for the long-comment lines. The first five columns will be empty, but
|
||||
have their widths set to match those in the containing ListView.
|
||||
If you don't set DisplayMemberBinding, it will try to ToString() the entire object.
|
||||
-->
|
||||
<GridViewColumnCollection x:Key="gvcc">
|
||||
<GridViewColumn Width="{Binding
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}
|
||||
}, Path=View.Columns[0].ActualWidth}" DisplayMemberBinding="{Binding Offset}"/>
|
||||
<GridViewColumn Width="{Binding
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}
|
||||
}, Path=View.Columns[1].ActualWidth}" DisplayMemberBinding="{Binding Addr}"/>
|
||||
<GridViewColumn Width="{Binding
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}
|
||||
}, Path=View.Columns[2].ActualWidth}" DisplayMemberBinding="{Binding Bytes}"/>
|
||||
<GridViewColumn Width="{Binding
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}
|
||||
}, Path=View.Columns[3].ActualWidth}" DisplayMemberBinding="{Binding Flags}"/>
|
||||
<GridViewColumn Width="{Binding
|
||||
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}
|
||||
}, Path=View.Columns[4].ActualWidth}" DisplayMemberBinding="{Binding Attr}"/>
|
||||
<GridViewColumn Header="two" DisplayMemberBinding="{Binding Path=Comment}"/>
|
||||
</GridViewColumnCollection>
|
||||
|
||||
<!-- Template for long lines. This is a modification of the default style, with
|
||||
Content and Columns attributes defined in the GridViewRowPresenter. It appears we
|
||||
inherit the FocusVisualStyle from the default. -->
|
||||
<ControlTemplate x:Key="longComment" TargetType="{x:Type ListViewItem}">
|
||||
<StackPanel>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="2"
|
||||
SnapsToDevicePixels="true">
|
||||
<Border x:Name="InnerBorder" BorderThickness="1" CornerRadius="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="11"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle x:Name="UpperHighlight" Fill="#75FFFFFF" Visibility="Collapsed"/>
|
||||
<GridViewRowPresenter Content="{TemplateBinding Content}"
|
||||
Columns="{StaticResource gvcc}"
|
||||
Grid.RowSpan="2"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- triggers for hover, selection, and activation effects -->
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Background" Value="{StaticResource ListItemHoverFill}"/>
|
||||
<Setter Property="BorderBrush" Value="#FFCCF0FF"/>
|
||||
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" Value="{StaticResource ListItemSelectedFill}"/>
|
||||
<Setter Property="BorderBrush" Value="#FF98DDFB"/>
|
||||
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
|
||||
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
|
||||
<Setter Property="Fill" TargetName="UpperHighlight" Value="#40FFFFFF"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="true"/>
|
||||
<Condition Property="Selector.IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{StaticResource ListItemSelectedInactiveFill}"/>
|
||||
<Setter Property="BorderBrush" Value="#FFCFCFCF"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="true"/>
|
||||
<Condition Property="IsMouseOver" Value="true"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{StaticResource ListItemSelectedHoverFill}"/>
|
||||
<Setter Property="BorderBrush" Value="#FF98DDFB"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="codeListItemStyle" TargetType="{x:Type ListViewItem}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=IsLongComment}" Value="True">
|
||||
<Setter Property="Template" Value="{StaticResource longComment}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@ -25,6 +25,12 @@ limitations under the License.
|
||||
Width="810" Height="510" MinWidth="800" MinHeight="500">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<!-- style and control templates for main code ListView items -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="CodeListItemStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<RoutedUICommand x:Key="AssembleCmd" Text="Assemble...">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Ctrl+Shift+A</KeyGesture>
|
||||
@ -33,77 +39,13 @@ limitations under the License.
|
||||
<RoutedUICommand x:Key="RecentProject"/>
|
||||
|
||||
<!-- don't center the ListView(GridView) column headers
|
||||
https://stackoverflow.com/questions/44119146/wpf-listview-column-header-alignment
|
||||
https://stackoverflow.com/q/44119146/294248
|
||||
(style without ID applies to all instances of that type)
|
||||
-->
|
||||
<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>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.CommandBindings>
|
||||
@ -285,7 +227,8 @@ limitations under the License.
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
Visibility="{Binding Path=CodeListVisibility}"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||
ItemContainerStyle="{StaticResource codeListViewItemStyle}" SelectionChanged="CodeListView_SelectionChanged">
|
||||
ItemContainerStyle="{StaticResource codeListItemStyle}"
|
||||
SelectionChanged="CodeListView_SelectionChanged">
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridViewColumn Header="Offset" DisplayMemberBinding="{Binding Offset}"/>
|
||||
|
@ -138,6 +138,10 @@
|
||||
<Resource Include="Res\Logo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="ProjWin\CodeListItemStyle.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="ProjWin\DataFileLoadIssue.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
Loading…
Reference in New Issue
Block a user