Beispiel #1
0
        public ColorPicker(Color starting_color)
        {
            InitializeComponent();

            m_rgb = starting_color;
            m_hsl = MyColors.RGB_to_HSL(m_rgb);
            m_cmyk = MyColors.RGB_to_CMYK(m_rgb);

            m_txt_Red.Text = m_rgb.R.ToString();
            m_txt_Green.Text = m_rgb.G.ToString();
            m_txt_Blue.Text = m_rgb.B.ToString();
            this.textAlpha.Text = m_rgb.A.ToString();
            this.trackBar.Value = m_rgb.A;

            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();
            this.textAlpha.Update();
            this.trackBar.Update();

            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;

            this.m_pbx_BlankBox.Controls.Add(this.m_lbl_Primary_Color);
            this.m_pbx_BlankBox.Controls.Add(this.m_lbl_Secondary_Color);

            m_lbl_Primary_Color.BackColor = starting_color;
            m_lbl_Secondary_Color.BackColor = starting_color;

            this.WriteHexData(m_rgb);
            this.m_pbx_BlankBox.BackgroundImage = My.Draw.BuildGrid(5, m_pbx_BlankBox);

            this.textTBC.Visible = false;
            this.labelTBC.Visible = false;

            // Localizzazione del testo
            /*
            this.m_lbl_SelectColor.Text =	"Seleziona il colore:";
            this.Text =	"Selezione del colore";
            this.labelAlpha.Text = "Alpha:";
            this.labelTBC.Text = "Codice:";
            this.m_cmd_OK.Text = "OK";
            this.m_cmd_Cancel.Text = "Annulla";
            this.buttonDefault.Text = "Default";*/
        }
Beispiel #2
0
        private void m_txt_Red_Leave(object sender, System.EventArgs e)
        {
            string text = m_txt_Red.Text;
            bool has_illegal_chars = false;

            if (text.Length <= 0)
                has_illegal_chars = true;
            else
                foreach (char letter in text)
                {
                    if (!char.IsNumber(letter))
                    {
                        has_illegal_chars = true;
                        break;
                    }
                }

            if (has_illegal_chars)
            {
                My.Box.Warning("Non è un colore RGB");
                UpdateTextBoxes();
                return;
            }

            int red = int.Parse(text);

            if (red < 0)
            {
                My.Box.Warning("Non è un colore RGB");
                m_rgb = Color.FromArgb(0, m_rgb.G, m_rgb.B);
            }
            else if (red > 255)
            {
                My.Box.Warning("Non è un colore RGB");
                m_rgb = Color.FromArgb(255, m_rgb.G, m_rgb.B);
            }
            else
            {
                m_rgb = Color.FromArgb(red, m_rgb.G, m_rgb.B);
            }

            m_hsl = MyColors.RGB_to_HSL(m_rgb);
            m_cmyk = MyColors.RGB_to_CMYK(m_rgb);
            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;
            m_lbl_Primary_Color.BackColor = m_rgb;

            UpdateTextBoxes();
        }
Beispiel #3
0
        private void m_txt_Hex_Leave(object sender, System.EventArgs e)
        {
            string text = m_txt_Hex.Text.ToUpper();
            bool has_illegal_chars = false;

            if (text.Length <= 0)
                has_illegal_chars = true;
            foreach (char letter in text)
            {
                if (!char.IsNumber(letter))
                {
                    if (letter >= 'A' && letter <= 'F')
                        continue;
                    has_illegal_chars = true;
                    break;
                }
            }

            if (has_illegal_chars)
            {
                My.Box.Warning("Non è un numero esadecimale");
                WriteHexData(m_rgb);
                return;
            }

            m_rgb = ParseHexData(text);
            m_rgb = ToTransparent(m_rgb);
            m_hsl = MyColors.RGB_to_HSL(m_rgb);
            m_cmyk = MyColors.RGB_to_CMYK(m_rgb);

            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;
            m_lbl_Primary_Color.BackColor = m_rgb;

            UpdateTextBoxes();
        }
Beispiel #4
0
        private void m_lbl_Secondary_Color_Click(object sender, System.EventArgs e)
        {
            m_rgb = m_lbl_Secondary_Color.BackColor;
            m_hsl = MyColors.RGB_to_HSL(m_rgb);

            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;

            m_lbl_Primary_Color.BackColor = m_rgb;
            m_lbl_Primary_Color.Update();

            m_cmyk = MyColors.RGB_to_CMYK(m_rgb);

            m_txt_Red.Text = m_rgb.R.ToString();
            m_txt_Green.Text = m_rgb.G.ToString();
            m_txt_Blue.Text = m_rgb.B.ToString();
            this.textAlpha.Text = m_rgb.A.ToString();
            this.trackBar.Value = (int)m_rgb.A;

            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();
            this.textAlpha.Update();
            this.trackBar.Update();
        }
Beispiel #5
0
        private void m_ctrl_ThinBox_Scroll(object sender, System.EventArgs e)
        {
            m_hsl = m_ctrl_ThinBox.HSL;
            m_rgb = MyColors.HSL_to_RGB(m_hsl);
            m_rgb = ToTransparent(m_rgb);
            m_cmyk = MyColors.RGB_to_CMYK(m_rgb);

            m_txt_Red.Text = m_rgb.R.ToString();
            m_txt_Green.Text = m_rgb.G.ToString();
            m_txt_Blue.Text = m_rgb.B.ToString();

            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();

            m_ctrl_BigBox.HSL = m_hsl;

            m_lbl_Primary_Color.BackColor = m_rgb;
            m_lbl_Primary_Color.Update();

            WriteHexData(m_rgb);
        }