* UINavMenu: SelectPage增加Guid接口
This commit is contained in:
parent
8e9b4eea98
commit
ef146ceff8
Binary file not shown.
Binary file not shown.
@ -22,6 +22,7 @@ namespace Sunny.UI.Demo
|
||||
private void FButton_Load(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("1. FButton_Load");
|
||||
|
||||
}
|
||||
|
||||
//放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换,进入页面都会执行。
|
||||
|
@ -27,7 +27,6 @@
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
@ -889,27 +888,21 @@ namespace Sunny.UI
|
||||
|
||||
public void SelectPage(int pageIndex)
|
||||
{
|
||||
AllNodes.Clear();
|
||||
GetAllNodes(Nodes);
|
||||
if (AllNodes.ContainsKey(pageIndex))
|
||||
var node = MenuHelper.GetTreeNode(pageIndex);
|
||||
if (node != null)
|
||||
{
|
||||
SelectedNode = AllNodes[pageIndex];
|
||||
SelectedNode = node;
|
||||
ShowSelectedNode();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ConcurrentDictionary<int, TreeNode> AllNodes = new ConcurrentDictionary<int, TreeNode>();
|
||||
|
||||
private void GetAllNodes(TreeNodeCollection nodes)
|
||||
public void SelectPage(Guid pageGuid)
|
||||
{
|
||||
foreach (TreeNode node in nodes)
|
||||
var node = MenuHelper.GetTreeNode(pageGuid);
|
||||
if (node != null)
|
||||
{
|
||||
if (MenuHelper.GetPageIndex(node) >= 0)
|
||||
{
|
||||
AllNodes.TryAddOrUpdate(MenuHelper.GetPageIndex(node), node);
|
||||
}
|
||||
|
||||
GetAllNodes(node.Nodes);
|
||||
SelectedNode = node;
|
||||
ShowSelectedNode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,19 @@ namespace Sunny.UI
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public TreeNode GetTreeNode(Guid guid)
|
||||
{
|
||||
foreach (var pair in Items)
|
||||
{
|
||||
if (pair.Value.PageGuid == guid)
|
||||
{
|
||||
return pair.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class UITabControlHelper
|
||||
|
Loading…
x
Reference in New Issue
Block a user