示例#1
0
        private void PostAddItem(string helpText, ContextCommand contextCommand, CustomMenuHandler customMenuHandler)
        {
            menuHost.OnAddMenuItem(helpText, contextCommand, customMenuHandler);

            indexMenu++;
            menuHost.IncrementCommandId();
        }
示例#2
0
            public MenuItem(string helpText, Menu.ContextCommand contextcommand, CustomMenuHandler custommenuhandler)
            {
                Contract.Requires(helpText != null);

                this.helpText     = helpText;
                Command           = contextcommand;
                CustomMenuHandler = custommenuhandler;
            }
示例#3
0
文件: Menu.cs 项目: hafsjold/snvrepos
        /// <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);
        }
示例#4
0
        /// <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));
        }
示例#5
0
        /// <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);
        }
示例#6
0
        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);
        }
示例#7
0
 void IMenuHost.OnAddMenuItem(string helpText, Menu.ContextCommand contextCommand, CustomMenuHandler customMenuHandler)
 {
     menuItems.Add(new MenuItem(helpText, contextCommand, customMenuHandler));
 }
示例#8
0
 public void OnAddMenuItem(string helpText, Menu.ContextCommand contextCommand, CustomMenuHandler customMenuHandler)
 {
     Contract.Requires(helpText != null);
 }