mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: improve performance
This commit is contained in:
parent
c03cc85232
commit
f904b3b71a
2 changed files with 51 additions and 10 deletions
|
@ -231,7 +231,7 @@
|
||||||
</TextBox.InnerRightContent>
|
</TextBox.InnerRightContent>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
|
||||||
<Grid Grid.Row="2" RowDefinitions="28,Auto,28,Auto,28,Auto,28,Auto,28,Auto" LayoutUpdated="OnDashboardLayoutUpdated">
|
<Grid Grid.Row="2" x:Name="leftSidebarGroups" RowDefinitions="28,Auto,28,Auto,28,Auto,28,Auto,28,Auto">
|
||||||
<!-- Local Branches -->
|
<!-- Local Branches -->
|
||||||
<ToggleButton Grid.Row="0" Classes="group_expander" IsChecked="{Binding IsLocalBranchGroupExpanded, Mode=TwoWay}">
|
<ToggleButton Grid.Row="0" Classes="group_expander" IsChecked="{Binding IsLocalBranchGroupExpanded, Mode=TwoWay}">
|
||||||
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.LocalBranches}"/>
|
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.LocalBranches}"/>
|
||||||
|
@ -245,7 +245,8 @@
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnLocalBranchContextMenuRequested"
|
ContextRequested="OnLocalBranchContextMenuRequested"
|
||||||
SelectionChanged="OnLocalBranchTreeSelectionChanged">
|
SelectionChanged="OnLocalBranchTreeSelectionChanged"
|
||||||
|
PropertyChanged="OnLeftSidebarTreeViewPropertyChanged">
|
||||||
<TreeView.Styles>
|
<TreeView.Styles>
|
||||||
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
||||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||||
|
@ -325,7 +326,8 @@
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnRemoteBranchContextMenuRequested"
|
ContextRequested="OnRemoteBranchContextMenuRequested"
|
||||||
SelectionChanged="OnRemoteBranchTreeSelectionChanged">
|
SelectionChanged="OnRemoteBranchTreeSelectionChanged"
|
||||||
|
PropertyChanged="OnLeftSidebarTreeViewPropertyChanged">
|
||||||
<TreeView.Styles>
|
<TreeView.Styles>
|
||||||
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
||||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||||
|
@ -401,7 +403,8 @@
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
||||||
SelectionChanged="OnTagDataGridSelectionChanged"
|
SelectionChanged="OnTagDataGridSelectionChanged"
|
||||||
ContextRequested="OnTagContextRequested">
|
ContextRequested="OnTagContextRequested"
|
||||||
|
PropertyChanged="OnLeftSidebarDataGridPropertyChanged">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridRow">
|
<Style Selector="DataGridRow">
|
||||||
<Setter Property="CornerRadius" Value="4" />
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
@ -504,6 +507,7 @@
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnSubmoduleContextRequested"
|
ContextRequested="OnSubmoduleContextRequested"
|
||||||
DoubleTapped="OnDoubleTappedSubmodule"
|
DoubleTapped="OnDoubleTappedSubmodule"
|
||||||
|
PropertyChanged="OnLeftSidebarDataGridPropertyChanged"
|
||||||
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
|
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridRow">
|
<Style Selector="DataGridRow">
|
||||||
|
@ -585,6 +589,7 @@
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
ContextRequested="OnWorktreeContextRequested"
|
ContextRequested="OnWorktreeContextRequested"
|
||||||
DoubleTapped="OnDoubleTappedWorktree"
|
DoubleTapped="OnDoubleTappedWorktree"
|
||||||
|
PropertyChanged="OnLeftSidebarDataGridPropertyChanged"
|
||||||
IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}">
|
IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}">
|
||||||
<DataGrid.Styles>
|
<DataGrid.Styles>
|
||||||
<Style Selector="DataGridRow">
|
<Style Selector="DataGridRow">
|
||||||
|
|
|
@ -18,6 +18,16 @@ namespace SourceGit.Views
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnLoaded(RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnLoaded(e);
|
||||||
|
|
||||||
|
if (DataContext is ViewModels.Repository repo && !repo.IsSearching)
|
||||||
|
{
|
||||||
|
UpdateLeftSidebarLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
|
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||||
|
@ -244,15 +254,24 @@ namespace SourceGit.Views
|
||||||
if (sender is Grid grid && DataContext is ViewModels.Repository repo)
|
if (sender is Grid grid && DataContext is ViewModels.Repository repo)
|
||||||
{
|
{
|
||||||
var node = grid.DataContext as ViewModels.BranchTreeNode;
|
var node = grid.DataContext as ViewModels.BranchTreeNode;
|
||||||
if (node != null && node.IsBranch)
|
if (node == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (node.IsBranch)
|
||||||
{
|
{
|
||||||
var branch = node.Backend as Models.Branch;
|
var branch = node.Backend as Models.Branch;
|
||||||
if (branch.IsCurrent)
|
if (branch.IsCurrent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
repo.CheckoutBranch(branch);
|
repo.CheckoutBranch(branch);
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
node.IsExpanded = !node.IsExpanded;
|
||||||
|
UpdateLeftSidebarLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,17 +388,34 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDashboardLayoutUpdated(object sender, EventArgs e)
|
private void OnLeftSidebarTreeViewPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Property == TreeView.ItemsSourceProperty || e.Property == TreeView.IsVisibleProperty)
|
||||||
|
{
|
||||||
|
if (sender is TreeView tree && tree.IsVisible)
|
||||||
|
UpdateLeftSidebarLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLeftSidebarDataGridPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Property == DataGrid.ItemsSourceProperty || e.Property == DataGrid.IsVisibleProperty)
|
||||||
|
{
|
||||||
|
if (sender is DataGrid datagrid && datagrid.IsVisible)
|
||||||
|
UpdateLeftSidebarLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLeftSidebarLayout()
|
||||||
{
|
{
|
||||||
var vm = DataContext as ViewModels.Repository;
|
var vm = DataContext as ViewModels.Repository;
|
||||||
if (vm == null || vm.Settings == null)
|
if (vm == null || vm.Settings == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var grid = sender as Grid;
|
if (!IsLoaded)
|
||||||
if (grid == null || !grid.IsAttachedToVisualTree())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var leftHeight = grid.Bounds.Height - 28.0 * 5;
|
var leftHeight = leftSidebarGroups.Bounds.Height - 28.0 * 5;
|
||||||
if (vm.IsTagGroupExpanded)
|
if (vm.IsTagGroupExpanded)
|
||||||
{
|
{
|
||||||
var desiredHeight = Math.Min(200.0, tagsList.RowHeight * vm.VisibleTags.Count);
|
var desiredHeight = Math.Min(200.0, tagsList.RowHeight * vm.VisibleTags.Count);
|
||||||
|
|
Loading…
Reference in a new issue