enhance: using lightweight ListBox instead of DataGrid to improve performance

This commit is contained in:
leo 2024-08-27 21:28:48 +08:00
parent 1f07c1bdf0
commit 7776cda475
No known key found for this signature in database
12 changed files with 465 additions and 529 deletions

View file

@ -275,7 +275,7 @@ namespace SourceGit.Models
unsolved.Remove(l); unsolved.Remove(l);
} }
// Margins & merge state (used by datagrid). // Margins & merge state (used by Views.Histories).
commit.IsMerged = isMerged; commit.IsMerged = isMerged;
commit.Margin = new Thickness(Math.Max(offsetX + HALF_WIDTH, oldCount * UNIT_WIDTH + H_MARGIN) + H_MARGIN, 0, 0, 0); commit.Margin = new Thickness(Math.Max(offsetX + HALF_WIDTH, oldCount * UNIT_WIDTH + H_MARGIN) + H_MARGIN, 0, 0, 0);

View file

@ -309,7 +309,11 @@ namespace SourceGit.ViewModels
public Models.Commit SearchResultSelectedCommit public Models.Commit SearchResultSelectedCommit
{ {
get => _searchResultSelectedCommit; get => _searchResultSelectedCommit;
set => SetProperty(ref _searchResultSelectedCommit, value); set
{
if (SetProperty(ref _searchResultSelectedCommit, value) && value != null)
NavigateToCommit(value.SHA);
}
} }
public void Open() public void Open()

View file

@ -53,44 +53,42 @@
<!-- Unchanged Files --> <!-- Unchanged Files -->
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<DataGrid Margin="8" <ListBox Margin="8"
Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Files}"
SelectionMode="Single"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
IsReadOnly="True"
HeadersVisibility="None"
Focusable="False"
RowHeight="26"
BorderThickness="1" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"
HorizontalScrollBarVisibility="Disabled" Background="{DynamicResource Brush.Contents}"
VerticalScrollBarVisibility="Auto"> SelectionMode="Single"
<DataGrid.Columns> ItemsSource="{Binding Files}"
<DataGridTemplateColumn Width="*"> ScrollViewer.HorizontalScrollBarVisibility="Disabled"
<DataGridTemplateColumn.CellTemplate> ScrollViewer.VerticalScrollBarVisibility="Auto">
<DataTemplate> <ListBox.Styles>
<StackPanel Orientation="Horizontal"> <Style Selector="ListBoxItem">
<Path Width="14" Height="14" Margin="8,0,4,0" Data="{StaticResource Icons.File}"/> <Setter Property="Margin" Value="0"/>
<TextBlock Text="{Binding}" Margin="4,0"/> <Setter Property="Padding" Value="0"/>
</StackPanel> <Setter Property="Height" Value="26"/>
</DataTemplate> </Style>
</DataGridTemplateColumn.CellTemplate> </ListBox.Styles>
</DataGridTemplateColumn>
<DataGridTemplateColumn> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<Button Classes="icon_button" Click="OnRemoveButtonClicked"> <Grid Height="26" ColumnDefinitions="26,*,30">
<Path Grid.Column="0" Width="14" Height="14" Margin="8,0,0,0" HorizontalAlignment="Center" Data="{StaticResource Icons.File}"/>
<Border Grid.Column="1" Margin="4,0" ClipToBounds="True">
<TextBlock Grid.Column="1" Text="{Binding}" HorizontalAlignment="Left"/>
</Border>
<Button Grid.Column="2" Classes="icon_button" Click="OnRemoveButtonClicked">
<Path Width="14" Height="14" Data="{StaticResource Icons.Clear}"/> <Path Width="14" Height="14" Data="{StaticResource Icons.Clear}"/>
</Button> </Button>
</Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<!-- Empty --> <!-- Empty -->
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"

