Csharp: Winform 顏色選擇器 Color convert RGB and RGB convert Color

简介: /// <summary> /// 選擇顏色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void
 /// <summary>
        /// 選擇顏色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //是否選擇了顏色
            if (colorDialog1.ShowDialog(this) == DialogResult.OK)
            {
                //System.Drawing.Color.FromArgb
                this.textBox2.Text = ColorTranslator.ToHtml(colorDialog1.Color);
                this.textBoxA.Text = colorDialog1.Color.A.ToString();
                this.textBoxB.Text = colorDialog1.Color.B.ToString();
                this.textBoxG.Text = colorDialog1.Color.G.ToString();
                this.textBoxR.Text = colorDialog1.Color.R.ToString();
                this.textBoxArgb.Text = colorDialog1.Color.ToArgb().ToString();


                //1
                //this.button1.BackColor = ColorTranslator.FromHtml(this.textBox2.Text.Trim());
                //2
                //this.button1.BackColor =Color.FromArgb(int.Parse(this.textBoxArgb.Text.Trim()));
                //3
                this.button1.BackColor = Color.FromArgb(int.Parse(this.textBoxR.Text.Trim()), int.Parse(this.textBoxG.Text.Trim()), int.Parse(this.textBoxB.Text.Trim()));
                

            }
        }
        /// <summary>
        /// 選擇字體
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog(this) == DialogResult.OK)
            {
                this.textBox1.Text = fontDialog1.Font.ToString();
            }
        }

目录
相关文章
|
6月前
|
前端开发
前景色[color]
前景色[color]。
36 0
SVG RGB 与 HSL 区别与使用
SVG RGB 与 HSL 区别与使用
70 0
Figma|Generate color palette
Figma|Generate color palette
112 0
COLOR
COLOR
113 0
c#-WPF string,color,brush之间的转换
原文:c#-WPF string,color,brush之间的转换 String转换成Color string-"ffffff" Color color = (Color)ColorConverter.
1656 0
|
算法 Windows
1054. The Dominant Color (20)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel.
1061 0