/// <summary> /// 将扩展的Menu对应的XML节点解析成WinShellMenu集合。 /// </summary> /// <param name="menus">顶层WinShellMenu集合。</param> /// <param name="application">所属的WinShellApplication。</param> /// <param name="parent">父菜单。</param> /// <param name="topNode">顶层XML节点。</param> /// <param name="nodeLevel">XML节点层次。</param> private void CreateWinShellMenusFromXmlNode(List <WinShellMenu> menus, WinShellApplication application, WinShellMenu parent, XmlNode topNode, int nodeLevel) { if (menus == null) { menus = new List <WinShellMenu>(); } foreach (XmlNode childNode in topNode.ChildNodes) { if (childNode.NodeType == XmlNodeType.Element) { string type = null; if (childNode.Attributes["Class"] != null) { type = childNode.Attributes["Class"].Value; } string text = childNode.Attributes["Text"] == null ? string.Empty : childNode.Attributes["Text"].Value; string toolTip = childNode.Attributes["ToolTip"] == null ? string.Empty : childNode.Attributes["ToolTip"].Value; string icon = childNode.Attributes["Icon"] == null ? string.Empty : childNode.Attributes["Icon"].Value; string guid = Guid.NewGuid().ToString(); // 创建WinShellMenu对象。 WinShellMenu winShellMenu = new WinShellMenu(application, parent, text, toolTip, icon, type, nodeLevel, guid); menus.Add(winShellMenu); // 递归创建子节点对象。 int childNodeLevel = nodeLevel + 1; CreateWinShellMenusFromXmlNode(winShellMenu.Children, application, winShellMenu, childNode, childNodeLevel); } } }
public override bool Equals(object obj) { if (obj != null && obj is WinShellMenu) { WinShellMenu other = obj as WinShellMenu; return(Equals(Guid, other.Guid)); } return(false); }
public WinShellMenu(WinShellApplication application, WinShellMenu parent, string text, string tooltip, string icon, string className, int level, string guid) { Application = application; Parent = parent; Text = text; Tooltip = tooltip; Icon = icon; ClassName = className; Level = level; Guid = guid; Children = new List <WinShellMenu>(); }
public WinShellMenu(WinShellApplication application, WinShellMenu parent, string text, string tooltip, string icon, string className, int level, string guid) { Application = application; Parent = parent; Text = text; Tooltip = tooltip; Icon = icon; ClassName = className; Level = level; Guid = guid; Children = new List<WinShellMenu>(); }
public void AddMenu(WinShellMenu menu) { Menus.Add(menu); }
/// <summary> /// 将扩展的Menu对应的XML节点解析成WinShellMenu集合。 /// </summary> /// <param name="menus">顶层WinShellMenu集合。</param> /// <param name="application">所属的WinShellApplication。</param> /// <param name="parent">父菜单。</param> /// <param name="topNode">顶层XML节点。</param> /// <param name="nodeLevel">XML节点层次。</param> private void CreateWinShellMenusFromXmlNode(List<WinShellMenu> menus, WinShellApplication application, WinShellMenu parent, XmlNode topNode, int nodeLevel) { if (menus == null) { menus = new List<WinShellMenu>(); } foreach (XmlNode childNode in topNode.ChildNodes) { if (childNode.NodeType == XmlNodeType.Element) { string type = null; if (childNode.Attributes["Class"] != null) type = childNode.Attributes["Class"].Value; string text = childNode.Attributes["Text"] == null ? string.Empty : childNode.Attributes["Text"].Value; string toolTip = childNode.Attributes["ToolTip"] == null ? string.Empty : childNode.Attributes["ToolTip"].Value; string icon = childNode.Attributes["Icon"] == null ? string.Empty : childNode.Attributes["Icon"].Value; string guid = Guid.NewGuid().ToString(); // 创建WinShellMenu对象。 WinShellMenu winShellMenu = new WinShellMenu(application, parent, text, toolTip, icon, type, nodeLevel, guid); menus.Add(winShellMenu); // 递归创建子节点对象。 int childNodeLevel = nodeLevel + 1; CreateWinShellMenusFromXmlNode(winShellMenu.Children, application, winShellMenu, childNode, childNodeLevel); } } }
public void AddMenu(WinShellMenu menu) { Menus.Add(menu); }