View file

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.DeleteMultipleBranches" x:Class="SourceGit.Views.DeleteMultipleBranches"
@ -17,56 +18,37 @@
BorderBrush="{DynamicResource Brush.Border1}" BorderBrush="{DynamicResource Brush.Border1}"
CornerRadius="4" CornerRadius="4"
Padding="4"> Padding="4">
<DataGrid MaxHeight="200" <ListBox MaxHeight="200"
Background="Transparent"
BorderThickness="0" BorderThickness="0"
Background="Transparent"
ItemsSource="{Binding Targets}" ItemsSource="{Binding Targets}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Auto"
CanUserResizeColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
CanUserSortColumns="False" <ListBox.Styles>
IsReadOnly="True" <Style Selector="ListBoxItem">
HeadersVisibility="None" <Setter Property="Margin" Value="0"/>
Focusable="False" <Setter Property="Padding" Value="0"/>
RowHeight="26" <Setter Property="Height" Value="26"/>
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<DataGrid.Styles>
<Style Selector="DataGridRow">
<Setter Property="CornerRadius" Value="4"/> <Setter Property="CornerRadius" Value="4"/>
</Style> </Style>
</ListBox.Styles>
<Style Selector="DataGridRow /template/ Border#RowBorder"> <ListBox.ItemsPanel>
<Setter Property="ClipToBounds" Value="True" /> <ItemsPanelTemplate>
</Style> <VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle"> <ListBox.ItemTemplate>
<Setter Property="Fill" Value="{DynamicResource Brush.AccentHovered}" /> <DataTemplate DataType="m:Branch">
</Style> <Grid Height="26" ColumnDefinitions="22,*">
<Path Grid.Column="0" Width="10" Height="10" Margin="4,0,8,0" Data="{StaticResource Icons.Branch}" />
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle"> <TextBlock Grid.Column="1" Text="{Binding FriendlyName}" Classes="primary" />
<Setter Property="Fill" Value="{DynamicResource Brush.Accent}" /> </Grid>
</Style>
</DataGrid.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Path Width="10" Height="10" Margin="4,0,8,0" Data="{StaticResource Icons.Branch}" />
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
<DataGridTemplateColumn Width="*" Header="NAME">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding FriendlyName}" ClipToBounds="True" Classes="primary" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border> </Border>
<TextBlock Margin="4,8,0,0" <TextBlock Margin="4,8,0,0"

View file

@ -53,7 +53,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<DataGrid Grid.Column="0" <ListBox Grid.Column="0"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
BorderThickness="1" BorderThickness="1"
Margin="8,4,4,8" Margin="8,4,4,8"
@ -61,24 +61,29 @@
ItemsSource="{Binding Commits}" ItemsSource="{Binding Commits}"
SelectedItem="{Binding SelectedCommit, Mode=TwoWay}" SelectedItem="{Binding SelectedCommit, Mode=TwoWay}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
CanUserSortColumns="False" <ListBox.Styles>
IsReadOnly="True" <Style Selector="ListBoxItem">
HeadersVisibility="None" <Setter Property="Margin" Value="0"/>
Focusable="False" <Setter Property="Padding" Value="0"/>
RowHeight="50" <Setter Property="Height" Value="50"/>
HorizontalScrollBarVisibility="Disabled" </Style>
VerticalScrollBarVisibility="Auto"> </ListBox.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Width="*"> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4"> <Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto"> <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto">
<v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/> <v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/> <TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0" ClipToBounds="True"/>
<TextBlock Grid.Column="2" <TextBlock Grid.Column="2"
Classes="primary" Classes="primary"
Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
@ -94,10 +99,8 @@
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<GridSplitter Grid.Column="1" <GridSplitter Grid.Column="1"
MinWidth="1" MinWidth="1"

View file

