Ejemplo n.º 1
0
        public static ColorStripMenuItem CreateCustomMenuItem(string text, System.Drawing.Color color, EventHandler handler)
        {
            ColorStripMenuItem item = new ColorStripMenuItem(color, text, handler);

            item.ShowColorDialog = true;
            return(item);
        }
Ejemplo n.º 2
0
        private void HandleMenuEvent(object sender, EventArgs args)
        {
            ColorStripMenuItem item = (ColorStripMenuItem)sender;

            this.CenterColor = item.Color;
            this.Invalidate();
            if (ValueChanged != null)
            {
                ValueChanged(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 3
0
        protected override void OnClick(EventArgs e)
        {
            if (this.ContextMenuStrip == null)
            {
                ContextMenuStrip menu    = new ContextMenuStrip();
                EventHandler     handler = new EventHandler(this.HandleMenuEvent);
                menu.Items.Add(new ColorStripMenuItem(Color.Transparent, "Transparent", handler));
                ColorStripMenuItem[] items = ColorStripMenuItem.CreateStandardItems(handler);
                foreach (ColorStripMenuItem item in items)
                {
                    menu.Items.AddRange(items);
                }
                menu.Items.Add(ColorStripMenuItem.CreateCustomMenuItem("Custom...", this.CenterColor, handler));
                this.ContextMenuStrip = menu;
            }
            this.ContextMenuStrip.Show(this, 0, this.Height);

            base.OnClick(e);
        }