private void PostAddItem(string helpText, ContextCommand contextCommand, CustomMenuHandler customMenuHandler) { menuHost.OnAddMenuItem(helpText, contextCommand, customMenuHandler); indexMenu++; menuHost.IncrementCommandId(); }
public MenuItem(string helpText, Menu.ContextCommand contextcommand, CustomMenuHandler custommenuhandler) { Contract.Requires(helpText != null); this.helpText = helpText; Command = contextcommand; CustomMenuHandler = custommenuhandler; }
/// <summary> /// Adds the item. /// </summary> /// <param name="customMenuHandler">The custom menu handler.</param> /// <param name="helpText">The help.</param> /// <param name="contextCommand">The context command.</param> public void AddItem(CustomMenuHandler customMenuHandler, string helpText, ContextCommand contextCommand) { Contract.Requires(customMenuHandler != null); Contract.Requires(helpText != null); Contract.Requires(contextCommand != null); var menuItemInfo = new MenuItemInfo(); menuItemInfo.InitializeSize(); menuItemInfo.Id = menuHost.GetCommandId(); customMenuHandler.InitializeItemInfo(ref menuItemInfo); InsertMenuItem(ref menuItemInfo, helpText, contextCommand, customMenuHandler); }
/// <summary> /// Adds the sub menu. /// </summary> /// <returns></returns> public Menu AddSubMenu(string helpText, CustomMenuHandler customMenuHandler) { ////Contract.Requires(helpText != null); ////Contract.Requires(customMenuHandler != null); IntPtr subMenu = CreateSubMenu(); var menuItemInfo = new MenuItemInfo(); menuItemInfo.InitializeSize(); menuItemInfo.Id = menuHost.GetCommandId(); menuItemInfo.SubMenu = subMenu; customMenuHandler.InitializeItemInfo(ref menuItemInfo); InsertMenuItem(ref menuItemInfo, helpText, null, customMenuHandler); return(new Menu(subMenu, indexMenu, idCmdLast, menuHost)); }
/// <summary> /// Adds the item. /// </summary> /// <param name="customMenuHandler">The custom menu handler.</param> /// <param name="helpText">The help.</param> /// <param name="contextCommand">The context command.</param> public void AddItem(CustomMenuHandler customMenuHandler, string helpText, ContextCommand contextCommand) { if (customMenuHandler == null) { throw new ArgumentNullException(nameof(customMenuHandler)); } ////Contract.Requires(helpText != null); ////Contract.Requires(contextCommand != null); var menuItemInfo = new MenuItemInfo(); menuItemInfo.InitializeSize(); menuItemInfo.Id = menuHost.GetCommandId(); customMenuHandler.InitializeItemInfo(ref menuItemInfo); InsertMenuItem(ref menuItemInfo, helpText, contextCommand, customMenuHandler); }
private void InsertMenuItem(ref MenuItemInfo menuItemInfo, string helpText, ContextCommand contextCommand, CustomMenuHandler customMenuHandler) { CheckIdSpace(); bool result = SafeNativeMethods.InsertMenuItem(hmenu, indexMenu, true, ref menuItemInfo); if (!result) { throw new Win32Exception(); } PostAddItem(helpText, contextCommand, customMenuHandler); }
void IMenuHost.OnAddMenuItem(string helpText, Menu.ContextCommand contextCommand, CustomMenuHandler customMenuHandler) { menuItems.Add(new MenuItem(helpText, contextCommand, customMenuHandler)); }
public void OnAddMenuItem(string helpText, Menu.ContextCommand contextCommand, CustomMenuHandler customMenuHandler) { Contract.Requires(helpText != null); }