예제 #1
0
        /// <summary>
        /// Setup constructor
        /// </summary>
        /// <param name="item">Tool strip item that this object is bound to</param>
        /// <param name="itemInfo">Item information</param>
        public MenuItem( ToolStripMenuItem item, MenuItemInfo itemInfo )
        {
            Arguments.CheckNotNull( item, "item" );
            Arguments.CheckNotNull( itemInfo, "itemInfo" );

            item.Name = itemInfo.Name;
            item.Text = itemInfo.Text;
            item.Tag = this;
            m_Item = item;
            m_Ordinal = itemInfo.Ordinal;
            m_Command = itemInfo.Command;
        }
예제 #2
0
 /// <summary>
 /// Finds or adds a new menu item matching the specified information
 /// </summary>
 public IMenuItem AddItem( MenuItemInfo itemInfo )
 {
     ToolStripItem item = m_Item.DropDownItems[ itemInfo.Name ];
     if ( item != null )
     {
         return ( IMenuItem )item.Tag;
     }
     ToolStripMenuItem menuItem = new ToolStripMenuItem( );
     InsertMenuItem( itemInfo.Ordinal, menuItem );
     if ( itemInfo.Command != null )
     {
         menuItem.Click += OnMenuItemClicked;
     }
     return new MenuItem( menuItem, itemInfo );
 }
예제 #3
0
 /// <summary>
 /// Finds or adds a new menu item matching the specified information
 /// </summary>
 public IMenuItem this[MenuItemInfo itemInfo]
 {
     get { return AddItem( itemInfo ); }
 }