private void colorTimer_Tick(object sender, EventArgs e) { Point pos = MousePosition; colorPicker.Color = MyColors.GetPixelColor(pos); txtX.Text = pos.X.ToString(); txtY.Text = pos.Y.ToString(); }
private void txtDecimal_TextChanged(object sender, EventArgs e) { try { if (!dialogChanged) { colorPicker.Color = MyColors.DecimalToColor(Convert.ToInt32(txtDecimal.Text)); } } catch { } }
private void txtHex_TextChanged(object sender, EventArgs e) { try { if (!dialogChanged) { colorPicker.Color = MyColors.HexToColor(txtHex.Text); } } catch { } }
private void UpdateControls(MyColor color) { DrawColors(); dialogChanged = true; nudHue.Value = (decimal)Math.Round(color.HSB.Hue360); nudSaturation.Value = (decimal)Math.Round(color.HSB.Saturation100); nudBrightness.Value = (decimal)Math.Round(color.HSB.Brightness100); nudRed.Value = color.RGB.Red; nudGreen.Value = color.RGB.Green; nudBlue.Value = color.RGB.Blue; nudCyan.Value = (decimal)Math.Round(color.CMYK.Cyan100); nudMagenta.Value = (decimal)Math.Round(color.CMYK.Magenta100); nudYellow.Value = (decimal)Math.Round(color.CMYK.Yellow100); nudKey.Value = (decimal)Math.Round(color.CMYK.Key100); txtHex.Text = MyColors.ColorToHex(color); txtDecimal.Text = MyColors.ColorToDecimal(color).ToString(); dialogChanged = false; }
public static Color ParseColor(string color) { if (color.StartsWith("#")) { return(MyColors.HexToColor(color)); } else if (color.Contains(',')) { int[] colors = color.Split(',').Select(x => int.Parse(x)).ToArray(); if (colors.Length == 3) { return(Color.FromArgb(colors[0], colors[1], colors[2])); } if (colors.Length == 4) { return(Color.FromArgb(colors[0], colors[1], colors[2], colors[3])); } } return(Color.FromName(color)); }