mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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 object Backend { get; private set; } = null;
|
||||||
public int Depth { get; set; } = 0;
|
public int Depth { get; set; } = 0;
|
||||||
public bool IsFiltered { get; set; } = false;
|
public bool IsFiltered { get; set; } = false;
|
||||||
|
public bool IsSelected { get; set; } = false;
|
||||||
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
|
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
|
||||||
|
|
||||||
public bool IsExpanded
|
public bool IsExpanded
|
||||||
|
|
|
@ -154,21 +154,24 @@ namespace SourceGit.Views
|
||||||
if (selected == null || selected.Count == 0)
|
if (selected == null || selected.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var set = new HashSet<ViewModels.BranchTreeNode>();
|
foreach (var item in e.AddedItems)
|
||||||
foreach (var item in selected)
|
|
||||||
{
|
{
|
||||||
if (item is ViewModels.BranchTreeNode node)
|
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 prev = null as ViewModels.BranchTreeNode;
|
||||||
var isPrevSelected = false;
|
|
||||||
foreach (var row in Rows)
|
foreach (var row in Rows)
|
||||||
{
|
{
|
||||||
var isSelected = set.Contains(row);
|
if (row.IsSelected)
|
||||||
if (isSelected)
|
|
||||||
{
|
{
|
||||||
if (isPrevSelected)
|
if (prev is { IsSelected: true })
|
||||||
{
|
{
|
||||||
var prevTop = prev.CornerRadius.TopLeft;
|
var prevTop = prev.CornerRadius.TopLeft;
|
||||||
prev.CornerRadius = new CornerRadius(prevTop, 0);
|
prev.CornerRadius = new CornerRadius(prevTop, 0);
|
||||||
|
@ -180,7 +183,6 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isPrevSelected = isSelected;
|
|
||||||
prev = row;
|
prev = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue