Ejemplo n.º 1
0
    protected void HandleButtonPopupMenu(object sender, ButtonPressEventArgs e)
    {
        if (e.Event.Button == 3)
        {         // right mouse button
            ColorButton cb = (ColorButton)sender;

            Menu     m            = new Menu();
            MenuItem hexPopupItem = new MenuItem("Copy He_x");
            MenuItem hslPopupItem = new MenuItem("Copy HS_L");
            MenuItem hsvPopupItem = new MenuItem("Copy HS_V");
            MenuItem addPopupItem = new MenuItem("_Add");
            hexPopupItem.Activated += (o, a) =>
            {
                clipboard.Text = cb.Color.ToRgbColor().ToHtml();
            };
            hslPopupItem.Activated += (o, a) =>
            {
                clipboard.Text = cb.Color.ToRgbColor().ToHslString();
            };
            hsvPopupItem.Activated += (o, a) =>
            {
                clipboard.Text = cb.Color.ToHsvColor().ToString();
            };
            addPopupItem.Activated += (o, a) =>
            {
                appPal.AppendColor(cb.Color.ToRgbColor());
            };
            m.Add(hexPopupItem);
            m.Add(hslPopupItem);
            m.Add(hsvPopupItem);
            m.Add(addPopupItem);
            m.ShowAll();
            m.Popup();
        }
    }
Ejemplo n.º 2
0
        private void addSubmenuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var cb = (ColorButton)colorContextMenu.SourceControl;

            appPal.AppendColor(new PaletteColor(cb.Color));
        }