mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-04 15:05:03 +00:00
80ec6b6c78
The various items in the Actions menu are enabled or disabled based on the current selection. There's no SelectedIndices property in WPF ListViews, so we have to do things slightly differently. The SelectedItems list isn't kept sorted to match the list contents, so finding first/last item requires a bit of scanning. Also, rearranged some stuff. I'm trying to keep the old and new code somewhat parallel, to make it easier to walk through at the end and see if I've missed something.
148 lines
7.9 KiB
XML
148 lines
7.9 KiB
XML
<!--
|
|
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. Most of this came from the default style (WPF 4.5).
|
|
|
|
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="longCommentTemplate" 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}">
|
|
<!-- There's a one-pixel gap between items, possibly space for grid lines, that
|
|
can't seem to be eliminated. Declaring a negative margin removes it. This is
|
|
necessary because the gap isn't a mouse target, so if your mouse is in just the
|
|
wrong place you'll feel like you clicked and nothing happened. -->
|
|
<Setter Property="Margin" Value="0,-1,0,0"/>
|
|
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Path=IsLongComment}" Value="True">
|
|
<Setter Property="Template" Value="{StaticResource longCommentTemplate}"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</ResourceDictionary> |