Esempio n. 1
0
    private void rgb_value_changed(object o)
    {
        Color color = Color.FromArgb(alpha.value, red.value, green.value, blue.value);
        hsv   hsv   = hsv.rgb_2_hsv(color);

        wheel.hsv = hsv;

        hue.value        = (int)(360.0 * hsv.hue);
        saturation.value = (int)(100.0 * hsv.saturation);
        value.value      = (int)(100.0 * hsv.value);

        saturation.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, 0, value.value), hsv.hsv_2_rgb(hue.value, 100, value.value), });
        value.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, saturation.value, 0), hsv.hsv_2_rgb(hue.value, saturation.value, 100), });

        if (red != o)
        {
            red.update_gradient(new Color[] { Color.FromArgb(0, green.value, blue.value), Color.FromArgb(255, green.value, blue.value), });
        }
        if (green != o)
        {
            green.update_gradient(new Color[] { Color.FromArgb(red.value, 0, blue.value), Color.FromArgb(red.value, 255, blue.value), });
        }
        if (blue != o)
        {
            blue.update_gradient(new Color[] { Color.FromArgb(red.value, green.value, 0), Color.FromArgb(red.value, green.value, 255), });
        }

        alpha.update_gradient(new Color[] { Color.FromArgb(0, red.value, green.value, blue.value), Color.FromArgb(255, red.value, green.value, blue.value), });

        indicator.color_current = color;

        update_caption();
    }
Esempio n. 2
0
    private void update_parameters(hsv hsv, Color color)
    {
        hue.value        = (int)(360.0 * hsv.hue);
        saturation.value = (int)(100.0 * hsv.saturation);
        value.value      = (int)(100.0 * hsv.value);

        saturation.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, 0, value.value), hsv.hsv_2_rgb(hue.value, 100, value.value), });
        value.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, saturation.value, 0), hsv.hsv_2_rgb(hue.value, saturation.value, 100), });

        red.value   = color.R;
        green.value = color.G;
        blue.value  = color.B;
        alpha.value = color.A;

        red.update_gradient(new Color[] { Color.FromArgb(0, color.G, color.B), Color.FromArgb(255, color.G, color.B), });
        green.update_gradient(new Color[] { Color.FromArgb(color.R, 0, color.B), Color.FromArgb(color.R, 255, color.B), });
        blue.update_gradient(new Color[] { Color.FromArgb(color.R, color.G, 0), Color.FromArgb(color.R, color.G, 255), });
        alpha.update_gradient(new Color[] { Color.FromArgb(0, color.R, color.G, color.B), Color.FromArgb(255, color.R, color.G, color.B), });

        indicator.color_current = color;

        update_caption();
    }
Esempio n. 3
0
    internal palette(Color color)
    {
        hsv hsv = hsv.rgb_2_hsv(color);

        wheel      = new palette_wheel(hsv, 150);
        hue        = new palette_slider((int)(360.0 * hsv.hue), 360, "H", 150, 6);
        saturation = new palette_slider((int)(100.0 * hsv.saturation), 100, "S", 150, 6);
        value      = new palette_slider((int)(100.0 * hsv.value), 100, "V", 150, 6);
        red        = new palette_slider(color.R, 255, "R", 150, 6);
        green      = new palette_slider(color.G, 255, "G", 150, 6);
        blue       = new palette_slider(color.B, 255, "B", 150, 6);
        alpha      = new palette_slider(color.A, 255, "A", 150, 6);
        stack      = new palette_stack(10);
        indicator  = new palette_indicator(color, color);
        accept     = new Button();
        cancel     = new Button();

        wheel.Location = new Point(5, 5);
        wheel.Parent   = this;

        wheel.value_changed += wheel_value_changed;

        hue.Location = new Point(160, 5);
        hue.Parent   = this;

        hue.value_changed += hsv_value_changed;

        saturation.Location = new Point(160, 25);
        saturation.Parent   = this;

        saturation.value_changed += hsv_value_changed;

        value.Location = new Point(160, 45);
        value.Parent   = this;

        value.value_changed += hsv_value_changed;

        red.Location = new Point(160, 70);
        red.Parent   = this;

        red.value_changed += rgb_value_changed;

        green.Location = new Point(160, 90);
        green.Parent   = this;

        green.value_changed += rgb_value_changed;

        blue.Location = new Point(160, 110);
        blue.Parent   = this;

        blue.value_changed += rgb_value_changed;

        alpha.Location = new Point(160, 130);
        alpha.Parent   = this;

        alpha.value_changed += alpha_value_changed;

        stack.Location = new Point(5, 161);
        stack.Parent   = this;

        stack.selected_index_changed += stack_selected_index_changed;

        indicator.Location = new Point(161, 161);
        indicator.Size     = new Size(24, 14);
        indicator.Parent   = this;

        indicator.restore += indicator_restore;

        accept.DialogResult = DialogResult.OK;
        accept.Location     = new Point(235, 155);
        accept.Size         = new Size(55, 20);
        accept.Parent       = this;

        cancel.DialogResult = DialogResult.Cancel;
        cancel.Location     = new Point(295, 155);
        cancel.Size         = new Size(55, 20);
        cancel.Parent       = this;

        MaximizeBox     = false;
        MinimizeBox     = false;
        ShowInTaskbar   = false;
        FormBorderStyle = FormBorderStyle.FixedDialog;
        StartPosition   = FormStartPosition.CenterParent;
        ClientSize      = new Size(355, 180);
        AcceptButton    = accept;
        CancelButton    = cancel;

        FormClosing += form_closing;

        color_elder = color;

        hue.update_gradient(new Color[] { Color.FromArgb(255, 0, 0), Color.FromArgb(255, 255, 0), Color.FromArgb(0, 255, 0), Color.FromArgb(0, 255, 255), Color.FromArgb(0, 0, 255), Color.FromArgb(255, 0, 255), Color.FromArgb(255, 0, 0), });
        saturation.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, 0, value.value), hsv.hsv_2_rgb(hue.value, 100, value.value), });
        value.update_gradient(new Color[] { hsv.hsv_2_rgb(hue.value, saturation.value, 0), hsv.hsv_2_rgb(hue.value, saturation.value, 100), });

        red.update_gradient(new Color[] { Color.FromArgb(0, color.G, color.B), Color.FromArgb(255, color.G, color.B), });
        green.update_gradient(new Color[] { Color.FromArgb(color.R, 0, color.B), Color.FromArgb(color.R, 255, color.B), });
        blue.update_gradient(new Color[] { Color.FromArgb(color.R, color.G, 0), Color.FromArgb(color.R, color.G, 255), });
        alpha.update_gradient(new Color[] { Color.FromArgb(0, color.R, color.G, color.B), Color.FromArgb(255, color.R, color.G, color.B), });

        switch_language();
    }
Esempio n. 4
0
    private void wheel_value_changed()
    {
        hsv hsv = wheel.hsv;

        update_parameters(hsv, Color.FromArgb(alpha.value, hsv.hsv_2_rgb(hsv.hue, hsv.saturation, hsv.value)));
    }