Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
159 lines (147 sloc) 9.54 KB
<UserControl x:Class="GG.UserControls.StatusGrid"
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:converters="clr-namespace:GG.Converters"
xmlns:userControls="clr-namespace:GG.UserControls"
mc:Ignorable="d"
d:DesignHeight="343" d:DesignWidth="501">
<UserControl.Resources>
<converters:StatusToColorConverter x:Key="statusToColorConverter" />
<converters:StatusToCharacterConverter x:Key="statusToCharacterConverter" />
<converters:ExtensionToImageConverter x:Key="extensionToImageConverter" />
<converters:GenericVisibilityConverter x:Key="genericVisibilityConverter" />
<userControls:StatusGridContextMenu x:Key="statusGridContextMenu" />
<!-- Status template. -->
<ItemContainerTemplate x:Key="StatusGridStatusTemplate">
<WrapPanel HorizontalAlignment="Center">
<Border BorderThickness="0" CornerRadius="4" Background="{Binding Path=Status, Converter={StaticResource statusToColorConverter}}">
<TextBlock
Width="16"
VerticalAlignment="Stretch"
HorizontalAlignment="Center"
TextAlignment="Center"
Foreground="White"
FontFamily="Arial"
FontSize="12"
FontWeight="Bold"
TextOptions.TextFormattingMode="Display"
TextOptions.TextRenderingMode="ClearType"
Text="{Binding Status, Converter={StaticResource statusToCharacterConverter}}" />
</Border>
</WrapPanel>
</ItemContainerTemplate>
<!-- Filename template. -->
<ItemContainerTemplate x:Key="StatusGridFilenameTemplate">
<WrapPanel>
<Image Source="{Binding Extension, Converter={StaticResource extensionToImageConverter}}" Stretch="None" Margin="0,0,3,0" />
<TextBlock Text="{Binding Path=Filename}"
Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
</WrapPanel>
</ItemContainerTemplate>
<!-- Grid style. -->
<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="SelectionUnit" Value="FullRow" />
<Setter Property="HeadersVisibility" Value="Column" />
<Setter Property="AutoGenerateColumns" Value="False" />
<Setter Property="CanUserAddRows" Value="False" />
<Setter Property="CanUserDeleteRows" Value="False" />
<Setter Property="CanUserResizeColumns" Value="True" />
<Setter Property="BorderThickness" Value="1,1,0,1" />
<Setter Property="VirtualizingPanel.IsVirtualizing" Value="True" />
<Setter Property="VirtualizingPanel.VirtualizationMode" Value="Recycling" />
<Setter Property="ContextMenu" Value="{StaticResource statusGridContextMenu}" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="72" />
<RowDefinition Height="6" />
<RowDefinition Height="*" MinHeight="72" />
</Grid.RowDefinitions>
<userControls:Panel Grid.Row="0">
<userControls:Panel.Header>
<WrapPanel Margin="0,4,0,4">
<TextBlock>Staged</TextBlock>
<TextBlock xml:space="preserve">: </TextBlock>
<TextBlock Text="{Binding StatusItemsStaged.Count}" />
</WrapPanel>
</userControls:Panel.Header>
<userControls:Panel.Body>
<Grid>
<TextBlock Margin="8"
Foreground="#222"
Visibility="{Binding StatusItemsStaged.Count, Converter={StaticResource genericVisibilityConverter}, ConverterParameter=not}">Nothing to commit.</TextBlock>
<DataGrid
ItemsSource="{Binding StatusItemsStaged}"
SelectionChanged="StatusGridSelectionChanged"
BorderThickness="0"
Visibility="{Binding StatusItemsStaged.Count, Converter={StaticResource genericVisibilityConverter}}"
Tag="{Binding}">
<DataGrid.InputBindings>
<KeyBinding Command="{Binding StageUnstageCommand}"
CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
Gesture="Enter" />
<KeyBinding Command="{Binding StageUnstageCommand}"
CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
Gesture="Delete" />
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
<DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
<DataGridTextColumn Binding="{Binding Path=Size}"
Header="Size"
Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
<DataGridTextColumn Binding="{Binding Path=IsBinary}"
Header="Binary"
Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</userControls:Panel.Body>
</userControls:Panel>
<GridSplitter Grid.Row="1" Style="{StaticResource GridSplitterVerticalStyle}" />
<userControls:Panel Grid.Row="2">
<userControls:Panel.Header>
<WrapPanel Margin="0,4,0,4">
<TextBlock>Unstaged</TextBlock>
<TextBlock xml:space="preserve">: </TextBlock>
<TextBlock Text="{Binding StatusItemsUnstaged.Count}" />
</WrapPanel>
</userControls:Panel.Header>
<userControls:Panel.Body>
<Grid>
<TextBlock Margin="8"
Foreground="#222"
Visibility="{Binding StatusItemsUnstaged.Count, Converter={StaticResource genericVisibilityConverter}, ConverterParameter=not}">Nothing to stage.</TextBlock>
<DataGrid
ItemsSource="{Binding StatusItemsUnstaged}"
SelectionChanged="StatusGridSelectionChanged"
BorderThickness="0"
Visibility="{Binding StatusItemsUnstaged.Count, Converter={StaticResource genericVisibilityConverter}}"
Tag="{Binding}">
<DataGrid.InputBindings>
<KeyBinding Command="{Binding StageUnstageCommand}"
CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
Gesture="Enter" />
<KeyBinding Command="{Binding StageUnstageCommand}"
CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
Gesture="Delete" />
</DataGrid.InputBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
<DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
<DataGridTextColumn Binding="{Binding Path=Size}"
Header="Size"
Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
<DataGridTextColumn Binding="{Binding Path=IsBinary}"
Header="Binary"
Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</userControls:Panel.Body>
</userControls:Panel>
</Grid>
</UserControl>