mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
enhance: improve selection changed event handler performance
This commit is contained in:
parent
3197b4bfe8
commit
36b8472d02
2 changed files with 11 additions and 8 deletions
|
@ -16,6 +16,7 @@ namespace SourceGit.ViewModels
|
|||
public object Backend { get; private set; } = null;
|
||||
public int Depth { get; set; } = 0;
|
||||
public bool IsFiltered { get; set; } = false;
|
||||
public bool IsSelected { get; set; } = false;
|
||||
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
|
||||
|
||||
public bool IsExpanded
|
||||
|
|
|
@ -154,21 +154,24 @@ namespace SourceGit.Views
|
|||
if (selected == null || selected.Count == 0)
|
||||
return;
|
||||
|
||||
var set = new HashSet<ViewModels.BranchTreeNode>();
|
||||
foreach (var item in selected)
|
||||
foreach (var item in e.AddedItems)
|
||||
{
|
||||
if (item is ViewModels.BranchTreeNode node)
|
||||
set.Add(node);
|
||||
node.IsSelected = true;
|
||||
}
|
||||
|
||||
foreach (var item in e.RemovedItems)
|
||||
{
|
||||
if (item is ViewModels.BranchTreeNode node)
|
||||
node.IsSelected = false;
|
||||
}
|
||||
|
||||
var prev = null as ViewModels.BranchTreeNode;
|
||||
var isPrevSelected = false;
|
||||
foreach (var row in Rows)
|
||||
{
|
||||
var isSelected = set.Contains(row);
|
||||
if (isSelected)
|
||||
if (row.IsSelected)
|
||||
{
|
||||
if (isPrevSelected)
|
||||
if (prev is { IsSelected: true })
|
||||
{
|
||||
var prevTop = prev.CornerRadius.TopLeft;
|
||||
prev.CornerRadius = new CornerRadius(prevTop, 0);
|
||||
|
@ -180,7 +183,6 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
isPrevSelected = isSelected;
|
||||
prev = row;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue