-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathStatusGrid.xaml
159 lines (147 loc) · 9.54 KB
/
StatusGrid.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<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>