@ -66,39 +66,41 @@
<!-- Body --> <!-- Body -->
<Border Grid.Row="2" Margin="8,0,8,8" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"> <Border Grid.Row="2" Margin="8,0,8,8" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<Grid RowDefinitions="*,3,*"> <Grid RowDefinitions="*,3,*">
<DataGrid Grid.Row="0" <ListBox Grid.Row="0"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Items}" ItemsSource="{Binding Items}"
SelectionMode="Single" SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
CanUserReorderColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto"
CanUserSortColumns="False" KeyDown="OnItemsListBoxKeyDown">
IsReadOnly="True" <ListBox.Styles>
HeadersVisibility="None" <Style Selector="ListBoxItem">
Focusable="False" <Setter Property="Margin" Value="0"/>
RowHeight="28" <Setter Property="Padding" Value="0"/>
HorizontalScrollBarVisibility="Disabled" <Setter Property="Height" Value="28"/>
VerticalScrollBarVisibility="Auto" </Style>
KeyDown="OnDataGridKeyDown"> </ListBox.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Width="16" Header="DragHandler"> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}"> <VirtualizingStackPanel Orientation="Vertical"/>
<Border Background="Transparent" </ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="vm:InteractiveRebaseItem">
<Grid ColumnDefinitions="16,110,*,40,100,96,156,32,32">
<!-- Drag & Drop Anchor -->
<Border Grid.Column="0" Background="Transparent"
Margin="4,0,0,0" Margin="4,0,0,0"
Loaded="OnSetupRowHeaderDragDrop" Loaded="OnSetupRowHeaderDragDrop"
PointerPressed="OnRowHeaderPointerPressed"> PointerPressed="OnRowHeaderPointerPressed">
<Path Width="14" Height="14" Data="{StaticResource Icons.Move}" Fill="{DynamicResource Brush.FG2}"/> <Path Width="14" Height="14" Data="{StaticResource Icons.Move}" Fill="{DynamicResource Brush.FG2}"/>
</Border> </Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Option"> <!-- Action -->
<DataGridTemplateColumn.CellTemplate> <Button Grid.Column="1" Opacity="1" Margin="4,0,0,0" Padding="8,2" Background="Transparent">
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<Button Opacity="1" Margin="4,0,0,0" Padding="8,2" Background="Transparent">
<Button.Flyout> <Button.Flyout>
<MenuFlyout Placement="BottomEdgeAlignedLeft" VerticalOffset="-4"> <MenuFlyout Placement="BottomEdgeAlignedLeft" VerticalOffset="-4">
<MenuItem InputGesture="P" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Pick}"> <MenuItem InputGesture="P" Command="{Binding SetAction}" CommandParameter="{x:Static m:InteractiveRebaseAction.Pick}">
@ -180,14 +182,9 @@
<TextBlock Classes="primary" Margin="8,0" Text="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.ToName}}"/> <TextBlock Classes="primary" Margin="8,0" Text="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.ToName}}"/>
</StackPanel> </StackPanel>
</Button> </Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*" Header="SUBJECT"> <!-- Subject -->
<DataGridTemplateColumn.CellTemplate> <StackPanel Grid.Column="2" Orientation="Horizontal" ClipToBounds="True">
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<StackPanel Orientation="Horizontal">
<Button Classes="icon_button" IsVisible="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.CanEditMessage}}"> <Button Classes="icon_button" IsVisible="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.CanEditMessage}}">
<Button.Flyout> <Button.Flyout>
<Flyout Placement="BottomEdgeAlignedLeft"> <Flyout Placement="BottomEdgeAlignedLeft">
@ -200,69 +197,41 @@
</Button> </Button>
<TextBlock Classes="primary" Text="{Binding Subject}" Margin="8,0,0,0"/> <TextBlock Classes="primary" Text="{Binding Subject}" Margin="8,0,0,0"/>
</StackPanel> </StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="AVATAR"> <!-- Avatar -->
<DataGridTemplateColumn.CellTemplate> <v:Avatar Grid.Column="3"
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}"> Width="16" Height="16"
<v:Avatar Width="16" Height="16"
Margin="16,0,8,0" Margin="16,0,8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False" IsHitTestVisible="False"
User="{Binding Commit.Author}"/> User="{Binding Commit.Author}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn MaxWidth="100" Header="AUTHOR"> <!-- Author -->
<DataGridTemplateColumn.CellTemplate> <Border Grid.Column="4" ClipToBounds="True">
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}"> <TextBlock Classes="primary" Text="{Binding Commit.Author.Name}" HorizontalAlignment="Left"/>
<TextBlock Classes="primary" Text="{Binding Commit.Author.Name}" Margin="0,0,8,0"/> </Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="SHA"> <!-- Commit SHA -->
<DataGridTemplateColumn.CellTemplate> <TextBlock Grid.Column="5" Classes="primary"
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<TextBlock Classes="primary"
Text="{Binding Commit.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Text="{Binding Commit.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
Margin="12,0"/> Margin="12,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="TIME"> <!-- Commit Time -->
<DataGridTemplateColumn.CellTemplate> <TextBlock Grid.Column="6" Classes="primary" Text="{Binding Commit.CommitterTimeStr}" Margin="8,0"/>
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<TextBlock Classes="primary" Text="{Binding Commit.CommitterTimeStr}" Margin="8,0"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="32" Header="MOVE UP"> <!-- MoveUp Button -->
<DataGridTemplateColumn.CellTemplate> <Button Grid.Column="7" Classes="icon_button" Click="OnMoveItemUp" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveUp}">
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<Button Classes="icon_button" Click="OnMoveItemUp" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveUp}">
<Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Up}"/> <Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Up}"/>
</Button> </Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="32" Header="MOVE DOWN"> <!-- MoveDown Button -->
<DataGridTemplateColumn.CellTemplate> <Button Grid.Column="8" Classes="icon_button" Click="OnMoveItemDown" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveDown}">
<DataTemplate x:DataType="{x:Type vm:InteractiveRebaseItem}">
<Button Classes="icon_button" Click="OnMoveItemDown" ToolTip.Tip="{DynamicResource Text.InteractiveRebase.MoveDown}">
<Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Down}"/> <Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Down}"/>
</Button> </Button>
</Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<v:LoadingIcon Grid.Row="0" Width="48" Height="48" HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsLoading}"/> <v:LoadingIcon Grid.Row="0" Width="48" Height="48" HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsLoading}"/>

