public void AddMenuGroup(FrmMenuPage menuPage, FrmMenuGroup menuGroup) { RibbonControl mainMenu = application.MainRibbon; if (MainMenuPages[menuPage.PageName] == null) { return; } if (mainMenu != null) { if (menuPage.Tag is RibbonPage) { RibbonPage _rPage = menuPage.Tag as RibbonPage; RibbonPageGroup _menuGroup = new RibbonPageGroup(); _menuGroup.Name = menuGroup.GroupName; _menuGroup.Text = menuGroup.DisplayTitle; _rPage.Groups.Add(_menuGroup); menuGroup.Tag = _menuGroup; } else { MessageBox.Show(string.Format("菜单页{0}不存在!", menuPage.PageName)); } } }
public void RemoveMenuItem(FrmMenuPage menuPage, FrmMenuGroup menuGroup, FrmMenuItem menuItem) { RibbonControl mainMenu = application.MainRibbon; if (MainMenuPages[menuPage.PageName] == null) { return; } if (mainMenu != null) { if (menuGroup.Tag is RibbonPageGroup) { RibbonPageGroup _mGroup = menuGroup.Tag as RibbonPageGroup; { foreach (BarItemLink _mi in _mGroup.ItemLinks) { if (_mi.Caption == menuItem.MenuTitle) { _mGroup.ItemLinks.Remove(_mi); break; } } } } else { MessageBox.Show(string.Format("菜单页{0}不存在!", menuPage.PageName)); } } }
public void RemoveMenuGroup(FrmMenuPage menuPage, FrmMenuGroup menuGroup) { RibbonControl mainMenu = application.MainRibbon; if (MainMenuPages[menuPage.PageName] == null) { return; } if (mainMenu != null) { if (menuPage.Tag is RibbonPage) { RibbonPage _rPage = menuPage.Tag as RibbonPage; RibbonPageGroup _mGroup = null; foreach (RibbonPageGroup _rg in _rPage.Groups) { if (_rg.Name == menuGroup.GroupName) { _mGroup = _rg; break; } } if (_mGroup != null) { _rPage.Groups.Remove(_mGroup); } } else { MessageBox.Show(string.Format("菜单页{0}不存在!", menuPage.PageName)); } } }
public void AddMenuItem(FrmMenuGroup menuGroup, FrmMenuItem menuItem) { RibbonControl mainMenu = application.MainRibbon; if (mainMenu != null) { if (menuGroup.Tag is RibbonPageGroup) { RibbonPageGroup _mGroup = menuGroup.Tag as RibbonPageGroup; BarItem _menuitem = new BarButtonItem(); _menuitem.Caption = menuItem.MenuTitle; _menuitem.Tag = menuItem; _menuitem.LargeGlyph = menuItem.MenuIcon; _menuitem.Glyph = menuItem.MenuIcon; _menuitem.ItemClick += new ItemClickEventHandler(_menuitem_ItemClick); _menuitem.LargeWidth = (PicWidth == -1) ? menuItem.MenuPicWidth : PicWidth; _mGroup.ItemLinks.Add(_menuitem); } else { MessageBox.Show(string.Format("菜单组{0}不存在!", menuGroup.GroupName)); } } }