mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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>
|
||||
|
||||
<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 -->
|
||||
<ToggleButton Grid.Row="0" Classes="group_expander" IsChecked="{Binding IsLocalBranchGroupExpanded, Mode=TwoWay}">
|
||||
<TextBlock Classes="group_header_label" Margin="0" Text="{DynamicResource Text.Repository.LocalBranches}"/>
|
||||
|
@ -245,7 +245,8 @@
|
|||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnLocalBranchContextMenuRequested"
|
||||
SelectionChanged="OnLocalBranchTreeSelectionChanged">
|
||||
SelectionChanged="OnLocalBranchTreeSelectionChanged"
|
||||
PropertyChanged="OnLeftSidebarTreeViewPropertyChanged">
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
|
@ -325,7 +326,8 @@
|
|||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnRemoteBranchContextMenuRequested"
|
||||
SelectionChanged="OnRemoteBranchTreeSelectionChanged">
|
||||
SelectionChanged="OnRemoteBranchTreeSelectionChanged"
|
||||
PropertyChanged="OnLeftSidebarTreeViewPropertyChanged">
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem" x:DataType="vm:BranchTreeNode">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
|
@ -401,7 +403,8 @@
|
|||
VerticalScrollBarVisibility="Auto"
|
||||
IsVisible="{Binding IsTagGroupExpanded, Mode=OneWay}"
|
||||
SelectionChanged="OnTagDataGridSelectionChanged"
|
||||
ContextRequested="OnTagContextRequested">
|
||||
ContextRequested="OnTagContextRequested"
|
||||
PropertyChanged="OnLeftSidebarDataGridPropertyChanged">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridRow">
|
||||
<Setter Property="CornerRadius" Value="4" />
|
||||
|
@ -504,6 +507,7 @@
|
|||
VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnSubmoduleContextRequested"
|
||||
DoubleTapped="OnDoubleTappedSubmodule"
|
||||
PropertyChanged="OnLeftSidebarDataGridPropertyChanged"
|
||||
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridRow">
|
||||
|
@ -585,6 +589,7 @@
|
|||
VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnWorktreeContextRequested"
|
||||
DoubleTapped="OnDoubleTappedWorktree"
|
||||
PropertyChanged="OnLeftSidebarDataGridPropertyChanged"
|
||||
IsVisible="{Binding IsWorktreeGroupExpanded, Mode=OneWay}">
|
||||
<DataGrid.Styles>
|
||||
<Style Selector="DataGridRow">
|
||||
|
|
|
@ -18,6 +18,16 @@ namespace SourceGit.Views
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
if (branch.IsCurrent)
|
||||
return;
|
||||
|
||||
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;
|
||||
if (vm == null || vm.Settings == null)
|
||||
return;
|
||||
|
||||
var grid = sender as Grid;
|
||||
if (grid == null || !grid.IsAttachedToVisualTree())
|
||||
if (!IsLoaded)
|
||||
return;
|
||||
|
||||
var leftHeight = grid.Bounds.Height - 28.0 * 5;
|
||||
var leftHeight = leftSidebarGroups.Bounds.Height - 28.0 * 5;
|
||||
if (vm.IsTagGroupExpanded)
|
||||
{
|
||||
var desiredHeight = Math.Min(200.0, tagsList.RowHeight * vm.VisibleTags.Count);
|
||||
|
|
Loading…
Reference in a new issue