嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
可使用系統顏色選擇器或螢幕取色器來查詢顏色值。
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace Xianfen.Net.GetColor
{
public class MainForm : Form
{
private IContainer components;
private Label lblColor0;
private Button btnPickColor;
private Button btnSelectColor;
private Button btnAbout;
private GroupBox gpbColorStack;
private Label lblColor5;
private Label lblColor4;
private Label lblColor3;
private Label lblColor2;
private Label lblColor1;
private GroupBox gpbValue;
private Label lblColor7;
private Label lblColor6;
private Label lblCMYK;
private Label lblARGB;
private Label lblRGB;
private TextBox txtHSB;
private TextBox txtARGB;
private TextBox txtRGB;
private ContextMenuStrip ctnMenu;
private ToolStripMenuItem toolPickColor;
private ToolStripMenuItem toolShow;
private ToolStripMenuItem toolAbout;
private ToolStripSeparator toolStripMenuItem1;
private ToolStripMenuItem toolClose;
private ColorDialog colorDlg;
private Label label1;
private TextBox txtBGR;
private Label lab;
private Timer timer1;
private Label label2;
private TextBox txtRGBdec;
private Label label3;
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new Container();
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(MainForm));
this.lblColor0 = new Label();
this.btnPickColor = new Button();
this.btnSelectColor = new Button();
this.btnAbout = new Button();
this.gpbColorStack = new GroupBox();
this.lblColor7 = new Label();
this.lblColor6 = new Label();
this.lblColor5 = new Label();
this.lblColor4 = new Label();
this.lblColor3 = new Label();
this.txtARGB = new TextBox();
this.lblColor2 = new Label();
this.lblColor1 = new Label();
this.lblARGB = new Label();
this.gpbValue = new GroupBox();
this.label3 = new Label();
this.txtRGBdec = new TextBox();
this.label1 = new Label();
this.txtBGR = new TextBox();
this.txtHSB = new TextBox();
this.txtRGB = new TextBox();
this.lblCMYK = new Label();
this.lblRGB = new Label();
this.ctnMenu = new ContextMenuStrip(this.components);
this.toolPickColor = new ToolStripMenuItem();
this.toolShow = new ToolStripMenuItem();
this.toolAbout = new ToolStripMenuItem();
this.toolStripMenuItem1 = new ToolStripSeparator();
this.toolClose = new ToolStripMenuItem();
this.colorDlg = new ColorDialog();
this.lab = new Label();
this.timer1 = new Timer(this.components);
this.label2 = new Label();
this.gpbColorStack.SuspendLayout();
this.gpbValue.SuspendLayout();
this.ctnMenu.SuspendLayout();
base.SuspendLayout();
this.lblColor0.BackColor = Color.White;
this.lblColor0.BorderStyle = BorderStyle.FixedSingle;
this.lblColor0.Location = new Point(12, 64);
this.lblColor0.Name = "lblColor0";
this.lblColor0.Size = new Size(88, 85);
this.lblColor0.TabIndex = 0;
this.lblColor0.Click = new EventHandler(this.lblColor_Click);
this.lblColor0.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.btnPickColor.FlatStyle = FlatStyle.System;
this.btnPickColor.Location = new Point(198, 6);
this.btnPickColor.Name = "btnPickColor";
this.btnPickColor.Size = new Size(61, 23);
this.btnPickColor.TabIndex = 1;
this.btnPickColor.Text = "拾色器";
this.btnPickColor.UseVisualStyleBackColor = true;
this.btnPickColor.Click = new EventHandler(this.btnPickColor_Click);
this.btnSelectColor.FlatStyle = FlatStyle.System;
this.btnSelectColor.Location = new Point(123, 6);
this.btnSelectColor.Name = "btnSelectColor";
this.btnSelectColor.Size = new Size(61, 23);
this.btnSelectColor.TabIndex = 2;
this.btnSelectColor.Text = "调色板";
this.btnSelectColor.UseVisualStyleBackColor = true;
this.btnSelectColor.Click = new EventHandler(this.btnSelectColor_Click);
this.btnAbout.FlatStyle = FlatStyle.System;
this.btnAbout.Location = new Point(271, 6);
this.btnAbout.Name = "btnAbout";
this.btnAbout.Size = new Size(61, 23);
this.btnAbout.TabIndex = 3;
this.btnAbout.Text = "关于";
this.btnAbout.UseVisualStyleBackColor = true;
this.btnAbout.Click = new EventHandler(this.btnAbout_Click);
this.gpbColorStack.Controls.Add(this.lblColor7);
this.gpbColorStack.Controls.Add(this.lblColor6);
this.gpbColorStack.Controls.Add(this.lblColor5);
this.gpbColorStack.Controls.Add(this.lblColor4);
this.gpbColorStack.Controls.Add(this.lblColor3);
this.gpbColorStack.Controls.Add(this.txtARGB);
this.gpbColorStack.Controls.Add(this.lblColor2);
this.gpbColorStack.Controls.Add(this.lblColor1);
this.gpbColorStack.Location = new Point(62, 205);
this.gpbColorStack.Name = "gpbColorStack";
this.gpbColorStack.Size = new Size(218, 75);
this.gpbColorStack.TabIndex = 5;
this.gpbColorStack.TabStop = false;
this.gpbColorStack.Text = "颜色栈";
this.gpbColorStack.Visible = false;
this.lblColor7.BackColor = Color.White;
this.lblColor7.BorderStyle = BorderStyle.Fixed3D;
this.lblColor7.Location = new Point(168, 16);
this.lblColor7.Name = "lblColor7";
this.lblColor7.Size = new Size(20, 20);
this.lblColor7.TabIndex = 6;
this.lblColor7.Click = new EventHandler(this.lblColor_Click);
this.lblColor7.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblColor6.BackColor = Color.White;
this.lblColor6.BorderStyle = BorderStyle.Fixed3D;
this.lblColor6.Location = new Point(142, 16);
this.lblColor6.Name = "lblColor6";
this.lblColor6.Size = new Size(20, 20);
this.lblColor6.TabIndex = 5;
this.lblColor6.Click = new EventHandler(this.lblColor_Click);
this.lblColor6.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblColor5.BackColor = Color.White;
this.lblColor5.BorderStyle = BorderStyle.Fixed3D;
this.lblColor5.Location = new Point(116, 16);
this.lblColor5.Name = "lblColor5";
this.lblColor5.Size = new Size(20, 20);
this.lblColor5.TabIndex = 4;
this.lblColor5.Click = new EventHandler(this.lblColor_Click);
this.lblColor5.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblColor4.BackColor = Color.White;
this.lblColor4.BorderStyle = BorderStyle.Fixed3D;
this.lblColor4.Location = new Point(90, 16);
this.lblColor4.Name = "lblColor4";
this.lblColor4.Size = new Size(20, 20);
this.lblColor4.TabIndex = 3;
this.lblColor4.Click = new EventHandler(this.lblColor_Click);
this.lblColor4.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblColor3.BackColor = Color.White;
this.lblColor3.BorderStyle = BorderStyle.Fixed3D;
this.lblColor3.Location = new Point(64, 16);
this.lblColor3.Name = "lblColor3";
this.lblColor3.Size = new Size(20, 20);
this.lblColor3.TabIndex = 2;
this.lblColor3.Click = new EventHandler(this.lblColor_Click);
this.lblColor3.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.txtARGB.Font = new Font("Microsoft Sans Serif", 12f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.txtARGB.Location = new Point(64, 39);
this.txtARGB.Name = "txtARGB";
this.txtARGB.ReadOnly = true;
this.txtARGB.Size = new Size(126, 26);
this.txtARGB.TabIndex = 3;
this.lblColor2.BackColor = Color.White;
this.lblColor2.BorderStyle = BorderStyle.Fixed3D;
this.lblColor2.Location = new Point(38, 16);
this.lblColor2.Name = "lblColor2";
this.lblColor2.Size = new Size(20, 20);
this.lblColor2.TabIndex = 1;
this.lblColor2.Click = new EventHandler(this.lblColor_Click);
this.lblColor2.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblColor1.BackColor = Color.White;
this.lblColor1.BorderStyle = BorderStyle.Fixed3D;
this.lblColor1.Location = new Point(12, 16);
this.lblColor1.Name = "lblColor1";
this.lblColor1.Size = new Size(20, 20);
this.lblColor1.TabIndex = 0;
this.lblColor1.Click = new EventHandler(this.lblColor_Click);
this.lblColor1.DoubleClick = new EventHandler(this.lblColor_DoubleClick);
this.lblARGB.AutoSize = true;
this.lblARGB.Location = new Point(8, 43);
this.lblARGB.Name = "lblARGB";
this.lblARGB.Size = new Size(36, 19);
this.lblARGB.TabIndex = 2;
this.lblARGB.Text = "RGB";
this.gpbValue.Controls.Add(this.label3);
this.gpbValue.Controls.Add(this.txtRGBdec);
this.gpbValue.Controls.Add(this.label1);
this.gpbValue.Controls.Add(this.txtBGR);
this.gpbValue.Controls.Add(this.txtHSB);
this.gpbValue.Controls.Add(this.lblARGB);
this.gpbValue.Controls.Add(this.txtRGB);
this.gpbValue.Controls.Add(this.lblCMYK);
this.gpbValue.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 134);
this.gpbValue.Location = new Point(106, 35);
this.gpbValue.Name = "gpbValue";
this.gpbValue.Size = new Size(240, 126);
this.gpbValue.TabIndex = 6;
this.gpbValue.TabStop = false;
this.gpbValue.Text = "颜色值";
this.label3.AutoSize = true;
this.label3.Location = new Point(8, 71);
this.label3.Name = "label3";
this.label3.Size = new Size(63, 19);
this.label3.TabIndex = 11;
this.label3.Text = "RGB(d)";
this.txtRGBdec.Location = new Point(70, 69);
this.txtRGBdec.Name = "txtRGBdec";
this.txtRGBdec.ReadOnly = true;
this.txtRGBdec.Size = new Size(156, 24);
this.txtRGBdec.TabIndex = 10;
this.txtRGBdec.MouseClick = new MouseEventHandler(this.txtRGBdec_MouseClick);
this.label1.AutoSize = true;
this.label1.Location = new Point(8, 15);
this.label1.Name = "label1";
this.label1.Size = new Size(36, 19);
this.label1.TabIndex = 7;
this.label1.Text = "ASS";
this.txtBGR.Location = new Point(70, 13);
this.txtBGR.Name = "txtBGR";
this.txtBGR.ReadOnly = true;
this.txtBGR.Size = new Size(156, 24);
this.txtBGR.TabIndex = 6;
this.txtBGR.MouseClick = new MouseEventHandler(this.txtBGR_MouseClick);
this.txtHSB.Location = new Point(70, 97);
this.txtHSB.Name = "txtHSB";
this.txtHSB.ReadOnly = true;
this.txtHSB.Size = new Size(156, 24);
this.txtHSB.TabIndex = 5;
this.txtHSB.MouseClick = new MouseEventHandler(this.txtHSB_MouseClick);
this.txtRGB.Location = new Point(70, 41);
this.txtRGB.Name = "txtRGB";
this.txtRGB.ReadOnly = true;
this.txtRGB.Size = new Size(156, 24);
this.txtRGB.TabIndex = 1;
this.txtRGB.MouseClick = new MouseEventHandler(this.txtRGB_MouseClick);
this.lblCMYK.AutoSize = true;
this.lblCMYK.Location = new Point(8, 99);
this.lblCMYK.Name = "lblCMYK";
this.lblCMYK.Size = new Size(36, 19);
this.lblCMYK.TabIndex = 4;
this.lblCMYK.Text = "HSB";
this.lblRGB.AutoSize = true;
this.lblRGB.Location = new Point(112, 46);
this.lblRGB.Name = "lblRGB";
this.lblRGB.Size = new Size(32, 16);
this.lblRGB.TabIndex = 0;
this.lblRGB.Text = "RGB";
this.ctnMenu.Items.AddRange(new ToolStripItem[]
{
this.toolPickColor,
this.toolShow,
this.toolAbout,
this.toolStripMenuItem1,
this.toolClose
});
this.ctnMenu.Name = "ctnMenu";
this.ctnMenu.Size = new Size(110, 98);
this.toolPickColor.Name = "toolPickColor";
this.toolPickColor.Size = new Size(109, 22);
this.toolPickColor.Text = "取色";
this.toolPickColor.Click = new EventHandler(this.btnPickColor_Click);
this.toolShow.Name = "toolShow";
this.toolShow.Size = new Size(109, 22);
this.toolShow.Text = "显示";
this.toolShow.Click = new EventHandler(this.toolShow_Click);
this.toolAbout.Name = "toolAbout";
this.toolAbout.Size = new Size(109, 22);
this.toolAbout.Text = "关于...";
this.toolAbout.Click = new EventHandler(this.btnAbout_Click);
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new Size(106, 6);
this.toolClose.Name = "toolClose";
this.toolClose.Size = new Size(109, 22);
this.toolClose.Text = "退出";
this.toolClose.Click = new EventHandler(this.btnClose_Click);
this.lab.AutoSize = true;
this.lab.Font = new Font("宋体", 9f, FontStyle.Regular, GraphicsUnit.Point, 134);
this.lab.Location = new Point(12, 11);
this.lab.Name = "lab";
this.lab.Size = new Size(77, 24);
this.lab.TabIndex = 9;
this.lab.Text = "单击颜色代码\r\n复制到剪贴板";
this.timer1.Interval = 5000;
this.timer1.Tick = new EventHandler(this.timer1_Tick);
this.label2.AutoSize = true;
this.label2.Location = new Point(12, 50);
this.label2.Name = "label2";
this.label2.Size = new Size(53, 12);
this.label2.TabIndex = 10;
this.label2.Text = "颜色预览";
base.AutoScaleDimensions = new SizeF(6f, 12f);
//base.AutoScaleMode = AutoScaleMode.Font;
base.ClientSize = new Size(358, 167);
base.Controls.Add(this.label2);
base.Controls.Add(this.gpbColorStack);
base.Controls.Add(this.gpbValue);
base.Controls.Add(this.lblColor0);
base.Controls.Add(this.lab);
base.Controls.Add(this.lblRGB);
base.Controls.Add(this.btnAbout);
base.Controls.Add(this.btnSelectColor);
base.Controls.Add(this.btnPickColor);
//base.FormBorderStyle = FormBorderStyle.FixedSingle;
//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
base.MaximizeBox = false;
base.Name = "MainForm";
base.StartPosition = FormStartPosition.CenterScreen;
this.Text = "小丸拾色器";
this.gpbColorStack.ResumeLayout(false);
this.gpbColorStack.PerformLayout();
this.gpbValue.ResumeLayout(false);
this.gpbValue.PerformLayout();
this.ctnMenu.ResumeLayout(false);
base.ResumeLayout(false);
base.PerformLayout();
}
public MainForm()
{
this.InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ColorPicker colorPicker = new ColorPicker();
base.Hide();
colorPicker.ShowDialog();
base.Show();
this.BackColor = colorPicker.SelectedColor;
}
private void btnPickColor_Click(object sender, EventArgs e)
{
using (ColorPicker colorPicker = new ColorPicker())
{
base.WindowState = FormWindowState.Minimized;
base.Visible = false;
colorPicker.ShowDialog();
for (int i = 7; i > 0; i--)
{
((Label)base.Controls.Find("lblColor" i.ToString(), true)[0]).BackColor = ((Label)base.Controls.Find("lblColor" (i - 1).ToString(), true)[0]).BackColor;
}
this.lblColor0.BackColor = colorPicker.SelectedColor;
this.toolShow_Click(null, null);
this.lblColor_Click(this.lblColor0, null);
}
}
private void btnSelectColor_Click(object sender, EventArgs e)
{
this.colorDlg.Color = this.lblColor0.BackColor;
if (this.colorDlg.ShowDialog() == DialogResult.OK)
{
this.lblColor0.BackColor = this.colorDlg.Color;
this.lblColor_Click(this.lblColor0, null);
}
}
private void btnAbout_Click(object sender, EventArgs e)
{
MessageBox.Show("小丸为获取用于ASS字幕的BGR颜色值而修改此软件。\n原作者:周振兴 Blog:http://www.xianfen.net \n发布日期:2013年12月11日", "关于 小丸拾色器", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
private void btnClose_Click(object sender, EventArgs e)
{
base.Close();
}
private void lnkCopyRights_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.xianfen.net");
}
private void lblColor_Click(object sender, EventArgs e)
{
Label label = sender as Label;
if (label != null)
{
Color backColor = label.BackColor;
this.txtRGB.Text = string.Format("{0,2:X2}{1,2:X2}{2,2:X2}", backColor.R.ToString("X"), backColor.G.ToString("X"), backColor.B.ToString("X")).Replace(" ", "0");
this.txtRGBdec.Text = string.Format("{0} {1} {2}", backColor.R.ToString(), backColor.G.ToString(), backColor.B.ToString());
this.txtARGB.Text = string.Format("{0,3:D3} {1,3:D3} {2,3:D3} {3,2:D3}", new object[]
{
backColor.A,
backColor.R,
backColor.G,
backColor.B
});
this.txtBGR.Text = string.Format("&H00{0,2:X2}{1,2:X2}{2,2:X2}", backColor.B.ToString("X"), backColor.G.ToString("X"), backColor.R.ToString("X")).Replace(" ", "0");
int num = (int)((double)(backColor.GetHue() / 360f * 240f) 0.5);
int num2 = (int)((double)(backColor.GetSaturation() * 241f) 0.5);
int num3 = (int)((double)(backColor.GetBrightness() * 241f) 0.5);
if (num > 239)
{
num = 239;
}
if (num2 > 240)
{
num2 = 240;
}
if (num3 > 240)
{
num3 = 240;
}
this.txtHSB.Text = string.Format("{0,3:D3} {1,3:D3} {2,3:D3}", num, num2, num3);
}
}
private void lblColor_DoubleClick(object sender, EventArgs e)
{
Label label = sender as Label;
if (label != null)
{
Color backColor = label.BackColor;
this.colorDlg.Color = backColor;
if (this.colorDlg.ShowDialog() == DialogResult.OK)
{
label.BackColor = this.colorDlg.Color;
}
}
}
private void toolShow_Click(object sender, EventArgs e)
{
base.Show();
base.WindowState = FormWindowState.Normal;
base.Activate();
}
private void ntyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.toolShow_Click(null, null);
}
private void timer1_Tick(object sender, EventArgs e)
{
this.lab.Text = "";
this.timer1.Enabled = false;
}
private void txtBGR_MouseClick(object sender, MouseEventArgs e)
{
TextBox textBox = (TextBox)sender;
if (textBox.Text != "")
{
Clipboard.SetDataObject(textBox.Text);
this.lab.Text = "已经复制到剪贴板!";
this.timer1.Enabled = true;
}
}
private void txtHSB_MouseClick(object sender, MouseEventArgs e)
{
TextBox textBox = (TextBox)sender;
if (textBox.Text != "")
{
Clipboard.SetDataObject(textBox.Text);
this.lab.Text = "已经复制到剪贴板!";
this.timer1.Enabled = true;
}
}
private void txtRGBdec_MouseClick(object sender, MouseEventArgs e)
{
TextBox textBox = (TextBox)sender;
if (textBox.Text != "")
{
Clipboard.SetDataObject(textBox.Text);
this.lab.Text = "已经复制到剪贴板!";
this.timer1.Enabled = true;
}
}
private void txtRGB_MouseClick(object sender, MouseEventArgs e)
{
TextBox textBox = (TextBox)sender;
if (textBox.Text != "")
{
Clipboard.SetDataObject(textBox.Text);
this.lab.Text = "已经复制到剪贴板!";
this.timer1.Enabled = true;
}
}
}
}