mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
fix: TreeView
do NOT support NavigationMethod.Direction with invisible nodes (#391)
This commit is contained in:
parent
71d36698f8
commit
af6d2cc725
3 changed files with 93 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
|
@ -76,6 +77,30 @@ namespace SourceGit.ViewModels
|
|||
Preference.Instance.MoveNode(from, to);
|
||||
}
|
||||
|
||||
public RepositoryNode GetPrevVisible(RepositoryNode node)
|
||||
{
|
||||
var visibleRows = new List<RepositoryNode>();
|
||||
CollectVisibleRows(visibleRows, RepositoryNodes);
|
||||
|
||||
var idx = visibleRows.IndexOf(node);
|
||||
if (idx <= 1)
|
||||
return null;
|
||||
|
||||
return visibleRows[idx - 1];
|
||||
}
|
||||
|
||||
public RepositoryNode GetNextVisible(RepositoryNode node)
|
||||
{
|
||||
var visibleRows = new List<RepositoryNode>();
|
||||
CollectVisibleRows(visibleRows, RepositoryNodes);
|
||||
|
||||
var idx = visibleRows.IndexOf(node);
|
||||
if (idx < 0 || idx >= visibleRows.Count - 1)
|
||||
return null;
|
||||
|
||||
return visibleRows[idx + 1];
|
||||
}
|
||||
|
||||
public ContextMenu CreateContextMenu(RepositoryNode node)
|
||||
{
|
||||
var menu = new ContextMenu();
|
||||
|
@ -212,6 +237,20 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
private void CollectVisibleRows(List<RepositoryNode> visible, AvaloniaList<RepositoryNode> collection)
|
||||
{
|
||||
foreach (var node in collection)
|
||||
{
|
||||
if (node.IsVisible)
|
||||
{
|
||||
visible.Add(node);
|
||||
|
||||
if (!node.IsRepository)
|
||||
CollectVisibleRows(visible, node.SubNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Welcome _instance = new Welcome();
|
||||
private string _searchFilter = string.Empty;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue