style<*>: enable SnapsToDevicePixels for borders

This commit is contained in:
leo 2021-04-06 10:59:50 +08:00
parent d56eab9592
commit eba5d456f0
4 changed files with 332 additions and 356 deletions

View file

@ -111,7 +111,7 @@
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="200" MaxWidth="300"/> <ColumnDefinition Width="200" MinWidth="200" MaxWidth="300"/>
<ColumnDefinition Width="1" MaxWidth="1"/> <ColumnDefinition Width="1"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -481,7 +481,7 @@
</Grid> </Grid>
<!-- Splitter --> <!-- Splitter -->
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource Brush.Border0}"/> <GridSplitter Grid.Column="1" HorizontalAlignment="Center" Width="1" VerticalAlignment="Stretch" Background="{StaticResource Brush.Border0}"/>
<!-- Right --> <!-- Right -->
<Grid Grid.Column="2"> <Grid Grid.Column="2">

View file

@ -10,7 +10,7 @@
<Border Background="Transparent" MouseLeftButtonDown="Close"/> <Border Background="Transparent" MouseLeftButtonDown="Close"/>
<Grid HorizontalAlignment="Center" VerticalAlignment="Top" Width="Auto" Height="Auto" Background="{StaticResource Brush.Popup}"> <Grid HorizontalAlignment="Center" VerticalAlignment="Top" Width="Auto" Height="Auto" Background="{StaticResource Brush.Popup}">
<Border x:Name="popupContent" Padding="8" Width="Auto" Height="Auto" BorderThickness="1,0,1,1" BorderBrush="{StaticResource Brush.Border0}"/> <Border x:Name="popupContent" Padding="8" Width="Auto" Height="Auto" BorderThickness="1,0,1,1" BorderBrush="{StaticResource Brush.Border0}" SnapsToDevicePixels="True"/>
<Border x:Name="status" Visibility="Collapsed" Background="{StaticResource Brush.Popup}" Margin="1,0,1,1" Opacity=".9"> <Border x:Name="status" Visibility="Collapsed" Background="{StaticResource Brush.Popup}" Margin="1,0,1,1" Opacity=".9">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">

View file

