我不太确定我是愚蠢的。什么是Web调色板小部件调用? colordialog带来了另一个不是我想要的选择器
我看网络,但大多数调色板没有网页选择器。 提前致谢 [编辑:也许我应该重新解释这个问题,我如何提出上面的颜色选择器?我不想使用任何第三方小部件,除了那些已经在VS]
中可用的小部件答案 0 :(得分:3)
我希望有人想出一个开箱即用的.Net解决方案。
如果没有,你可以写自己的;这是一个初学者..:
public partial class WebColors : Form
{
public WebColors()
{
InitializeComponent();
}
public Color pick { get; set; }
private void WebColors_Load(object sender, EventArgs e)
{
var webColors =
Enum.GetValues(typeof(KnownColor))
.Cast<KnownColor>()
.Where(k => k >= KnownColor.Transparent && k < KnownColor.ButtonFace)
.Select(k => Color.FromKnownColor(k))
.OrderBy(c => c.GetHue())
.ThenBy(c => c.GetSaturation())
.ThenBy(c => c.GetBrightness()).ToList();
int cc = webColors.Count;
int n = (int)Math.Sqrt(cc) + 0;
int w = ClientSize.Width / (n) - 1;
Height = (n+1) * w + 90;
for (int i = 0; i < cc; i++)
{
Label lbl = new Label();
lbl.Text = "";
lbl.AutoSize = false;
lbl.Size = new Size(w - 1, w - 1);
lbl.BackColor = webColors[i];
lbl.BorderStyle = BorderStyle.FixedSingle;
lbl.Location = new Point(1 + w * (i % (n+ 1)) , w * ( i / (n+1)) );
lbl.Click += (ss, ee) =>
{
pick = lbl.BackColor;
lbl_colorName.Text = pick.Name;
};
Controls.Add(lbl);
}
}
private void cb_ok_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void cb_cancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
您可以添加排序选项并切换orderby子句..
答案 1 :(得分:-1)
您可以使用rgb颜色
your_object_here.BackColor = Color.FromArgb(255, 210, 210);
your_object_here.ForeColor = Color.FromArgb(255,255,255);