Menu item.
Inheritance: Button
Example #1
0
        private void BuildSubmenu(SubmenuNode menu, MenuItem menuControl)
        {
            foreach (var menuChild in menu.ChildNodes)
            {
                var menuItem = menuChild as MenuItemNode;
                if(menuItem != null)
                {
                    menuControl.Menu.AddItem(menuItem.Label);
                    continue;
                }

                var submenu = menuChild as SubmenuNode;
                if (submenu != null)
                {
                    //menuControl.
                    //BuildSubmenu(submenu);
                    continue;
                }

                if (menuChild is MenuSeparatorNode)
                {
                     menuControl.Menu.AddDivider();
                    continue;
                }

                throw new NotImplementedException();
            }
        }
Example #2
0
 /// <summary>
 /// Add item handler.
 /// </summary>
 /// <param name="item">Item added.</param>
 protected override void OnAddItem(MenuItem item)
 {
     item.Dock = Pos.Left;
     item.TextPadding = new Padding(5, 0, 5, 0);
     item.Padding = new Padding(10, 0, 10, 0);
     item.SizeToContents();
     item.IsOnStrip = true;
     item.HoverEnter += OnHoverItem;
 }
Example #3
0
        /// <summary>
        /// Internal handler for item selected event.
        /// </summary>
        /// <param name="control">Event source.</param>
        protected virtual void OnItemSelected(Control control)
        {
            //Convert selected to a menu item
            MenuItem item = control as MenuItem;
            if (null == item) return;

            m_SelectedItem = item;
            Text = m_SelectedItem.Text;
            m_Menu.IsHidden = true;

            if (ItemSelected != null)
                ItemSelected.Invoke(this);

            Focus();
            Invalidate();
        }
Example #4
0
File: Menu.cs Project: tritao/flood
        /// <summary>
        /// Adds a new menu item.
        /// </summary>
        /// <param name="text">Item text.</param>
        /// <param name="iconName">Icon texture name.</param>
        /// <param name="accelerator">Accelerator for this item.</param>
        /// <returns>Newly created control.</returns>
        public virtual MenuItem AddItem(String text, String iconName, String accelerator = "")
        {
            MenuItem item = new MenuItem(this);
            item.Padding = Padding.Four;
            item.SetText(text);
            item.SetImage(iconName);
            item.SetAccelerator(accelerator);

            OnAddItem(item);

            return item;
        }
Example #5
0
File: Menu.cs Project: tritao/flood
        /// <summary>
        /// Add item handler.
        /// </summary>
        /// <param name="item">Item added.</param>
        protected virtual void OnAddItem(MenuItem item)
        {
            item.TextPadding = new Padding(IconMarginDisabled ? 0 : 24, 0, 16, 0);
            item.Dock = Pos.Top;
            item.SizeToContents();
            item.Alignment = Pos.CenterV | Pos.Left;
            item.HoverEnter += OnHoverItem;

            // Do this here - after Top Docking these values mean nothing in layout
            int w = item.Width + 10 + 32;
            if (w < Width) w = Width;
            SetSize(w, Height);
        }