@ -18,68 +18,57 @@
<!-- Left panel --> <!-- Left panel -->
<Grid Grid.Column="0"> <Grid Grid.Column="0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="1"/> <RowDefinition Height="24"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Stash list --> <!-- Stashes list toolbar -->
<Grid Grid.Row="0"> <Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1" SnapsToDevicePixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="1"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Content="{StaticResource Text.Stashes.Stashes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/> <Label Content="{StaticResource Text.Stashes.Stashes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/>
<Rectangle Grid.Row="1" HorizontalAlignment="Stretch" Height="1" Fill="{StaticResource Brush.Border0}"/> </Border>
<ListView
Grid.Row="2" <!-- Stashes list -->
x:Name="stashList" <ListView
Background="{StaticResource Brush.Contents}" BorderThickness="0" Grid.Row="1"
SelectedIndex="-1" x:Name="stashList"
ScrollViewer.VerticalScrollBarVisibility="Auto" Background="{StaticResource Brush.Contents}" BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden" Style="{StaticResource Style.ListView.Borderless}"
SelectionChanged="StashSelectionChanged"> SelectedIndex="-1"
<ListView.ItemContainerStyle> ScrollViewer.VerticalScrollBarVisibility="Auto"
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}"> ScrollViewer.HorizontalScrollBarVisibility="Hidden"
<Setter Property="Padding" Value="0"/> SelectionChanged="StashSelectionChanged">
<EventSetter Event="ContextMenuOpening" Handler="StashContextMenuOpening"/> <ListView.ItemContainerStyle>
</Style> <Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
</ListView.ItemContainerStyle> <Setter Property="Padding" Value="0"/>
<ListView.ItemTemplate> <Setter Property="Margin" Value="0"/>
<DataTemplate DataType="{x:Type git:Stash}"> <EventSetter Event="ContextMenuOpening" Handler="StashContextMenuOpening"/>
<Border BorderBrush="{StaticResource Brush.Border3}" BorderThickness="0,0,0,1" Padding="4"> </Style>
<StackPanel Orientation="Vertical" Margin="2" MaxWidth="290"> </ListView.ItemContainerStyle>
<Grid TextBlock.Foreground="{StaticResource Brush.FG2}" TextBlock.FontSize="11"> <ListView.ItemTemplate>
<Grid.ColumnDefinitions> <DataTemplate DataType="{x:Type git:Stash}">
<ColumnDefinition Width="*"/> <Border BorderBrush="{StaticResource Brush.Border3}" BorderThickness="0,0,0,1" Padding="4">
<ColumnDefinition Width="Auto"/> <StackPanel Orientation="Vertical" Margin="2" MaxWidth="290">
</Grid.ColumnDefinitions> <Grid TextBlock.Foreground="{StaticResource Brush.FG2}" TextBlock.FontSize="11">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding SHA}"/> <TextBlock Grid.Column="0" Text="{Binding SHA}"/>
<TextBlock Grid.Column="1" Text="{Binding Author.Time}"/> <TextBlock Grid.Column="1" Text="{Binding Author.Time}"/>
</Grid> </Grid>
<TextBlock MaxWidth="280" Foreground="{StaticResource Brush.FG1}" Text="{Binding Message}" TextAlignment="Left" Padding="0" Margin="0,8,2,0"/> <TextBlock MaxWidth="280" Foreground="{StaticResource Brush.FG1}" Text="{Binding Message}" TextAlignment="Left" Padding="0" Margin="0,8,2,0"/>
</StackPanel> </StackPanel>
</Border> </Border>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
</Grid>
<!-- Changed file toolbar -->
<!-- Splitter --> <Border Grid.Row="2" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,1,0,1" SnapsToDevicePixels="True">
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource Brush.Border0}"/> <Grid>
<!-- Changed file in this stash -->
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="1"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@ -88,45 +77,45 @@
<Label Grid.Column="0" Content="{StaticResource Text.Stashes.Changes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/> <Label Grid.Column="0" Content="{StaticResource Text.Stashes.Changes}" Foreground="{StaticResource Brush.FG2}" Margin="4,0,0,0" FontWeight="Bold"/>
<Label Grid.Column="1" Content="{StaticResource Text.Stashes.Changes.Tip}" Foreground="{StaticResource Brush.FG2}" FontSize="10"/> <Label Grid.Column="1" Content="{StaticResource Text.Stashes.Changes.Tip}" Foreground="{StaticResource Brush.FG2}" FontSize="10"/>
</Grid> </Grid>
</Border>
<!-- Change files -->
<ListView
x:Name="changeList"
Grid.Row="3"
Background="{StaticResource Brush.Contents}" BorderThickness="0"
Style="{StaticResource Style.ListView.Borderless}"
SelectedIndex="-1"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
SelectionChanged="FileSelectionChanged">
<ListView.Resources>
<converters:FileStatusToColor x:Key="StatusColorConverter"/>
<converters:FileStatusToIcon x:Key="StatusIconConverter"/>
</ListView.Resources>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
<Setter Property="Padding" Value="0"/>
<Setter Property="TextBlock.FontFamily" Value="Consolas"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type git:Change}">
<Grid Height="24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Row="1" HorizontalAlignment="Stretch" Height="1" Fill="{StaticResource Brush.Border0}"/> <Border Grid.Column="0" Width="14" Height="14" Background="{Binding ., Converter={StaticResource StatusColorConverter}}" CornerRadius="2" Margin="0,0,4,0">
<TextBlock Text="{Binding ., Converter={StaticResource StatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10"/>
</Border>
<ListView <TextBlock Grid.Column="1" Text="{Binding Path}" Foreground="{StaticResource Brush.FG1}" VerticalAlignment="Center" FontSize="11"/>
x:Name="changeList" </Grid>
Grid.Row="2" </DataTemplate>
Background="{StaticResource Brush.Contents}" BorderThickness="0" </ListView.ItemTemplate>
SelectedIndex="-1" </ListView>
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
SelectionChanged="FileSelectionChanged">
<ListView.Resources>
<converters:FileStatusToColor x:Key="StatusColorConverter"/>
<converters:FileStatusToIcon x:Key="StatusIconConverter"/>
</ListView.Resources>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
<Setter Property="Padding" Value="0"/>
<Setter Property="TextBlock.FontFamily" Value="Consolas"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type git:Change}">
<Grid Height="24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Width="14" Height="14" Background="{Binding ., Converter={StaticResource StatusColorConverter}}" CornerRadius="2" Margin="0,0,4,0">
<TextBlock Text="{Binding ., Converter={StaticResource StatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10"/>
</Border>
<TextBlock Grid.Column="1" Text="{Binding Path}" Foreground="{StaticResource Brush.FG1}" VerticalAlignment="Center" FontSize="11"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid> </Grid>
<!-- Splitter --> <!-- Splitter -->

