Beispiel #1
0
 public virtual void AddRange( MenuItemEx[] items )
 {
   for( int i=0; i<items.Length; i++ )
   {
     Add( items[i] );
   }
 }
Beispiel #2
0
        private void OnCollectionChange(object parent, System.EventArgs e)
        {
            base.MenuItems.Clear();

            for (int i = 0; i < m_items.Count; i++)
            {
                MenuItemEx item = m_items[i];

                if (item.ImageList == null)
                {
                    item.ImageList = m_imgList;
                }

                base.MenuItems.Add(item);
            }
        }
Beispiel #3
0
    public ContextMenuEx( ImageList img, MenuItemEx[] items ) : this()
    {
      int iCount = 0;

      for( int i=0; i<items.Length; i++ )
      {
        MenuItemEx item = items[i];
        item.ImageList = img;

        if( item.Text.Length > 1 && item.Text != "-" )
        {
          item.ImageIndex = iCount;
          iCount++;
        }
      }

      base.MenuItems.AddRange( ( MenuItem[] )items );
    }
Beispiel #4
0
        public ContextMenuEx(ImageList img, MenuItemEx[] items) : this()
        {
            int iCount = 0;

            for (int i = 0; i < items.Length; i++)
            {
                MenuItemEx item = items[i];
                item.ImageList = img;

                if (item.Text.Length > 1 && item.Text != "-")
                {
                    item.ImageIndex = iCount;
                    iCount++;
                }
            }

            base.MenuItems.AddRange(( MenuItem[] )items);
        }
Beispiel #5
0
        static public MenuItemEx CloneMenu(MenuItemEx currentItem)
        {
            MenuItemEx clonedItem = new MenuItemEx(currentItem.Text,
                                                   ( Bitmap )currentItem.Icon,
                                                   ( Shortcut )currentItem.Shortcut,
                                                   currentItem.ClickHandler);

            // Preserve the enable and check state
            clonedItem.Enabled    = currentItem.Enabled;
            clonedItem.Checked    = currentItem.Checked;
            clonedItem.RadioCheck = currentItem.RadioCheck;

            foreach (MenuItemEx item in currentItem.MenuItems)
            {
                clonedItem.MenuItems.Add(CloneMenu(item));
            }

            return(clonedItem);
        }
Beispiel #6
0
 public void Insert( int index, MenuItemEx item )
 {
   List.Insert( index, item );
 }
Beispiel #7
0
 public void Remove( MenuItemEx item )
 {
   List.Remove( item );
 }
Beispiel #8
0
 public int IndexOf( MenuItemEx item )
 {
   return InnerList.IndexOf( item );
 }
Beispiel #9
0
 public bool Contains( MenuItemEx item )
 {
   return InnerList.Contains( item );
 }
Beispiel #10
0
 public int Add( MenuItemEx item )
 {
   if (Contains(item)) return -1;
   int index = List.Add(item);
   return index;
 }
        public static MenuItemEx CloneMenu( MenuItemEx currentItem )
        {
            MenuItemEx clonedItem = new MenuItemEx( currentItem.Text,
            ( Bitmap )currentItem.Icon,
            ( Shortcut )currentItem.Shortcut,
            currentItem.ClickHandler );

              // Preserve the enable and check state
              clonedItem.Enabled = currentItem.Enabled;
              clonedItem.Checked = currentItem.Checked;
              clonedItem.RadioCheck = currentItem.RadioCheck;

              foreach ( MenuItemEx item in currentItem.MenuItems )
              {
            clonedItem.MenuItems.Add( CloneMenu( item ) );
              }

              return clonedItem;
        }
Beispiel #12
0
    void CreateContextMenu()
    {
      // context menu
      MenuItemEx largeIconsMenu = new MenuItemEx("Large Icons", new EventHandler(OnContextMenu));
      MenuItemEx smallIconsMenu = new MenuItemEx("Small Icons", new EventHandler(OnContextMenu));
      MenuItemEx separator1 = new MenuItemEx("-", new EventHandler(OnContextMenu));
      MenuItemEx renameGroup = new MenuItemEx("Rename Group", new EventHandler(OnContextMenu));
      MenuItemEx separator2 = new MenuItemEx("-", new EventHandler(OnContextMenu));
      MenuItemEx renameShortcut = new MenuItemEx("Rename Shortcut", new EventHandler(OnContextMenu));

      contextMenu = new ContextMenu();
      contextMenu.MenuItems.Add(0, largeIconsMenu);
      contextMenu.MenuItems.Add(1, smallIconsMenu);
      contextMenu.MenuItems.Add(2, separator1);
      contextMenu.MenuItems.Add(3, renameGroup);
      contextMenu.MenuItems.Add(4, separator2);
      contextMenu.MenuItems.Add(5, renameShortcut);

      contextMenu.Popup += new EventHandler(ContextMenuPopup);
      this.ContextMenu = contextMenu;
    }