View file

@ -88,9 +88,9 @@ namespace SourceGit.Views
} }
} }
private void OnDataGridKeyDown(object sender, KeyEventArgs e) private void OnItemsListBoxKeyDown(object sender, KeyEventArgs e)
{ {
var item = (sender as DataGrid)?.SelectedItem as ViewModels.InteractiveRebaseItem; var item = (sender as ListBox)?.SelectedItem as ViewModels.InteractiveRebaseItem;
if (item == null) if (item == null)
return; return;

View file

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:vm="using:SourceGit.ViewModels" xmlns:vm="using:SourceGit.ViewModels"
xmlns:v="using:SourceGit.Views" xmlns:v="using:SourceGit.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@ -51,62 +52,48 @@
<!-- Locked Files --> <!-- Locked Files -->
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<DataGrid Margin="8" <ListBox Margin="8"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Locks}" ItemsSource="{Binding Locks}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
IsReadOnly="True"
HeadersVisibility="None"
Focusable="False"
RowHeight="26"
BorderThickness="1" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"
HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"> ScrollViewer.VerticalScrollBarVisibility="Auto">
<DataGrid.Columns> <ListBox.Styles>
<DataGridTemplateColumn Width="*"> <Style Selector="ListBoxItem">
<DataGridTemplateColumn.CellTemplate> <Setter Property="Margin" Value="0"/>
<DataTemplate> <Setter Property="Padding" Value="0"/>
<StackPanel Orientation="Horizontal"> <Setter Property="Height" Value="26"/>
<Path Width="14" Height="14" Margin="8,0,4,0" Data="{StaticResource Icons.File}"/> </Style>
<TextBlock Text="{Binding File}" Margin="4,0"/> </ListBox.Styles>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<DataTemplate> <VirtualizingStackPanel Orientation="Vertical"/>
<TextBlock Text="{Binding User}" Padding="16,0"/> </ItemsPanelTemplate>
</DataTemplate> </ListBox.ItemsPanel>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn> <ListBox.ItemTemplate>
<DataGridTemplateColumn.CellTemplate> <DataTemplate DataType="m:LFSLock">
<DataTemplate> <Grid ColumnDefinitions="26,*,100,32,32">
<Button Classes="icon_button" Click="OnUnlockButtonClicked" ToolTip.Tip="{DynamicResource Text.GitLFS.Locks.Unlock}"> <Path Grid.Column="0" Width="14" Height="14" Margin="8,0,4,0" Data="{StaticResource Icons.File}"/>
<Border Grid.Column="1" Margin="4,0" ClipToBounds="True">
<TextBlock Text="{Binding File}" HorizontalAlignment="Left"/>
</Border>
<Border Grid.Column="2" Margin="8,0" ClipToBounds="True">
<TextBlock Text="{Binding User}" HorizontalAlignment="Left"/>
</Border>
<Button Grid.Column="3" Classes="icon_button" Click="OnUnlockButtonClicked" ToolTip.Tip="{DynamicResource Text.GitLFS.Locks.Unlock}">
<Path Width="14" Height="14" Data="{StaticResource Icons.Unlock}"/> <Path Width="14" Height="14" Data="{StaticResource Icons.Unlock}"/>
</Button> </Button>
</DataTemplate> <Button Grid.Column="4" Classes="icon_button" Click="OnForceUnlockButtonClicked" ToolTip.Tip="{DynamicResource Text.GitLFS.Locks.UnlockForce}">
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Classes="icon_button" Click="OnForceUnlockButtonClicked" ToolTip.Tip="{DynamicResource Text.GitLFS.Locks.UnlockForce}">
<Path Width="14" Height="14" Fill="Red" Data="{StaticResource Icons.Unlock}"/> <Path Width="14" Height="14" Fill="Red" Data="{StaticResource Icons.Unlock}"/>
</Button> </Button>
</Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<!-- Empty --> <!-- Empty -->
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"

View file

@ -257,7 +257,7 @@
SelectionMode="Single" SelectionMode="Single"
ContextRequested="OnSubmoduleContextRequested" ContextRequested="OnSubmoduleContextRequested"
DoubleTapped="OnDoubleTappedSubmodule" DoubleTapped="OnDoubleTappedSubmodule"
PropertyChanged="OnLeftSidebarDataGridPropertyChanged" PropertyChanged="OnLeftSidebarListBoxPropertyChanged"
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}"> IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
<ListBox.Styles> <ListBox.Styles>
<Style Selector="ListBoxItem"> <Style Selector="ListBoxItem">
@ -312,7 +312,7 @@
SelectionMode="Single" SelectionMode="Single"
ContextRequested="OnWorktreeContextRequested" ContextRequested="OnWorktreeContextRequested"
DoubleTapped="OnDoubleTappedWorktree" DoubleTapped="OnDoubleTappedWorktree"
PropertyChanged="OnLeftSidebarDataGridPropertyChanged" PropertyChanged="OnLeftSidebarListBoxPropertyChanged"
IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}"> IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}">
<ListBox.Styles> <ListBox.Styles>
<Style Selector="ListBoxItem"> <Style Selector="ListBoxItem">
@ -445,48 +445,53 @@
</ComboBox> </ComboBox>
</Grid> </Grid>
<DataGrid Grid.Row="2" <ListBox Grid.Row="2"
ItemsSource="{Binding SearchedCommits}" ItemsSource="{Binding SearchedCommits}"
SelectionMode="Single" SelectionMode="Single"
SelectedItem="{Binding SearchResultSelectedCommit, Mode=OneWay}" SelectedItem="{Binding SearchResultSelectedCommit, Mode=TwoWay}"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
IsReadOnly="True"
HeadersVisibility="None"
Focusable="False"
RowHeight="50"
BorderThickness="1" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
CornerRadius="4" CornerRadius="4"
HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
SelectionChanged="OnSearchResultDataGridSelectionChanged"> <ListBox.Styles>
<DataGrid.Columns> <Style Selector="ListBoxItem">
<DataGridTemplateColumn Width="*"> <Setter Property="Margin" Value="0"/>
<DataGridTemplateColumn.CellTemplate> <Setter Property="Padding" Value="0"/>
<Setter Property="Height" Value="50"/>
</Style>
<Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Brush.AccentHovered}" />
</Style>
</ListBox.Styles>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Commit"> <DataTemplate DataType="m:Commit">
<Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4"> <Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4" Background="Transparent">
<Grid RowDefinitions="Auto,*"> <Grid RowDefinitions="Auto,*">
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto"> <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto">
<v:Avatar Width="16" Height="16" <v:Avatar Grid.Column="0" Width="16" Height="16" VerticalAlignment="Center" IsHitTestVisible="False" User="{Binding Author}"/>
VerticalAlignment="Center" <TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0" ClipToBounds="True"/>
IsHitTestVisible="False"
User="{Binding Author}"/>
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Author.Name}" Margin="8,0,0,0"/>
<TextBlock Grid.Column="2" Classes="primary" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange" Margin="8,0,0,0"/> <TextBlock Grid.Column="2" Classes="primary" Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange" Margin="8,0,0,0"/>
<TextBlock Grid.Column="3" Classes="primary" Text="{Binding AuthorTimeShortStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/> <TextBlock Grid.Column="3" Classes="primary" Text="{Binding AuthorTimeShortStr}" Foreground="{DynamicResource Brush.FG2}" Margin="8,0,0,0"/>
</Grid> </Grid>
<TextBlock Grid.Row="1" Text="{Binding Subject}" VerticalAlignment="Bottom"/> <TextBlock Grid.Row="1" Classes="primary" Text="{Binding Subject}" VerticalAlignment="Bottom"/>
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<Path Grid.Row="2" <Path Grid.Row="2"
HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center"