View file

@ -29,26 +29,22 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/> <ColumnDefinition Width="300"/>
<ColumnDefinition Width="1" MaxWidth="1"/> <ColumnDefinition Width="1"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Left --> <!-- Left -->
<Grid Grid.Column="0"> <Grid Grid.Column="0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="1"/> <RowDefinition Height="24"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Unstaged changes --> <!-- Unstaged changes toolbar -->
<Grid Grid.Row="0"> <Border Grid.Row="0" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1" SnapsToDevicePixels="True">
<Grid.RowDefinitions> <Grid>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@ -58,8 +54,6 @@
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" Grid.ColumnSpan="6" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1"/>
<local:FilesDisplayModeSwitch <local:FilesDisplayModeSwitch
Grid.Column="0" Grid.Column="0"
Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Mode=TwoWay}"/> Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Mode=TwoWay}"/>
@ -78,144 +72,138 @@
<Path Width="14" Height="14" Data="{StaticResource Icon.DoubleDown}" Opacity=".4"/> <Path Width="14" Height="14" Data="{StaticResource Icon.DoubleDown}" Opacity=".4"/>
</Button> </Button>
</Grid> </Grid>
</Border>
<!-- Unstage changes tree view mode -->
<TreeView
Grid.Row="1"
x:Name="unstagedTree"
ItemsSource="{Binding ElementName=me, Path=UnstagedTreeData, IsAsync=True}"
Background="{StaticResource Brush.Contents}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
helpers:TreeViewHelper.EnableMultiSelection="True"
helpers:TreeViewHelper.MultiSelectionChanged="UnstagedTreeMultiSelectionChanged">
<TreeView.Resources>
<RoutedUICommand x:Key="SelectWholeTreeCommand" Text="SelectWholeTree"/>
</TreeView.Resources>
<TreeView <TreeView.InputBindings>
Grid.Row="1" <KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeTreeCommand}"/>
x:Name="unstagedTree" </TreeView.InputBindings>
ItemsSource="{Binding ElementName=me, Path=UnstagedTreeData, IsAsync=True}"
Background="{StaticResource Brush.Contents}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
helpers:TreeViewHelper.EnableMultiSelection="True"
helpers:TreeViewHelper.MultiSelectionChanged="UnstagedTreeMultiSelectionChanged">
<TreeView.Resources>
<RoutedUICommand x:Key="SelectWholeTreeCommand" Text="SelectWholeTree"/>
</TreeView.Resources>
<TreeView.InputBindings> <TreeView.CommandBindings>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeTreeCommand}"/> <CommandBinding Command="{StaticResource SelectWholeTreeCommand}" Executed="SelectWholeTree"/>
</TreeView.InputBindings> </TreeView.CommandBindings>
<TreeView.CommandBindings> <TreeView.ItemContainerStyle>
<CommandBinding Command="{StaticResource SelectWholeTreeCommand}" Executed="SelectWholeTree"/> <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.MultiSelectionItemContainerStyle}">
</TreeView.CommandBindings> <Setter Property="IsExpanded" Value="{Binding IsNodeExpanded, Mode=TwoWay}"/>
<EventSetter Event="ContextMenuOpening" Handler="UnstagedTreeContextMenuOpening"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal" Height="24">
<Border x:Name="status" Width="14" Height="14" Visibility="Collapsed" Background="{Binding Change, Converter={StaticResource UnstagedStatusConverter}}" CornerRadius="2" Margin="0,0,4,0">
<TextBlock Text="{Binding Change, Converter={StaticResource UnstagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10" RenderOptions.BitmapScalingMode="HighQuality"/>
</Border>
<Path x:Name="icon" Width="14" Fill="Goldenrod" Data="{StaticResource Icon.Folder.Fill}"/>
<TextBlock Text="{Binding Name}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" Margin="4,0,0,0" FontSize="11"/>
</StackPanel>
<TreeView.ItemContainerStyle> <HierarchicalDataTemplate.Triggers>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.MultiSelectionItemContainerStyle}"> <DataTrigger Binding="{Binding IsFile}" Value="True">
<Setter Property="IsExpanded" Value="{Binding IsNodeExpanded, Mode=TwoWay}"/> <Setter TargetName="status" Property="Visibility" Value="Visible"/>
<EventSetter Event="ContextMenuOpening" Handler="UnstagedTreeContextMenuOpening"/> <Setter TargetName="icon" Property="Visibility" Value="Collapsed"/>
</Style> </DataTrigger>
</TreeView.ItemContainerStyle> <MultiDataTrigger>
<TreeView.ItemTemplate> <MultiDataTrigger.Conditions>
<HierarchicalDataTemplate ItemsSource="{Binding Children}"> <Condition Binding="{Binding IsFile}" Value="False"/>
<StackPanel Orientation="Horizontal" Height="24"> <Condition Binding="{Binding IsNodeExpanded}" Value="True"/>
<Border x:Name="status" Width="14" Height="14" Visibility="Collapsed" Background="{Binding Change, Converter={StaticResource UnstagedStatusConverter}}" CornerRadius="2" Margin="0,0,4,0"> </MultiDataTrigger.Conditions>
<TextBlock Text="{Binding Change, Converter={StaticResource UnstagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10" RenderOptions.BitmapScalingMode="HighQuality"/> <Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</MultiDataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<!-- Unstaged changes list/grid view mode -->
<DataGrid
Grid.Row="1"
x:Name="unstagedList"
ItemsSource="{Binding ElementName=me, Path=UnstagedListData, IsAsync=True}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
RowHeight="24"
SelectionChanged="UnstagedListSelectionChanged"
SelectionMode="Extended"
SelectionUnit="FullRow"
Background="{StaticResource Brush.Contents}">
<DataGrid.Resources>
<Style x:Key="Style.DataGridText.VerticalCenter" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="4,0"/>
</Style>
<RoutedUICommand x:Key="SelectWholeDataGridCommand" Text="SelectWholeDataGrid"/>
</DataGrid.Resources>
<DataGrid.InputBindings>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeDataGridCommand}"/>
</DataGrid.InputBindings>
<DataGrid.CommandBindings>
<CommandBinding Command="{StaticResource SelectWholeDataGridCommand}" Executed="SelectWholeDataGrid"/>
</DataGrid.CommandBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Width="22">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Width="14" Height="14" x:Name="status" Background="{Binding ., Converter={StaticResource UnstagedStatusConverter}}" CornerRadius="2" Margin="2,0">
<TextBlock Text="{Binding ., Converter={StaticResource UnstagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="8"/>
</Border> </Border>
<Path x:Name="icon" Width="14" Fill="Goldenrod" Data="{StaticResource Icon.Folder.Fill}"/> </DataTemplate>
<TextBlock Text="{Binding Name}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" Margin="4,0,0,0" FontSize="11"/> </DataGridTemplateColumn.CellTemplate>
</StackPanel> </DataGridTemplateColumn>
<HierarchicalDataTemplate.Triggers> <DataGridTextColumn
<DataTrigger Binding="{Binding IsFile}" Value="True"> Width="Auto"
<Setter TargetName="status" Property="Visibility" Value="Visible"/> Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
<Setter TargetName="icon" Property="Visibility" Value="Collapsed"/> Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
</DataTrigger> Foreground="{StaticResource Brush.FG1}"
<MultiDataTrigger> FontFamily="Consolas"
<MultiDataTrigger.Conditions> ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<Condition Binding="{Binding IsFile}" Value="False"/>
<Condition Binding="{Binding IsNodeExpanded}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</MultiDataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<DataGrid <DataGridTextColumn
Grid.Row="2" Width="*"
x:Name="unstagedList" Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
ItemsSource="{Binding ElementName=me, Path=UnstagedListData, IsAsync=True}" Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}" Foreground="{StaticResource Brush.FG2}"
RowHeight="24" FontFamily="Consolas"
SelectionChanged="UnstagedListSelectionChanged" ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
SelectionMode="Extended"
SelectionUnit="FullRow"
Background="{StaticResource Brush.Contents}">
<DataGrid.Resources>
<Style x:Key="Style.DataGridText.VerticalCenter" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="4,0"/>
</Style>
<RoutedUICommand x:Key="SelectWholeDataGridCommand" Text="SelectWholeDataGrid"/> <DataGridTextColumn
</DataGrid.Resources> Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
</DataGrid.Columns>
<DataGrid.InputBindings> <DataGrid.RowStyle>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeDataGridCommand}"/> <Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
</DataGrid.InputBindings> <EventSetter Event="ContextMenuOpening" Handler="UnstagedListContextMenuOpening"/>
</Style>
<DataGrid.CommandBindings> </DataGrid.RowStyle>
<CommandBinding Command="{StaticResource SelectWholeDataGridCommand}" Executed="SelectWholeDataGrid"/> </DataGrid>
</DataGrid.CommandBindings>
<!-- Staged changes toolbar -->
<DataGrid.Columns> <Border Grid.Row="2" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,1,0,1" SnapsToDevicePixels="True">
<DataGridTemplateColumn Width="22"> <Grid>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Width="14" Height="14" x:Name="status" Background="{Binding ., Converter={StaticResource UnstagedStatusConverter}}" CornerRadius="2" Margin="2,0">
<TextBlock Text="{Binding ., Converter={StaticResource UnstagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="8"/>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="Auto"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
Foreground="{StaticResource Brush.FG2}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="ContextMenuOpening" Handler="UnstagedListContextMenuOpening"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</Grid>
<!-- Splitter -->
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource Brush.Border0}"/>
<!-- Staged changes -->
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="24"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@ -224,8 +212,6 @@
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" Grid.ColumnSpan="5" BorderBrush="{StaticResource Brush.Border0}" BorderThickness="0,0,0,1"/>
<local:FilesDisplayModeSwitch <local:FilesDisplayModeSwitch
Grid.Column="0" Grid.Column="0"
Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Mode=TwoWay}"/> Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Mode=TwoWay}"/>
@ -237,132 +223,133 @@
<Path Width="14" Height="14" Data="{StaticResource Icon.DoubleUp}" Opacity=".4"/> <Path Width="14" Height="14" Data="{StaticResource Icon.DoubleUp}" Opacity=".4"/>
</Button> </Button>
</Grid> </Grid>
</Border>
<!-- Staged changes tree view mode -->
<TreeView
Grid.Row="3"
x:Name="stageTree"
ItemsSource="{Binding ElementName=me, Path=StagedTreeData, IsAsync=False}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
Background="{StaticResource Brush.Contents}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
helpers:TreeViewHelper.EnableMultiSelection="True"
helpers:TreeViewHelper.MultiSelectionChanged="StageTreeMultiSelectionChanged">
<TreeView.Resources>
<RoutedUICommand x:Key="SelectWholeTreeCommand" Text="SelectWholeTree"/>
</TreeView.Resources>
<TreeView <TreeView.InputBindings>
Grid.Row="1" <KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeTreeCommand}"/>
x:Name="stageTree" </TreeView.InputBindings>
ItemsSource="{Binding ElementName=me, Path=StagedTreeData, IsAsync=False}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
Background="{StaticResource Brush.Contents}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
helpers:TreeViewHelper.EnableMultiSelection="True"
helpers:TreeViewHelper.MultiSelectionChanged="StageTreeMultiSelectionChanged">
<TreeView.Resources>
<RoutedUICommand x:Key="SelectWholeTreeCommand" Text="SelectWholeTree"/>
</TreeView.Resources>
<TreeView.InputBindings> <TreeView.CommandBindings>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeTreeCommand}"/> <CommandBinding Command="{StaticResource SelectWholeTreeCommand}" Executed="SelectWholeTree"/>
</TreeView.InputBindings> </TreeView.CommandBindings>
<TreeView.CommandBindings> <TreeView.ItemContainerStyle>
<CommandBinding Command="{StaticResource SelectWholeTreeCommand}" Executed="SelectWholeTree"/> <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.MultiSelectionItemContainerStyle}">
</TreeView.CommandBindings> <Setter Property="IsExpanded" Value="{Binding IsNodeExpanded, Mode=TwoWay}"/>
<EventSetter Event="ContextMenuOpening" Handler="StageTreeContextMenuOpening"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal" Height="24">
<Border x:Name="status" Width="14" Height="14" Visibility="Collapsed" Background="{Binding Change, Converter={StaticResource StagedStatusConverter}}" CornerRadius="2" Margin="0,0,4,0">
<TextBlock Text="{Binding Change, Converter={StaticResource StagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10" RenderOptions.BitmapScalingMode="HighQuality"/>
</Border>
<Path x:Name="icon" Width="14" Fill="Goldenrod" Data="{StaticResource Icon.Folder.Fill}"/>
<TextBlock Text="{Binding Name}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" Margin="4,0,0,0" FontSize="11"/>
</StackPanel>
<TreeView.ItemContainerStyle> <HierarchicalDataTemplate.Triggers>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.MultiSelectionItemContainerStyle}"> <DataTrigger Binding="{Binding IsFile}" Value="True">
<Setter Property="IsExpanded" Value="{Binding IsNodeExpanded, Mode=TwoWay}"/> <Setter TargetName="status" Property="Visibility" Value="Visible"/>
<EventSetter Event="ContextMenuOpening" Handler="StageTreeContextMenuOpening"/> <Setter TargetName="icon" Property="Visibility" Value="Collapsed"/>
</Style> </DataTrigger>
</TreeView.ItemContainerStyle> <MultiDataTrigger>
<TreeView.ItemTemplate> <MultiDataTrigger.Conditions>
<HierarchicalDataTemplate ItemsSource="{Binding Children}"> <Condition Binding="{Binding IsFile}" Value="False"/>
<StackPanel Orientation="Horizontal" Height="24"> <Condition Binding="{Binding IsNodeExpanded}" Value="True"/>
<Border x:Name="status" Width="14" Height="14" Visibility="Collapsed" Background="{Binding Change, Converter={StaticResource StagedStatusConverter}}" CornerRadius="2" Margin="0,0,4,0"> </MultiDataTrigger.Conditions>
<TextBlock Text="{Binding Change, Converter={StaticResource StagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="10" RenderOptions.BitmapScalingMode="HighQuality"/> <Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</MultiDataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<DataGrid
Grid.Row="3"
x:Name="stageList"
ItemsSource="{Binding ElementName=me, Path=StagedListData, IsAsync=False}"
RowHeight="24"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
SelectionChanged="StagedListSelectionChanged"
SelectionMode="Extended"
SelectionUnit="FullRow"
Background="{StaticResource Brush.Contents}">
<DataGrid.Resources>
<Style x:Key="Style.DataGridText.VerticalCenter" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="4,0"/>
</Style>
<RoutedUICommand x:Key="SelectWholeDataGridCommand" Text="SelectWholeDataGrid"/>
</DataGrid.Resources>
<DataGrid.InputBindings>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeDataGridCommand}"/>
</DataGrid.InputBindings>
<DataGrid.CommandBindings>
<CommandBinding Command="{StaticResource SelectWholeDataGridCommand}" Executed="SelectWholeDataGrid"/>
</DataGrid.CommandBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Width="22">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Width="14" Height="14" x:Name="status" Background="{Binding ., Converter={StaticResource StagedStatusConverter}}" CornerRadius="2" Margin="2,0">
<TextBlock Text="{Binding ., Converter={StaticResource StagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="8"/>
</Border> </Border>
<Path x:Name="icon" Width="14" Fill="Goldenrod" Data="{StaticResource Icon.Folder.Fill}"/> </DataTemplate>
<TextBlock Text="{Binding Name}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" Margin="4,0,0,0" FontSize="11"/> </DataGridTemplateColumn.CellTemplate>
</StackPanel> </DataGridTemplateColumn>
<HierarchicalDataTemplate.Triggers> <DataGridTextColumn
<DataTrigger Binding="{Binding IsFile}" Value="True"> Width="Auto"
<Setter TargetName="status" Property="Visibility" Value="Visible"/> Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
<Setter TargetName="icon" Property="Visibility" Value="Collapsed"/> Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
</DataTrigger> Foreground="{StaticResource Brush.FG1}"
<MultiDataTrigger> FontFamily="Consolas"
<MultiDataTrigger.Conditions> ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<Condition Binding="{Binding IsFile}" Value="False"/>
<Condition Binding="{Binding IsNodeExpanded}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</MultiDataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<DataGrid <DataGridTextColumn
Grid.Row="2" Width="*"
x:Name="stageList" Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
ItemsSource="{Binding ElementName=me, Path=StagedListData, IsAsync=False}" Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
RowHeight="24" Foreground="{StaticResource Brush.FG2}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}" FontFamily="Consolas"
SelectionChanged="StagedListSelectionChanged" ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
SelectionMode="Extended"
SelectionUnit="FullRow"
Background="{StaticResource Brush.Contents}">
<DataGrid.Resources>
<Style x:Key="Style.DataGridText.VerticalCenter" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Padding" Value="4,0"/>
</Style>
<RoutedUICommand x:Key="SelectWholeDataGridCommand" Text="SelectWholeDataGrid"/> <DataGridTextColumn
</DataGrid.Resources> Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
</DataGrid.Columns>
<DataGrid.InputBindings> <DataGrid.RowStyle>
<KeyBinding Key="A" Modifiers="Ctrl" Command="{StaticResource SelectWholeDataGridCommand}"/> <Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
</DataGrid.InputBindings> <EventSetter Event="ContextMenuOpening" Handler="StagedListContextMenuOpening"/>
</Style>
<DataGrid.CommandBindings> </DataGrid.RowStyle>
<CommandBinding Command="{StaticResource SelectWholeDataGridCommand}" Executed="SelectWholeDataGrid"/> </DataGrid>
</DataGrid.CommandBindings>
<DataGrid.Columns>
<DataGridTemplateColumn Width="22">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Width="14" Height="14" x:Name="status" Background="{Binding ., Converter={StaticResource StagedStatusConverter}}" CornerRadius="2" Margin="2,0">
<TextBlock Text="{Binding ., Converter={StaticResource StagedStatusIconConverter}}" Foreground="{StaticResource Brush.FG1}" TextAlignment="Center" VerticalAlignment="Center" FontSize="8"/>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="Auto"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
Foreground="{StaticResource Brush.FG2}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG1}"
FontFamily="Consolas"
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
<EventSetter Event="ContextMenuOpening" Handler="StagedListContextMenuOpening"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
</Grid>
</Grid> </Grid>
<!-- Splitter --> <!-- Splitter -->