Beispiel #1
0
        private void m_lbl_Secondary_Color_Click(object sender, System.EventArgs e)
        {
            Color secondary = m_lbl_Secondary_Color.BackColor;
            m_rgb = Color.FromArgb(m_rgb.A, secondary.R, secondary.G, secondary.B);
            m_hsl = AdobeColors.RGB_to_HSL(m_rgb);

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

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

            m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);
            
            m_txt_Hue.Text =        Round(m_hsl.H * 360).ToString();
            m_txt_Sat.Text =        Round(m_hsl.S * 100).ToString();
            m_txt_Bright.Text =     Round(m_hsl.L * 100).ToString();
            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_Cyan.Text =       Round(m_cmyk.C * 100).ToString();
            m_txt_Magenta.Text =    Round(m_cmyk.M * 100).ToString();
            m_txt_Yellow.Text =     Round(m_cmyk.Y * 100).ToString();
            m_txt_K.Text =          Round(m_cmyk.K * 100).ToString();
            m_txt_A.Text =          m_rgb.A.ToString();

            m_txt_Hue.Update();
            m_txt_Sat.Update();
            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();
            m_txt_Cyan.Update();
            m_txt_Magenta.Update();
            m_txt_Yellow.Update();
            m_txt_K.Update();
            m_txt_A.Update();
        }
Beispiel #2
0
        private void m_txt_Sat_Leave(object sender, System.EventArgs e)
        {
            string text = m_txt_Sat.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 )
            {
                MessageBox.Show("Saturation must be a number between 0 and 100".Localize());
                UpdateTextBoxes();
                return;
            }

            int sat = int.Parse(text);

            if ( sat < 0 )
            {
                m_txt_Sat.Text = "0";
                m_hsl.S = 0.0;
            }
            else if ( sat > 100 )
            {
                m_txt_Sat.Text = "100";
                m_hsl.S = 1.0;
            }
            else
            {
                m_hsl.S = (double)sat/100;
            }

            m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
            m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);
            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;
            m_lbl_Primary_Color.BackColor = MakeOpaque(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 )
            {
                MessageBox.Show("Hex must be a hex value between 00000000 and FFFFFFFF".Localize());
                WriteHexData(m_rgb);
                return;
            }

            Color hexColor = ParseHexData(text);
            if (hexColor.IsEmpty)
            {
                WriteHexData(m_rgb);
                return;
            }

            m_rgb = hexColor;
            m_hsl = AdobeColors.RGB_to_HSL(m_rgb);
            m_cmyk = AdobeColors.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_ctrl_ThinBox_ColorChanged(object sender, System.EventArgs e)
        {
            m_hsl = m_ctrl_ThinBox.HSL;
            m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
            m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);
            
            m_txt_Hue.Text =        Round(m_hsl.H * 360).ToString();
            m_txt_Sat.Text =        Round(m_hsl.S * 100).ToString();
            m_txt_Bright.Text =     Round(m_hsl.L * 100).ToString();
            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_Cyan.Text =       Round(m_cmyk.C * 100).ToString();
            m_txt_Magenta.Text =    Round(m_cmyk.M * 100).ToString();
            m_txt_Yellow.Text =     Round(m_cmyk.Y * 100).ToString();
            m_txt_K.Text =          Round(m_cmyk.K * 100).ToString();
            m_txt_A.Text =          m_rgb.A.ToString();

            m_txt_Hue.Update();
            m_txt_Sat.Update();
            m_txt_Bright.Update();
            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();
            m_txt_Cyan.Update();
            m_txt_Magenta.Update();
            m_txt_Yellow.Update();
            m_txt_K.Update();
            m_txt_A.Update();

            m_ctrl_BigBox.HSL = m_hsl;

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

            WriteHexData(m_rgb);
        }
Beispiel #5
0
        /// <summary>
        /// Sets starting color</summary>
        /// <param name="starting_color">The starting color</param>
        /// <param name="enableAlpha">Enable the alpha channel iff true</param>
        public void SetStartColor(Color starting_color, bool enableAlpha)
        {
            m_enableAlpha = enableAlpha;
            if (enableAlpha)
            {
                m_txt_A.Visible = true;
                m_lbl_A.Visible = true;
                m_txt_Hex.MaxLength = 8;
            }
            else
            {
                starting_color = MakeOpaque(starting_color);
                m_txt_A.Visible = false;
                m_lbl_A.Visible = false;
                m_txt_Hex.MaxLength = 6;
            }

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

            m_txt_Hue.Text = Round(m_hsl.H * 360).ToString();
            m_txt_Sat.Text = Round(m_hsl.S * 100).ToString();
            m_txt_Bright.Text = Round(m_hsl.L * 100).ToString();
            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_Cyan.Text = Round(m_cmyk.C * 100).ToString();
            m_txt_Magenta.Text = Round(m_cmyk.M * 100).ToString();
            m_txt_Yellow.Text = Round(m_cmyk.Y * 100).ToString();
            m_txt_K.Text = Round(m_cmyk.K * 100).ToString();
            m_txt_A.Text = m_rgb.A.ToString();

            m_txt_Hue.Update();
            m_txt_Sat.Update();
            m_txt_Red.Update();
            m_txt_Green.Update();
            m_txt_Blue.Update();
            m_txt_Cyan.Update();
            m_txt_Magenta.Update();
            m_txt_Yellow.Update();
            m_txt_K.Update();
            m_txt_A.Update();

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

            m_lbl_Primary_Color.BackColor = MakeOpaque(starting_color);
            m_lbl_Secondary_Color.BackColor = MakeOpaque(starting_color);

            m_rbtn_Hue.Checked = true;

            WriteHexData(m_rgb);
        }
Beispiel #6
0
        private void m_txt_A_Leave(object sender, System.EventArgs e)
        {
            string text = m_txt_A.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 )
            {
                MessageBox.Show("Alpha must be a number between 0 and 255".Localize());
                UpdateTextBoxes();
                return;
            }

            int alpha = int.Parse(text);

            if ( alpha < 0 )
            {
                m_txt_Red.Text = "0";
                m_rgb = Color.FromArgb(0, m_rgb.R, m_rgb.G, m_rgb.B);
            }
            else if ( alpha > 255 )
            {
                m_txt_Red.Text = "255";
                m_rgb = Color.FromArgb(255, m_rgb.R, m_rgb.G, m_rgb.B);
            }
            else
            {
                m_rgb = Color.FromArgb(alpha, m_rgb.R, m_rgb.G, m_rgb.B);
            }

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

            UpdateTextBoxes();
        }
Beispiel #7
0
        private void m_txt_Hue_Leave(object sender, System.EventArgs e)
        {
            string text = m_txt_Hue.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 )
            {
                MessageBox.Show("Hue must be a number between 0 and 360");
                UpdateTextBoxes();
                return;
            }

            int hue = int.Parse(text);

            if ( hue < 0 )
            {
                m_txt_Hue.Text = "0";
                m_hsl.H = 0.0;
            }
            else if ( hue > 360 )
            {
                m_txt_Hue.Text = "360";
                m_hsl.H = 1.0;
            }
            else
            {
                m_hsl.H = (double)hue/360;
            }

            m_rgb = AdobeColors.HSL_to_RGB(m_hsl);
            m_cmyk = AdobeColors.RGB_to_CMYK(m_rgb);
            m_ctrl_BigBox.HSL = m_hsl;
            m_ctrl_ThinBox.HSL = m_hsl;
            m_lbl_Primary_Color.BackColor = MakeOpaque(m_rgb);

            UpdateTextBoxes();
        }