View file

@ -154,16 +154,6 @@ namespace SourceGit.Views
} }
} }
private void OnSearchResultDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is DataGrid { SelectedItem: Models.Commit commit } && DataContext is ViewModels.Repository repo)
{
repo.NavigateToCommit(commit.SHA);
}
e.Handled = true;
}
private void OnBranchTreeRowsChanged(object _, RoutedEventArgs e) private void OnBranchTreeRowsChanged(object _, RoutedEventArgs e)
{ {
UpdateLeftSidebarLayout(); UpdateLeftSidebarLayout();
@ -236,7 +226,7 @@ namespace SourceGit.Views
e.Handled = true; e.Handled = true;
} }
private void OnLeftSidebarDataGridPropertyChanged(object _, AvaloniaPropertyChangedEventArgs e) private void OnLeftSidebarListBoxPropertyChanged(object _, AvaloniaPropertyChangedEventArgs e)
{ {
if (e.Property == ListBox.ItemsSourceProperty || e.Property == ListBox.IsVisibleProperty) if (e.Property == ListBox.ItemsSourceProperty || e.Property == ListBox.IsVisibleProperty)
UpdateLeftSidebarLayout(); UpdateLeftSidebarLayout();

View file

@ -66,23 +66,28 @@
</Border> </Border>
<!-- Stash List --> <!-- Stash List -->
<DataGrid Grid.Row="2" <ListBox Grid.Row="2"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding VisibleStashes}" ItemsSource="{Binding VisibleStashes}"
SelectedItem="{Binding SelectedStash, Mode=TwoWay}" SelectedItem="{Binding SelectedStash, Mode=TwoWay}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
CanUserSortColumns="False" <ListBox.Styles>
IsReadOnly="True" <Style Selector="ListBoxItem">
HeadersVisibility="None" <Setter Property="Margin" Value="0"/>
Focusable="False" <Setter Property="Padding" Value="0"/>
RowHeight="50" <Setter Property="Height" Value="50"/>
HorizontalScrollBarVisibility="Disabled" </Style>
VerticalScrollBarVisibility="Auto"> </ListBox.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Width="*"> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Stash"> <DataTemplate DataType="m:Stash">
<Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4" Background="Transparent" ContextRequested="OnStashContextRequested"> <Border BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="0,0,0,1" Padding="4" Background="Transparent" ContextRequested="OnStashContextRequested">
<Grid RowDefinitions="Auto,*" > <Grid RowDefinitions="Auto,*" >
@ -95,10 +100,8 @@
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
<!-- Changes Bar --> <!-- Changes Bar -->
<Border Grid.Row="3" BorderThickness="0,1" BorderBrush="{DynamicResource Brush.Border0}"> <Border Grid.Row="3" BorderThickness="0,1" BorderBrush="{DynamicResource Brush.Border0}">
@ -110,38 +113,36 @@
</Border> </Border>
<!-- View Changes --> <!-- View Changes -->
<DataGrid Grid.Row="4" <ListBox Grid.Row="4"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
ItemsSource="{Binding Changes}" ItemsSource="{Binding Changes}"
SelectedItem="{Binding SelectedChange, Mode=TwoWay}" SelectedItem="{Binding SelectedChange, Mode=TwoWay}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
CanUserSortColumns="False" <ListBox.Styles>
IsReadOnly="True" <Style Selector="ListBoxItem">
HeadersVisibility="None" <Setter Property="Margin" Value="0"/>
Focusable="False" <Setter Property="Padding" Value="0"/>
RowHeight="26" <Setter Property="Height" Value="26"/>
HorizontalScrollBarVisibility="Auto" </Style>
VerticalScrollBarVisibility="Auto"> </ListBox.Styles>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<v:ChangeStatusIcon Width="14" Height="14" Change="{Binding}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*" Header="PATH"> <ListBox.ItemsPanel>
<DataGridTemplateColumn.CellTemplate> <ItemsPanelTemplate>
<DataTemplate> <VirtualizingStackPanel Orientation="Vertical"/>
<TextBlock Classes="primary" Text="{Binding Path}" Margin="4,0,0,0"/> </ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Change">
<Grid ColumnDefinitions="24,*">
<v:ChangeStatusIcon Grid.Column="0" Width="14" Height="14" Change="{Binding}"/>
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Path}" Margin="4,0,0,0"/>
</Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </ListBox.ItemTemplate>
</DataGridTemplateColumn> </ListBox>
</DataGrid.Columns>
</DataGrid>
</Grid> </Grid>
<GridSplitter Grid.Column="1" <GridSplitter Grid.Column="1"

