/// <summary> /// 设置显示的菜单项 /// </summary> public void Setup(IList <MenuItemGroup> groups) { var userPanelGroup = new MenuItemGroup("User Panel", "fa fa-home"); userPanelGroup.Items.AddItemForLink(new T("Index"), "fa fa-home", "/home"); groups.Insert(0, userPanelGroup); }
public void MenuItemGroupRemove() { tlog.Debug(tag, $"MenuItemGroupRemove START"); var testingTarget = new MenuItemGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <MenuItemGroup>(testingTarget, "Should return MenuItemGroup instance."); MenuItem item = new MenuItem() { BackgroundColor = Color.Cyan, }; testingTarget.Add(item); try { testingTarget.Remove(item); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } tlog.Debug(tag, $"MenuItemGroupRemove END (OK)"); }
protected override void registerMenus() { MenuItem topMenu = MenuManager.Instance.TopMenu[TOPMENUGROUP_ID][TOPMENU_LABEL]; MenuItemGroup menuGroup = topMenu[MENUGROUP_ID]; menuGroup.Weight = MENUGROUP_WEIGHT; menuGroup[SUBMENU_LABEL].ClickHandler = (menu, tag) => new VtrList().ShowAsChild(); }
protected override void registerMenus() { MenuItem topMenu = MenuManager.Instance.TopMenu[TOPMENUGROUP_ID][TOPMENU_LABEL]; MenuItemGroup menuGroup = topMenu[MENUGROUP_ID]; menuGroup.Weight = MENUGROUP_WEIGHT; menuGroup[SUBMENU_ROUTERS_LABEL].ClickHandler = (menu, tag) => new RouterList().ShowAsChild(); menuGroup[SUBMENU_ALLCROSSPOINTS_LABEL].ClickHandler = (menu, tag) => new RouterControlTableForm(RouterDatabase.Instance).ShowAsChild(); }
protected override void registerMenus() { MenuItem topMenu = MenuManager.Instance.TopMenu[TOPMENUGROUP_ID][TOPMENU_LABEL]; MenuItemGroup menuGroup = topMenu[MENUGROUP_ID]; menuGroup.Weight = MENUGROUP_WEIGHT; menuGroup[SUBMENU_SIGNALLIST_LABEL].ClickHandler = (menu, tag) => new SignalList().ShowAsChild(); menuGroup[SUBMENU_EXTERNALSIGNALLIST_LABEL].ClickHandler = (menu, tag) => new ExternalSignalList().ShowAsChild(); menuGroup[SUBMENU_EXTERNALSIGNALCATEGORYLIST_LABEL].ClickHandler = (menu, tag) => new ExternalSignalCategoryList().ShowAsChild(); }
private void addChild(MenuItem associatedMenuItem) { Func <System.Windows.Forms.ToolStripItem, bool> lastBeforeLookupFunction = (toolStripItem) => { CustomToolStripMenuItem toolStripItemCasted = toolStripItem as CustomToolStripMenuItem; if (toolStripItemCasted == null) { return(false); } MenuItem menuItem = toolStripItemCasted.AssociatedMenuItem; return((menuItem.ParentGroup.Weight <= associatedMenuItem.ParentGroup.Weight) && (menuItem.Weight <= associatedMenuItem.Weight)); }; // Separator before System.Windows.Forms.ToolStripItem lastBefore = guiElement.DropDownItems.Cast <System.Windows.Forms.ToolStripItem>().Where(lastBeforeLookupFunction).LastOrDefault(); int position = guiElement.StartPosition; if (lastBefore != null) { position = guiElement.DropDownItems.IndexOf(lastBefore) + 1; if (!(lastBefore is System.Windows.Forms.ToolStripSeparator)) { CustomToolStripMenuItem lastBeforeCasted = lastBefore as CustomToolStripMenuItem; MenuItemGroup groupBefore = lastBeforeCasted?.AssociatedMenuItem.ParentGroup; if ((groupBefore != associatedMenuItem.ParentGroup) && (groupBefore != null)) { guiElement.DropDownItems.Insert(position++, new System.Windows.Forms.ToolStripSeparator()); } } } // Menu item System.Windows.Forms.ToolStripItem myChild = new CustomToolStripMenuItem(associatedMenuItem); guiElement.DropDownItems.Insert(position++, myChild); // Separator after if (guiElement.DropDownItems.Count > position) { System.Windows.Forms.ToolStripItem firstAfter = guiElement.DropDownItems[position]; if (firstAfter != null) { CustomToolStripMenuItem firstAfterCasted = firstAfter as CustomToolStripMenuItem; MenuItemGroup groupAfter = firstAfterCasted?.AssociatedMenuItem.ParentGroup; // Add if next is another group if (!(firstAfter is System.Windows.Forms.ToolStripSeparator) && (groupAfter != associatedMenuItem.ParentGroup) && (groupAfter != null)) { guiElement.DropDownItems.Insert(position++, new System.Windows.Forms.ToolStripSeparator()); } // Remove is next is same group if ((firstAfter is System.Windows.Forms.ToolStripSeparator) && (groupAfter == associatedMenuItem.ParentGroup) && (groupAfter != null)) { guiElement.DropDownItems.Remove(firstAfter); } } } }
public RootPageMaster() { InitializeComponent(); BindingContext = this; ItemsListView = MenuItemsListView; MenuItems = new ObservableCollection <MenuItemGroup>(); var mainGroup = new MenuItemGroup { new MenuItem { Id = 0, Title = "Home", IconSrc = "home_icon.png", Type = MenuItem.ItemType.Normal, TargetType = typeof(HomePage) }, new MenuItem { Id = 1, Title = "Explore", IconSrc = "explore_icon.png", Type = MenuItem.ItemType.Normal, TargetType = typeof(ExplorePage) }, new MenuItem { Id = 2, Title = "Notifications", IconSrc = "bell_icon.png", Type = MenuItem.ItemType.Normal, TargetType = typeof(NotificationsPage) }, new MenuItem { Id = 3, Title = "My Showroom", IconSrc = "showroom_icon.png", Type = MenuItem.ItemType.Normal }, new MenuItem { Id = 4, Title = "Subscriptions", IconSrc = "subscriptions_icon.png", Type = MenuItem.ItemType.Normal }, new MenuItem { Id = 5, Title = "Challenges", IconSrc = "trophy_icon.png", Type = MenuItem.ItemType.Normal }, new MenuItem { Id = 6, Title = "Settings", IconSrc = "cog_icon.png", Type = MenuItem.ItemType.Normal }, }; var othersGroup = new MenuItemGroup { new MenuItem { Id = 0, Title = "Help & Feedback", IconSrc = "", Type = MenuItem.ItemType.Other }, new MenuItem { Id = 1, Title = "About SHOWMiE", IconSrc = "", Type = MenuItem.ItemType.Other } }; MenuItems.Add(mainGroup); MenuItems.Add(othersGroup); MenuItemsListView.ItemsSource = MenuItems; MenuItemsListView.SelectedItem = MenuItems[0][0]; }
public void MenuItemGroupAdd() { tlog.Debug(tag, $"MenuItemGroupAdd START"); var testingTarget = new MenuItemGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <MenuItemGroup>(testingTarget, "Should return MenuItemGroup instance."); try { MenuItem item = null; testingTarget.Add(item); } catch (ArgumentNullException) { tlog.Debug(tag, $"MenuItemGroupAdd END (OK)"); Assert.Pass("Caught ArgumentNullException : Passed!"); } }
public override void Load() { base.Load(); RegisterRoutes(RouteTable.Routes); MenuItem[] items = new MenuItem[] { new MenuItem { Title = "Contacts", Url = () => RouteTable.Routes.GetRouteUrl("cms.contactmanagement.contact.list", null), RouteNamePrefix = "cms.contactmanagement.contact" } }; MenuItemGroup group = new MenuItemGroup { Title = "Contact management" }; group.MenuItems.AddRange(items); IMenuManager manager = Locator.Get <IMenuManager>(); manager.MenuItemGroups.Add(group); }
/// <summary> /// 设置显示的菜单项 /// </summary> /// <param name="groups">菜单项分组列表</param> /// <param name="page">菜单页</param> public static void SetupFrom(this IList <MenuItemGroup> groups, IMenuPage page) { // 没有权限时不显示菜单项 var sessionManager = Application.Ioc.Resolve <SessionManager>(); var privilegeManager = Application.Ioc.Resolve <PrivilegeManager>(); var user = sessionManager.GetSession().GetUser(); if (user == null || !privilegeManager.HasUserType(user, page.RequiredUserType) || !privilegeManager.HasPrivileges(user, page.RequiredPrivileges)) { return; } // 添加菜单项 var group = groups.FirstOrDefault(g => g.Name == page.Group); if (group == null) { group = new MenuItemGroup(page.Group, page.GroupIconClass); groups.Add(group); } group.Items.AddItemForLink(new T(page.Name), page.IconClass, page.Url); }
private void itemRemovedFromGroupHandler(MenuItemGroup group, MenuItem item, string id) => removeChild(item);
private void itemAddedToGroupHandler(MenuItemGroup group, MenuItem item, string id) => addChild(item);
private void groupRemovedHandler(MenuItem menu, MenuItemGroup group, string id) { group.ItemAdded -= itemAddedToGroupHandler; group.ItemRemoved -= itemRemovedFromGroupHandler; }
public CommandInMenuAttribute(string title, MenuItemGroup group) => throw null;
public LocalizableCommandInMenuAttribute(Type resourceManagerProvider, string titleResource, MenuItemGroup group) : base(string.Empty, MenuItemGroup.DatabaseGroup1) => throw null;