131 lines
6.9 KiB
XML
131 lines
6.9 KiB
XML
<UserControl x:Class="JD.Timeline.View.Pads.MoveModelControl"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
|
xmlns:converters="clr-namespace:JD.Timeline.View.Converters"
|
|
xmlns:serialization="clr-namespace:JD.Serialization;assembly=JD.Serialization"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="300" d:DesignWidth="300">
|
|
|
|
<UserControl.Resources>
|
|
<!-- Main Data Source -->
|
|
<serialization:MoveModelCollection x:Key="models" />
|
|
|
|
<!-- Presenting rules of data (grouping, sorting) -->
|
|
<CollectionViewSource x:Key="cvsMoveModels" Source="{StaticResource models}">
|
|
<CollectionViewSource.GroupDescriptions>
|
|
<PropertyGroupDescription PropertyName="MoveTypeFriendlyName"/>
|
|
</CollectionViewSource.GroupDescriptions>
|
|
<CollectionViewSource.SortDescriptions>
|
|
<componentModel:SortDescription PropertyName="MoveTypeFriendlyName" Direction="Descending"/>
|
|
<componentModel:SortDescription PropertyName="Name" Direction="Ascending"/>
|
|
</CollectionViewSource.SortDescriptions>
|
|
</CollectionViewSource>
|
|
|
|
<!-- Converters -->
|
|
<converters:WinFormsColorToWpfColorConverter x:Key="WinFormsColorToWpfColor" />
|
|
</UserControl.Resources>
|
|
|
|
<Grid>
|
|
<DataGrid Name="_dataGrid" Grid.Row="0"
|
|
ItemsSource="{Binding Source={StaticResource cvsMoveModels}}"
|
|
AutoGenerateColumns="False"
|
|
CanUserSortColumns="True"
|
|
CanUserResizeRows="False"
|
|
CanUserAddRows="False"
|
|
CanUserDeleteRows="False"
|
|
SelectionMode="Single"
|
|
GridLinesVisibility="None"
|
|
RowHeaderWidth="0"
|
|
SelectionChanged="_dataGrid_SelectionChanged">
|
|
|
|
<!-- Column Definitions -->
|
|
<DataGrid.Columns>
|
|
<DataGridTemplateColumn Header="" IsReadOnly="True" Width="12">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Ellipse Width="8" Height="8" Stroke="#88B0C4DE">
|
|
</Ellipse>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
<DataGridTemplateColumn Header="Color" IsReadOnly="True">
|
|
<DataGridTemplateColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<Rectangle Width="16" Height="16" MouseLeftButtonDown="Color_MouseLeftButtonDown" DataContext="{Binding}" >
|
|
<Rectangle.Fill>
|
|
<SolidColorBrush Color="{Binding Path=Color, Mode=OneWay, Converter={StaticResource ResourceKey=WinFormsColorToWpfColor}}" />
|
|
</Rectangle.Fill>
|
|
</Rectangle>
|
|
</DataTemplate>
|
|
</DataGridTemplateColumn.CellTemplate>
|
|
</DataGridTemplateColumn>
|
|
<DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" MinWidth="150">
|
|
</DataGridTextColumn>
|
|
<DataGridHyperlinkColumn ContentBinding="{Binding Path=InstancesCount}" Header="Instances" IsReadOnly="True" >
|
|
<DataGridHyperlinkColumn.ElementStyle>
|
|
<Style TargetType="TextBlock">
|
|
<EventSetter Event="Hyperlink.Click" Handler="InstancesCount_Click"/>
|
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
</Style>
|
|
</DataGridHyperlinkColumn.ElementStyle>
|
|
</DataGridHyperlinkColumn>
|
|
</DataGrid.Columns>
|
|
|
|
<!-- Groups Header Styles -->
|
|
<DataGrid.GroupStyle>
|
|
<GroupStyle>
|
|
<GroupStyle.ContainerStyle>
|
|
<Style TargetType="{x:Type GroupItem}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type GroupItem}">
|
|
<Expander IsExpanded="True" >
|
|
<Expander.Header>
|
|
<!-- Groups Title -->
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Text="{Binding Path=ItemCount}" />
|
|
<TextBlock Text=" "/>
|
|
<TextBlock Text="{Binding Path=Name}" />
|
|
<TextBlock Text="(s)"/>
|
|
</StackPanel>
|
|
</Expander.Header>
|
|
<ItemsPresenter />
|
|
</Expander>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</GroupStyle.ContainerStyle>
|
|
</GroupStyle>
|
|
</DataGrid.GroupStyle>
|
|
|
|
<!-- Setting cells and rows colors -->
|
|
<DataGrid.CellStyle>
|
|
<Style TargetType="DataGridCell">
|
|
<Style.Triggers>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter Property="Background" Value="Transparent" />
|
|
<Setter Property="Foreground" Value="Navy" />
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</DataGrid.CellStyle>
|
|
<DataGrid.RowStyle>
|
|
<Style TargetType="DataGridRow">
|
|
<Style.Triggers>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter Property="Background" Value="#22AAAAFF" />
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</DataGrid.RowStyle>
|
|
</DataGrid>
|
|
</Grid>
|
|
</UserControl>
|