mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-01 01:14:59 +00:00
feature<WorkingCopy>: add grid layout for unstaged and staged files mode
This commit is contained in:
parent
ab98191875
commit
8a6d970498
8 changed files with 278 additions and 30 deletions
49
src/UI/FilesDisplayModeSwitch.xaml
Normal file
49
src/UI/FilesDisplayModeSwitch.xaml
Normal file
|
@ -0,0 +1,49 @@
|
|||
<UserControl x:Class="SourceGit.UI.FilesDisplayModeSwitch"
|
||||
x:Name="me"
|
||||
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:SourceGit.Converters"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<converters:FilesDisplayModeToIcon x:Key="FilesDisplayModeToIcon"/>
|
||||
<Style x:Key="Style.Icon.DisplayMode" TargetType="{x:Type Path}" BasedOn="{StaticResource Style.Icon}">
|
||||
<Setter Property="Fill" Value="Transparent"/>
|
||||
<Setter Property="Stroke" Value="{StaticResource Brush.FG}"/>
|
||||
<Setter Property="StrokeThickness" Value=".4"/>
|
||||
<Setter Property="Width" Value="12"/>
|
||||
<Setter Property="Height" Value="12"/>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
|
||||
<Button Click="OpenModeSelector" ToolTip="CHANGE FILES DISPLAY MODE" Margin="4,0">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu x:Name="selector" Placement="Bottom" StaysOpen="False" Focusable="True">
|
||||
<MenuItem Header="Show As Grid" Click="UseGrid">
|
||||
<MenuItem.Icon>
|
||||
<Path Style="{StaticResource Style.Icon.DisplayMode}" Data="{StaticResource Icon.Grid}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem Header="Show As List" Click="UseList">
|
||||
<MenuItem.Icon>
|
||||
<Path Style="{StaticResource Style.Icon.DisplayMode}" Data="{StaticResource Icon.List}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem Header="Show As Tree" Click="UseTree">
|
||||
<MenuItem.Icon>
|
||||
<Path Style="{StaticResource Style.Icon.DisplayMode}" Data="{StaticResource Icon.Tree}"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
|
||||
<Path
|
||||
Style="{StaticResource Style.Icon.DisplayMode}"
|
||||
Data="{Binding ElementName=me, Path=Mode, Converter={StaticResource FilesDisplayModeToIcon}}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
46
src/UI/FilesDisplayModeSwitch.xaml.cs
Normal file
46
src/UI/FilesDisplayModeSwitch.xaml.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGit.UI {
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for FilesDisplayModeSwitch.xaml
|
||||
/// </summary>
|
||||
public partial class FilesDisplayModeSwitch : UserControl {
|
||||
|
||||
public static readonly DependencyProperty ModeProperty =
|
||||
DependencyProperty.Register(
|
||||
"Mode",
|
||||
typeof(Git.Preference.FilesDisplayMode),
|
||||
typeof(FilesDisplayModeSwitch),
|
||||
new PropertyMetadata(Git.Preference.FilesDisplayMode.Grid));
|
||||
|
||||
public Git.Preference.FilesDisplayMode Mode {
|
||||
get { return (Git.Preference.FilesDisplayMode)GetValue(ModeProperty); }
|
||||
set { SetValue(ModeProperty, value); }
|
||||
}
|
||||
|
||||
public FilesDisplayModeSwitch() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OpenModeSelector(object sender, RoutedEventArgs e) {
|
||||
selector.PlacementTarget = sender as Button;
|
||||
selector.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UseGrid(object sender, RoutedEventArgs e) {
|
||||
Mode = Git.Preference.FilesDisplayMode.Grid;
|
||||
}
|
||||
|
||||
private void UseList(object sender, RoutedEventArgs e) {
|
||||
Mode = Git.Preference.FilesDisplayMode.List;
|
||||
}
|
||||
|
||||
private void UseTree(object sender, RoutedEventArgs e) {
|
||||
Mode = Git.Preference.FilesDisplayMode.Tree;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,12 @@
|
|||
<converters:FileStatusToIcon x:Key="UnstagedStatusIconConverter" OnlyWorkTree="True"/>
|
||||
<converters:FileStatusToColor x:Key="StagedStatusConverter"/>
|
||||
<converters:FileStatusToIcon x:Key="StagedStatusIconConverter"/>
|
||||
<converters:FilesDisplayModeToList x:Key="FilesDisplayModeToList"/>
|
||||
<converters:FilesDisplayModeToList x:Key="FilesDisplayModeToListOnly" TreatGridAsList="False"/>
|
||||
<converters:FilesDisplayModeToTree x:Key="FilesDisplayModeToTree"/>
|
||||
<converters:FilesDisplayModeToGrid x:Key="FilesDisplayModeToGrid"/>
|
||||
<converters:PathToFileName x:Key="PathToFileName"/>
|
||||
<converters:PathToFolderName x:Key="PathToFolderName"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Background="{StaticResource Brush.BG3}">
|
||||
|
@ -51,13 +57,10 @@
|
|||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ToggleButton
|
||||
Grid.Column="0"
|
||||
x:Name="toggleUnstangedMode"
|
||||
Margin="4,0,4,0"
|
||||
ToolTip="SWITCH TO LIST/TREE VIEW"
|
||||
Style="{StaticResource Style.ToggleButton.ListOrTree}"
|
||||
IsChecked="{Binding Source={x:Static source:App.Preference}, Path=UIUseListInUnstaged, Mode=TwoWay}"/>
|
||||
<local:FilesDisplayModeSwitch
|
||||
Grid.Column="0"
|
||||
Mode="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Mode=TwoWay}"
|
||||
Opacity=".4"/>
|
||||
<Label Grid.Column="1" Content="UNSTAGED" FontWeight="Bold" Foreground="{StaticResource Brush.FG}" Opacity=".4"/>
|
||||
<Button Grid.Column="3" Click="Stage" Margin="4,0" ToolTip="STAGE" Background="Transparent">
|
||||
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Down}" Opacity=".4"/>
|
||||
|
@ -71,7 +74,7 @@
|
|||
Grid.Row="1"
|
||||
x:Name="unstagedTree"
|
||||
Background="{StaticResource Brush.BG2}"
|
||||
Visibility="{Binding ElementName=toggleUnstangedMode, Path=IsChecked, Converter={StaticResource InverseBoolToCollapsed}}"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
|
||||
FontFamily="Consolas"
|
||||
PreviewMouseWheel="TreeMouseWheel"
|
||||
helpers:TreeViewHelper.EnableMultiSelection="True"
|
||||
|
@ -124,7 +127,7 @@
|
|||
<DataGrid
|
||||
Grid.Row="1"
|
||||
x:Name="unstagedList"
|
||||
Visibility="{Binding ElementName=toggleUnstangedMode, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
|
||||
RowHeight="24"
|
||||
SelectionChanged="UnstagedListSelectionChanged"
|
||||
SelectionMode="Extended"
|
||||
|
@ -133,6 +136,7 @@
|
|||
<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"/>
|
||||
|
@ -156,7 +160,30 @@
|
|||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Width="*" Binding="{Binding Path}" Foreground="{StaticResource Brush.FG}" FontFamily="Consolas" ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="Auto"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
|
||||
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
|
||||
Foreground="{StaticResource Brush.FG}"
|
||||
FontFamily="Consolas"
|
||||
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, 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.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
|
||||
Binding="{Binding Path}"
|
||||
Foreground="{StaticResource Brush.FG}"
|
||||
FontFamily="Consolas"
|
||||
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
</DataGrid.Columns>
|
||||
|
||||
<DataGrid.RowStyle>
|
||||
|
@ -186,13 +213,10 @@
|
|||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ToggleButton
|
||||
Grid.Column="0"
|
||||
x:Name="toggleStagedMode"
|
||||
Margin="4,0,4,0"
|
||||
ToolTip="SWITCH TO LIST/TREE VIEW"
|
||||
Style="{StaticResource Style.ToggleButton.ListOrTree}"
|
||||
IsChecked="{Binding Source={x:Static source:App.Preference}, Path=UIUseListInStaged, Mode=TwoWay}"/>
|
||||
<local:FilesDisplayModeSwitch
|
||||
Grid.Column="0"
|
||||
Mode="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Mode=TwoWay}"
|
||||
Opacity=".4"/>
|
||||
<Label Grid.Column="1" Content="STAGED" FontWeight="Bold" Foreground="{StaticResource Brush.FG}" Opacity=".4"/>
|
||||
<Button Grid.Column="3" Click="Unstage" ToolTip="UNSTAGE" Margin="4,0" Background="Transparent">
|
||||
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Up}" Opacity=".4"/>
|
||||
|
@ -205,8 +229,8 @@
|
|||
<TreeView
|
||||
Grid.Row="1"
|
||||
x:Name="stageTree"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
|
||||
Background="{StaticResource Brush.BG2}"
|
||||
Visibility="{Binding ElementName=toggleStagedMode, Path=IsChecked, Converter={StaticResource InverseBoolToCollapsed}}"
|
||||
FontFamily="Consolas"
|
||||
PreviewMouseWheel="TreeMouseWheel"
|
||||
helpers:TreeViewHelper.EnableMultiSelection="True"
|
||||
|
@ -259,8 +283,8 @@
|
|||
<DataGrid
|
||||
Grid.Row="1"
|
||||
x:Name="stageList"
|
||||
Visibility="{Binding ElementName=toggleStagedMode, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
RowHeight="24"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
|
||||
SelectionChanged="StagedListSelectionChanged"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow"
|
||||
|
@ -268,6 +292,7 @@
|
|||
<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"/>
|
||||
|
@ -291,7 +316,30 @@
|
|||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Width="*" Binding="{Binding Path}" Foreground="{StaticResource Brush.FG}" FontFamily="Consolas" ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="Auto"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
|
||||
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
|
||||
Foreground="{StaticResource Brush.FG}"
|
||||
FontFamily="Consolas"
|
||||
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, 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.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
|
||||
Binding="{Binding Path}"
|
||||
Foreground="{StaticResource Brush.FG}"
|
||||
FontFamily="Consolas"
|
||||
ElementStyle="{StaticResource Style.DataGridText.VerticalCenter}"/>
|
||||
</DataGrid.Columns>
|
||||
|
||||
<DataGrid.RowStyle>
|
||||
|
|
|
@ -495,7 +495,7 @@ namespace SourceGit.UI {
|
|||
private async void Stage(object sender, RoutedEventArgs e) {
|
||||
var files = new List<string>();
|
||||
|
||||
if (App.Preference.UIUseListInUnstaged) {
|
||||
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
|
||||
var selected = unstagedList.SelectedItems;
|
||||
foreach (var one in selected) {
|
||||
var node = one as Git.Change;
|
||||
|
@ -695,7 +695,7 @@ namespace SourceGit.UI {
|
|||
private async void Unstage(object sender, RoutedEventArgs e) {
|
||||
var files = new List<string>();
|
||||
|
||||
if (App.Preference.UIUseListInStaged) {
|
||||
if (App.Preference.UIStagedDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
|
||||
var selected = stageList.SelectedItems;
|
||||
foreach (var one in selected) {
|
||||
var node = one as Git.Change;
|
||||
|
@ -867,7 +867,7 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
string file = null;
|
||||
if (App.Preference.UIUseListInUnstaged) {
|
||||
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
|
||||
var selected = unstagedList.SelectedItems;
|
||||
if (selected.Count <= 0) return;
|
||||
|
||||
|
@ -894,7 +894,7 @@ namespace SourceGit.UI {
|
|||
|
||||
private async void UseTheirs(object sender, RoutedEventArgs e) {
|
||||
var files = new List<string>();
|
||||
if (App.Preference.UIUseListInUnstaged) {
|
||||
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
|
||||
var selected = unstagedList.SelectedItems;
|
||||
foreach (var one in selected) {
|
||||
var node = one as Git.Change;
|
||||
|
@ -923,7 +923,7 @@ namespace SourceGit.UI {
|
|||
|
||||
private async void UseMine(object sender, RoutedEventArgs e) {
|
||||
var files = new List<string>();
|
||||
if (App.Preference.UIUseListInUnstaged) {
|
||||
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
|
||||
var selected = unstagedList.SelectedItems;
|
||||
foreach (var one in selected) {
|
||||
var node = one as Git.Change;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue