コード例 #1
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_txt_Blue_Leave(object sender, System.EventArgs e)
                    {
                        string text = m_txt_Blue.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("Blue must be a number value between 0 and 255");
                            UpdateTextBoxes();
                            return;
                        }

                        int blue = int.Parse(text);

                        if ( blue < 0 )
                        {
                            MessageBox.Show("An integer between 0 and 255 is required.\nClosest value inserted.");
                            m_txt_Blue.Text = "0";
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 0);
                        }
                        else if ( blue > 255 )
                        {
                            MessageBox.Show("An integer between 0 and 255 is required.\nClosest value inserted.");
                            m_txt_Blue.Text = "255";
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, 255);
                        }
                        else
                        {
                            m_rgb = Color.FromArgb(m_rgb.R, m_rgb.G, blue);
                        }

                        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();
                    }
コード例 #2
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_txt_Black_Leave(object sender, System.EventArgs e)
                    {
                        string text = m_txt_Black.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("Black must be a number value between 0 and 360");
                            UpdateTextBoxes();
                            return;
                        }

                        int lum = int.Parse(text);

                        if ( lum < 0 )
                        {
                            MessageBox.Show("An integer between 0 and 100 is required.\nClosest value inserted.");
                            m_txt_Black.Text = "0";
                            m_hsl.L = 0.0;
                        }
                        else if ( lum > 100 )
                        {
                            MessageBox.Show("An integer between 0 and 100 is required.\nClosest value inserted.");
                            m_txt_Black.Text = "100";
                            m_hsl.L = 1.0;
                        }
                        else
                        {
                            m_hsl.L = (double)lum/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 = m_rgb;

                        UpdateTextBoxes();
                    }
コード例 #3
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    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 0x000000 and 0xFFFFFF");
                            WriteHexData(m_rgb);
                            return;
                        }

                        m_rgb = ParseHexData(text);
                        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();
                    }
コード例 #4
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    private void m_lbl_Secondary_Color_Click(object sender, System.EventArgs e)
                    {
                        m_rgb = m_lbl_Secondary_Color.BackColor;
                        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 = 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_Black.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_Hue.Update();
                        m_txt_Sat.Update();
                        m_txt_Lum.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();
                    }
コード例 #5
0
ファイル: ColorCellEditor.cs プロジェクト: zhuangyy/Motion
                    public frmColorPicker(Color starting_color)
                    {
                        InitializeComponent();

                        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_Black.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_Hue.Update();
                        m_txt_Sat.Update();
                        m_txt_Lum.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_ctrl_BigBox.HSL = m_hsl;
                        m_ctrl_ThinBox.HSL = m_hsl;

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

                        m_rbtn_Hue.Checked = true;

                        this.WriteHexData(m_rgb);
                    }