Exemple #1
0
        public static ToolStripDropDown AddNestedItem(this ToolStripDropDown dropDown, string text)
        {
            AudioToolStripMenuItem item = new AudioToolStripMenuItem();

            item.Text = text;
            dropDown.Items.Add(item);

            return(item.DropDown);
        }
        protected override void OnItemClicked(ToolStripItemClickedEventArgs e)
        {
            AudioToolStripMenuItem item = e.ClickedItem as AudioToolStripMenuItem;

            if (item != null && !item.AutoCloseOnClick)
            {
                _cancelNextAttemptedClose = true;
            }

            base.OnItemClicked(e);
        }
Exemple #3
0
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            AudioToolStripMenuItem menuItem = e.Item as AudioToolStripMenuItem;

            if (menuItem != null && menuItem.CheckedImage != null)
            {
                Image image = menuItem.CheckedImage;

                base.OnRenderItemCheck(new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, image, new Rectangle(e.ImageRectangle.X, e.ImageRectangle.Y, image.Width, image.Height)));
                return;
            }

            if (EnsureRenderer())
            {
                Rectangle bgRect = GetBackgroundRectangle(e.Item);
                //Rectangle bgRect = e.ImageRectangle;
                bgRect.Width = bgRect.Height;

                // Now, mirror its position if the menu item is RTL.
                if (e.Item.RightToLeft == RightToLeft.Yes)
                {
                    bgRect = new Rectangle(e.ToolStrip.ClientSize.Width - bgRect.X - bgRect.Width, bgRect.Y, bgRect.Width, bgRect.Height);
                }

                bool isRendereringImageCheck = IsRenderingImageCheck(e.Item);

                renderer.SetParameters(MenuClass, (int)MenuParts.PopupCheckBackground, e.Item.Enabled ? (isRendereringImageCheck ? (int)MenuPopupCheckBackgroundStates.Bitmap : (int)MenuPopupCheckBackgroundStates.Normal) : (int)MenuPopupCheckBackgroundStates.Disabled);
                renderer.DrawBackground(e.Graphics, bgRect);

                if (!isRendereringImageCheck)
                {
                    Rectangle checkRect = e.ImageRectangle;
                    checkRect.X = bgRect.X + bgRect.Width / 2 - checkRect.Width / 2;
                    checkRect.Y = bgRect.Y + bgRect.Height / 2 - checkRect.Height / 2;


                    ToolStripMenuItem item = e.Item as ToolStripMenuItem;
                    if (item != null && item.CheckState == CheckState.Indeterminate)
                    {
                        renderer.SetParameters(MenuClass, (int)MenuParts.PopupCheck, e.Item.Enabled ? (int)MenuPopupCheckStates.BulletNormal : (int)MenuPopupCheckStates.BulletDisabled);
                    }
                    else
                    {
                        renderer.SetParameters(MenuClass, (int)MenuParts.PopupCheck, e.Item.Enabled ? (int)MenuPopupCheckStates.CheckmarkNormal : (int)MenuPopupCheckStates.CheckmarkDisabled);
                    }

                    renderer.DrawBackground(e.Graphics, checkRect);
                }
            }
            else
            {
                base.OnRenderItemCheck(e);
            }
        }
Exemple #4
0
        public static ToolStripMenuItem AddCommand(this ToolStripDropDown dropDown, Command command)
        {
            AudioToolStripMenuItem item = new AudioToolStripMenuItem();

            item.Tag          = command;
            item.ImageScaling = ToolStripItemImageScaling.None;
            dropDown.Items.Add(item);

            // Should be kept alive by the strip and command hookups.
            new CommandBinding(dropDown, item, command);

            return(item);
        }
        protected override ToolStripItem CreateDefaultItem(string text, Image image, EventHandler onClick)
        {
            if (text == "-")
            {
                return(new ToolStripSeparator());
            }

            AudioToolStripMenuItem item = new AudioToolStripMenuItem();

            item.Text   = text;
            item.Image  = image;
            item.Click += onClick;

            return(item);
        }
Exemple #6
0
        private void SyncProperty(ICommand command, string propertyName)
        {
            switch (propertyName)
            {
            case CommandProperty.IsVisible:
                _item.Visible = command.IsVisible;
                break;

            case CommandProperty.IsEnabled:
                _item.Enabled = command.IsEnabled;
                break;

            case CommandProperty.IsChecked:
                if (_menuItem != null)
                {
                    _menuItem.Checked = command.IsChecked;
                }
                break;

            case CommandProperty.Text:
                _item.Text = command.Text;
                break;

            case CommandProperty.TooltipText:
                _item.ToolTipText = command.TooltipText;
                break;

            case CommandProperty.IsInvokable:
                AudioToolStripMenuItem item = _item as AudioToolStripMenuItem;
                if (item != null)
                {
                    item.AutoCloseOnClick = command.IsInvokable;
                }
                break;

            case CommandProperty.Image:
            default:
                Debug.Assert(propertyName == CommandProperty.Image);
                _item.Image = command.Image;
                break;
            }
        }
        protected override ToolStripItem CreateDefaultItem(string text, Image image, EventHandler onClick)
        {
            if (text == "-")
                return new ToolStripSeparator();

            AudioToolStripMenuItem item = new AudioToolStripMenuItem();
            item.Text = text;
            item.Image = image;
            item.Click += onClick;

            return item;
        }