View file

@ -134,46 +134,43 @@
<Grid ColumnDefinitions="256,*" Margin="8,8,8,16"> <Grid ColumnDefinitions="256,*" Margin="8,8,8,16">
<Grid Grid.Column="0" RowDefinitions="*,16"> <Grid Grid.Column="0" RowDefinitions="*,16">
<!-- Table By Committer --> <!-- Table By Committer -->
<DataGrid Grid.Row="0" <ListBox Grid.Column="0"
ItemsSource="{Binding ByCommitter}" ItemsSource="{Binding ByCommitter}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
HeadersVisibility="Column"
GridLinesVisibility="All"
BorderThickness="1" BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}" BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}" Background="{DynamicResource Brush.Contents}"
HorizontalGridLinesBrush="{DynamicResource Brush.Border2}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalGridLinesBrush="{DynamicResource Brush.Border2}" ScrollViewer.VerticalScrollBarVisibility="Auto">
IsReadOnly="True" <ListBox.Styles>
RowHeight="26" <Style Selector="ListBoxItem">
HorizontalScrollBarVisibility="Disabled" <Setter Property="Margin" Value="0"/>
VerticalScrollBarVisibility="Auto"> <Setter Property="Padding" Value="0"/>
<DataGrid.Styles> <Setter Property="Height" Value="26"/>
<Style Selector="DataGridColumnHeader">
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/>
<Setter Property="Padding" Value="8,0,0,0"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border2}"/>
<Setter Property="SeparatorBrush" Value="{DynamicResource Brush.Border2}" />
<Style Selector="^:pointerover /template/ Grid#PART_ColumnHeaderRoot">
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/>
</Style> </Style>
</ListBox.Styles>
<Style Selector="^:pressed /template/ Grid#PART_ColumnHeaderRoot"> <ListBox.ItemsPanel>
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/> <ItemsPanelTemplate>
</Style> <VirtualizingStackPanel Orientation="Vertical"/>
</Style> </ItemsPanelTemplate>
</DataGrid.Styles> </ListBox.ItemsPanel>
<DataGrid.Columns> <ListBox.ItemTemplate>
<DataGridTextColumn Width="150" Header="{DynamicResource Text.Statistics.Committer}" Binding="{Binding Name}"/> <DataTemplate DataType="m:StatisticsSample">
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" Binding="{Binding Count}"/> <Border BorderThickness="0,0,0,1" BorderBrush="{DynamicResource Brush.Border2}">
</DataGrid.Columns> <Grid ColumnDefinitions="*,150">
</DataGrid> <Border Grid.Column="0" Padding="8,0" ClipToBounds="True">
<TextBlock Text="{Binding Name}" HorizontalAlignment="Left"/>
</Border>
<Border Grid.Column="1" Padding="8,0" ClipToBounds="True">
<TextBlock Text="{Binding Count}" HorizontalAlignment="Right"/>
</Border>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Summary --> <!-- Summary -->
<Grid Grid.Row="1" ColumnDefinitions="*,*"> <Grid Grid.Row="1" ColumnDefinitions="*,*">