Пример #1
0
        private void InsertItem(IMenuItem iMenuItem, int index)
        {
            var    menuItem = iMenuItem as MenuItem;
            Widget widget;

            if (menuItem != null)
            {
                menuItem.Changed += MenuItemOnChanged;
                var menuItemButton = new MenuItemButton(this, MenuItemStyle)
                {
                    Text = menuItem.Text,
                    Tag  = menuItem
                };

                if (menuItem.Color.HasValue)
                {
                    menuItemButton.TextColor = menuItem.Color.Value;
                }

                menuItemButton.MouseEntered += MouseOnEntered;
                menuItemButton.MouseLeft    += MouseOnLeft;
                menuItemButton.SubMenu.Items = menuItem.Items;
                menuItemButton.Toggleable    = menuItem.Items.Count > 0;

                if (menuItemButton.Toggleable)
                {
                    menuItemButton.PressedChanged += ButtonOnPressedChanged;
                }
                else
                {
                    menuItemButton.Click += ButtonOnClick;
                }

                widget = menuItemButton;
            }
            else
            {
                if (Orientation == Orientation.Horizontal)
                {
                    widget = new VerticalSeparator(SeparatorStyle);
                }
                else
                {
                    widget = new HorizontalSeparator(SeparatorStyle);
                }
            }

            iMenuItem.Menu   = this;
            iMenuItem.Widget = widget;

            AddItem(widget, index);
            UpdateGridPositions();
        }
Пример #2
0
        private void ShowSubMenu(MenuItemButton menuItem)
        {
            if (OpenMenuItem != null)
            {
                OpenMenuItem.IsPressed = false;
            }

            if (menuItem == null || !menuItem.CanOpen)
            {
                return;
            }

            Desktop.ShowContextMenu(menuItem.SubMenu, new Point(menuItem.Bounds.X, Bounds.Bottom));
            Desktop.ContextMenuClosed += DesktopOnContextMenuClosed;

            OpenMenuItem = menuItem;
        }
Пример #3
0
        private void Click(MenuItemButton menuItemButton)
        {
            if (Desktop == null)
            {
                return;
            }

            var menuItem = (MenuItem)menuItemButton.Tag;

            if (!menuItemButton.CanOpen)
            {
                Close();
                menuItem.FireSelected();
            }
            else
            {
                menuItemButton.IsPressed = true;
            }
        }
Пример #4
0
        private void InsertItem(IMenuItem iMenuItem, int index)
        {
            var    menuItem = iMenuItem as MenuItem;
            Widget widget;

            if (menuItem != null)
            {
                menuItem.Changed += MenuItemOnChanged;
                var menuItemButton = new MenuItemButton(MenuItemStyle)
                {
                    Text = menuItem.Text,
                    Tag  = menuItem
                };

                if (menuItem.Color.HasValue)
                {
                    menuItemButton.TextColor = menuItem.Color.Value;
                }

                menuItemButton.Down         += ButtonOnDown;
                menuItemButton.Up           += ButtonOnUp;
                menuItemButton.MouseEntered += MouseOnEntered;
                menuItemButton.MouseLeft    += MouseOnLeft;
                menuItemButton.SubMenu.Items = menuItem.Items;
                menuItemButton.Toggleable    = menuItem.Items.Count > 0;

                widget = menuItemButton;
            }
            else
            {
                widget = new MenuSeparatorWidget(Orientation, SeparatorStyle);
            }

            iMenuItem.Menu   = this;
            iMenuItem.Widget = widget;

            AddItem(widget, index);
            UpdateGridPositions();
        }