public InternalColor(InternalColor c) { this.h = c.h; this.s = c.s; this.v = c.v; this.a = c.a; }
public void UpdateUI() { ChangeModule(); ChangeDescriptions(); UpdaterdFader(); UpdatectxOptions(); UpdatetbValue(null); _module.XYZ = InternalColor; lblColorOut.Color = lblColorOut.OldColor = InternalColor.ToRGB(); }
private void UpdatetbValue(TextBox skipupdate) { #region hsv textboxes HSV chsv = HSV.FromRGB(InternalColor.ToRGB()); if (skipupdate != tbHSV_H) { tbHSV_H.Text = (chsv.H * 360.0).ToString("0"); } if (skipupdate != tbHSV_S) { tbHSV_S.Text = (chsv.S * 100.0).ToString("0"); } if (skipupdate != tbHSV_V) { tbHSV_V.Text = (chsv.V * 100.0).ToString("0"); } #endregion #region secondary textboxes if (_mode == Mode.HSV_RGB) { RGB crgb = InternalColor.ToRGB(); if (skipupdate != tbSecond_1) { tbSecond_1.Text = (crgb.R * 255.0).ToString("0"); } if (skipupdate != tbSecond_2) { tbSecond_2.Text = (crgb.G * 255.0).ToString("0"); } if (skipupdate != tbSecond_3) { tbSecond_3.Text = (crgb.B * 255.0).ToString("0"); } } else //(_mode==Mode.HSV_LAB) { LAB clab = LAB.FromXYZ(InternalColor); if (skipupdate != tbSecond_1) { tbSecond_1.Text = clab.L.ToString("0"); } if (skipupdate != tbSecond_2) { tbSecond_2.Text = clab.a.ToString("0"); } if (skipupdate != tbSecond_3) { tbSecond_3.Text = clab.b.ToString("0"); } } #endregion }
private void UpdateSelectedColorFromSliderValue() { Color tmp; switch (_primAttrib) { default: _selColor.H = colorSlider.ValuePercentual; break; case PrimaryAttrib.Saturation: _selColor.S = colorSlider.ValuePercentual; break; case PrimaryAttrib.Brightness: _selColor.V = colorSlider.ValuePercentual; break; case PrimaryAttrib.Red: tmp = _selColor.ToColor(); _selColor = new InternalColor(Color.FromArgb( tmp.A, (int)Math.Round(colorSlider.ValuePercentual * 255.0f), tmp.G, tmp.B)); break; case PrimaryAttrib.Green: tmp = _selColor.ToColor(); _selColor = new InternalColor(Color.FromArgb( tmp.A, tmp.R, (int)Math.Round(colorSlider.ValuePercentual * 255.0f), tmp.B)); break; case PrimaryAttrib.Blue: tmp = _selColor.ToColor(); _selColor = new InternalColor(Color.FromArgb( tmp.A, tmp.R, tmp.G, (int)Math.Round(colorSlider.ValuePercentual * 255.0f))); break; } if (ColorChanged != null) { ColorChanged(this, EventArgs.Empty); } }
private void UpdateSelectedColorFromPanelValue() { Color tmp; switch (this.primAttrib) { default: case PrimaryAttrib.Hue: this.selColor.s = this.colorPanel.ValuePercentual.X; this.selColor.v = this.colorPanel.ValuePercentual.Y; break; case PrimaryAttrib.Saturation: this.selColor.h = this.colorPanel.ValuePercentual.X; this.selColor.v = this.colorPanel.ValuePercentual.Y; break; case PrimaryAttrib.Brightness: this.selColor.h = this.colorPanel.ValuePercentual.X; this.selColor.s = this.colorPanel.ValuePercentual.Y; break; case PrimaryAttrib.Red: tmp = this.selColor.ToColor(); this.selColor = new InternalColor(Color.FromArgb( tmp.A, tmp.R, (int)Math.Round(this.colorPanel.ValuePercentual.Y * 255.0f), (int)Math.Round(this.colorPanel.ValuePercentual.X * 255.0f))); break; case PrimaryAttrib.Green: tmp = this.selColor.ToColor(); this.selColor = new InternalColor(Color.FromArgb( tmp.A, (int)Math.Round(this.colorPanel.ValuePercentual.Y * 255.0f), tmp.G, (int)Math.Round(this.colorPanel.ValuePercentual.X * 255.0f))); break; case PrimaryAttrib.Blue: tmp = this.selColor.ToColor(); this.selColor = new InternalColor(Color.FromArgb( tmp.A, (int)Math.Round(this.colorPanel.ValuePercentual.Y * 255.0f), (int)Math.Round(this.colorPanel.ValuePercentual.X * 255.0f), tmp.B)); break; } this.OnColorEdited(); }
private void numAlpha_ValueChanged(object sender, EventArgs e) { if (this.suspendTextEvents) { return; } Color tmp = this.selColor.ToColor(); this.selColor = new InternalColor(Color.FromArgb( (byte)this.numAlpha.Value, tmp.R, tmp.G, tmp.B)); this.UpdateColorControls(); }
private void textBoxHex_TextChanged(object sender, EventArgs e) { if (this.suspendTextEvents) { return; } int argb; if (int.TryParse(this.textBoxHex.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.CurrentUICulture, out argb)) { Color tmp = Color.FromArgb(argb); this.selColor = new InternalColor(tmp); this.UpdateColorControls(); } }
private void numAlpha_ValueChanged(object sender, EventArgs e) { if (_suspendTextEvents) { return; } Color tmp = _selColor.ToColor(); _selColor = new InternalColor(Color.FromArgb( (byte)numAlpha.Value, tmp.R, tmp.G, tmp.B)); UpdateColorControls(); if (ColorChanged != null) { ColorChanged(this, EventArgs.Empty); } }
private void textBoxHex_TextChanged(object sender, EventArgs e) { if (_suspendTextEvents) { return; } int argb; if (!int.TryParse(textBoxHex.Text, NumberStyles.HexNumber, CultureInfo.CurrentUICulture, out argb)) { return; } Color tmp = Color.FromArgb(argb); _selColor = new InternalColor(tmp); UpdateColorControls(); if (ColorChanged != null) { ColorChanged(this, EventArgs.Empty); } }
private void blueButton_Click(object sender, EventArgs e) { InternalColor = XYZ.FromRGB(new RGB(0, 0, 255)); lblColorOut.Color = InternalColor.ToRGB(); UpdatetbValue(null); }
private void tbValue_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (!(sender is TextBox)) { return; } if (e.KeyCode == Keys.Return) { UpdatetbValue(null); e.Handled = true; return; } double value; if (!double.TryParse(((TextBox)sender).Text, System.Globalization.NumberStyles.Integer, null, out value)) { return; } #region hsv textboxes if (sender == tbHSV_H) { HSV chsv = HSV.FromRGB(InternalColor.ToRGB()); chsv.H = value / 360.0; InternalColor = XYZ.FromRGB(chsv.ToRGB()); } else if (sender == tbHSV_S) { HSV chsv = HSV.FromRGB(InternalColor.ToRGB()); chsv.S = value / 100.0; InternalColor = XYZ.FromRGB(chsv.ToRGB()); } else if (sender == tbHSV_V) { HSV chsv = HSV.FromRGB(InternalColor.ToRGB()); chsv.V = value / 100.0; InternalColor = XYZ.FromRGB(chsv.ToRGB()); } #endregion #region secondary textboxes else if (_mode == Mode.HSV_RGB) { RGB crgb = InternalColor.ToRGB(); if (sender == tbSecond_1) { crgb.R = value / 255.0; } else if (sender == tbSecond_2) { crgb.G = value / 255.0; } else //sender==tbSecond_3 { crgb.B = value / 255.0; } InternalColor = XYZ.FromRGB(crgb); } else if (_mode == Mode.HSV_LAB) { LAB clab = LAB.FromXYZ(InternalColor); if (sender == tbSecond_1) { clab.L = value; } else if (sender == tbSecond_2) { clab.a = value; } else //sender==tbSecond_3 { clab.b = value; } InternalColor = clab.ToXYZ(); } #endregion //update ui _module.XYZ = InternalColor; lblColorOut.Color = InternalColor.ToRGB(); UpdatetbValue((TextBox)sender); }
protected override void OnShown(EventArgs e) { base.OnShown(e); this.selColor = this.oldColor; this.UpdateColorControls(); }
private void colorShowBox_UpperClick(object sender, EventArgs e) { this.selColor = this.oldColor; this.UpdateColorControls(); }
private void numAlpha_ValueChanged(object sender, EventArgs e) { if (this.suspendTextEvents) return; Color tmp = this.selColor.ToColor(); this.selColor = new InternalColor(Color.FromArgb( (byte)this.numAlpha.Value, tmp.R, tmp.G, tmp.B)); this.UpdateColorControls(); }
private void textBoxHex_TextChanged(object sender, EventArgs e) { if (this.suspendTextEvents) return; int argb; if (int.TryParse(this.textBoxHex.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.CurrentUICulture, out argb)) { Color tmp = Color.FromArgb(argb); this.selColor = new InternalColor(tmp); this.UpdateColorControls(); } }