代码拉取完成,页面将自动刷新
using System;
using System.Drawing;
using System.Windows.Forms;
namespace ColorPane
{
public partial class ColorTracker : UserControl
{
private bool _foreColorizing = true;
public ColorTracker()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
txtR.Left++;
txtG.Left++;
txtB.Left++;
txtR.Left--;
txtG.Left--;
txtB.Left--;
ForeColorizing = _foreColorizing;
}
private void SyncColors(ColorSlider cs)
{
foreach (Control c in Controls)
{
if (c is ColorSlider)
{
if (c != cs) ((ColorSlider)c).RGB = cs.RGB;
}
}
txtR.Text = cs.RGB.R.ToString();
txtG.Text = cs.RGB.G.ToString();
txtB.Text = cs.RGB.B.ToString();
if (_foreColorizing) lblForeColor.BackColor = cs.RGB;
else lblBackColor.BackColor = cs.RGB;
}
[System.ComponentModel.Description("true��ʾ����ǰ��ɫ������Ϊfalse��")]
public bool ForeColorizing
{
get { return _foreColorizing; }
set
{
_foreColorizing = value;
if (_foreColorizing)
{
csR.RGB = lblForeColor.BackColor;
}
else
{
csR.RGB = lblBackColor.BackColor;
}
SyncColors(csR);
}
}
[System.ComponentModel.Description("ѡ���ǰ��ɫ��")]
public Color ForeColorSelection
{
get { return lblForeColor.BackColor; }
set
{
lblForeColor.BackColor = value;
csR.RGB = value;
_foreColorizing = true;
SyncColors(csR);
}
}
[System.ComponentModel.Description("ѡ��ı���ɫ��")]
public Color BackColorSelection
{
get { return lblBackColor.BackColor; }
set
{
lblBackColor.BackColor = value;
csR.RGB = value;
_foreColorizing = false;
SyncColors(csR);
}
}
private void SliderScroll(object sender, SliderEventArgs e)
{
SyncColors((ColorSlider)sender);
}
private void lblForeColor_Click(object sender, EventArgs e)
{
ForeColorizing = true;
}
private void lblBackColor_Click(object sender, EventArgs e)
{
ForeColorizing = false;
}
private void lblSwitch_Click(object sender, EventArgs e)
{
Color temp = lblForeColor.BackColor;
lblForeColor.BackColor = lblBackColor.BackColor;
lblBackColor.BackColor = temp;
ForeColorizing = _foreColorizing;
}
private void lblGray_Click(object sender, EventArgs e)
{
lblBackColor.BackColor = Color.White;
lblForeColor.BackColor = Color.Black;
ForeColorizing = _foreColorizing;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。