/// <summary> /// Метод осуществляет добавление секции (подменю) в конец списка /// элементов. /// </summary> /// <param name="sTitle">Заголовок секции (подменю).</param> /// <returns> /// Созданная секция. /// </returns> public XMenuSection AddSection(string sTitle) { XMenuSection item = new XMenuSection(null, sTitle); Add(item); return(item); }
/// <summary> /// Метод возвращает копию элемента. /// </summary> public override XMenuItemBase Clone() { XMenuSection menu_sec = new XMenuSection(Name, Caption); foreach (XMenuItemBase item in Items) { menu_sec.Items.Add(item.Clone()); } return(menu_sec); }
protected void buildMenuItems(XMenuSectionBase menu, XmlElement xmlMenu) { XmlNamespaceManager nsMan = m_mdManager.NamespaceManager; XmlNode node; string sCaption; string sValue; XMenuActionItem actionItem; foreach (XmlElement xmlMenuItem in xmlMenu.SelectNodes("i:menu-item-info | i:menu-item-separ | i:menu-item | i:menu-section", nsMan)) { switch (xmlMenuItem.LocalName) { case "menu-item-info": node = xmlMenuItem.SelectSingleNode("i:caption/text() | @t", nsMan); sCaption = node != null ? node.InnerText : String.Empty; node = xmlMenuItem.SelectSingleNode("i:value", nsMan); sValue = node != null ? node.InnerText : String.Empty; menu.Items.AddInfoItem(sCaption, sValue); break; case "menu-item-separ": menu.Items.AddSeparatorItem(); break; case "menu-item": node = xmlMenuItem.SelectSingleNode("i:caption/text() | @t", nsMan); sCaption = node != null ? node.InnerText : String.Empty; actionItem = menu.Items.AddActionItem(sCaption, xmlMenuItem.GetAttribute("action")); actionItem.SeparatorBefore = xmlMenuItem.HasAttribute("separator-before"); actionItem.SeparatorAfter = xmlMenuItem.HasAttribute("separator-after"); actionItem.Hint = xmlMenuItem.GetAttribute("hint"); actionItem.Hotkey = xmlMenuItem.GetAttribute("hotkey"); actionItem.Hidden = xmlMenuItem.HasAttribute("hidden"); actionItem.Disabled = xmlMenuItem.HasAttribute("disabled"); actionItem.Default = xmlMenuItem.HasAttribute("default"); actionItem.MayBeDefault = xmlMenuItem.HasAttribute("may-be-default"); foreach (XmlElement xmlParam in xmlMenuItem.SelectNodes("i:params/i:param", nsMan)) { actionItem.Parameters.Add(xmlParam.GetAttribute("n"), xmlParam.InnerText); } break; case "menu-section": node = xmlMenuItem.SelectSingleNode("i:caption/text() | @t", nsMan); sCaption = node != null ? node.InnerText : String.Empty; XMenuSection menu_sec = menu.Items.AddSection(sCaption); buildMenuItems(menu_sec, xmlMenuItem); break; } } }