private void ConvertToRgba() { CurrentColor1 = CurrentColor1.ToColorSpace <Rgba>(); CurrentColor2 = CurrentColor2.ToColorSpace <Rgba>(); _updatingSliders = true; TextBlockLabelA1.Text = "R"; TextBlockLabelA2.Text = "R"; TextBlockLabelB1.Text = "G"; TextBlockLabelB2.Text = "G"; TextBlockLabelC1.Text = "B"; TextBlockLabelC2.Text = "B"; TextBlockLabelD1.Text = "A"; TextBlockLabelD2.Text = "A"; ConfigureSlider(ref SliderA1, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderA2, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderB1, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderB2, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderC1, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderC2, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderD1, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureSlider(ref SliderD2, 0.0, 255.0, 1.0, 16.0, 16.0); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}"); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}"); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}"); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}"); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}"); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}"); ConfigureBinding(ref SliderD1, ref TextBoxValueD1, "{0:F1}"); ConfigureBinding(ref SliderD2, ref TextBoxValueD2, "{0:F1}"); UpdateSliderValues(); }
private void ConvertToYxy() { CurrentColor1 = CurrentColor1.ToColorSpace <Yxy>(); CurrentColor2 = CurrentColor2.ToColorSpace <Yxy>(); _updatingSliders = true; TextBlockLabelA1.Text = "Y"; TextBlockLabelA2.Text = "Y"; TextBlockLabelB1.Text = "x"; TextBlockLabelB2.Text = "x"; TextBlockLabelC1.Text = "y"; TextBlockLabelC2.Text = "y"; ConfigureSlider(ref SliderA1, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderA2, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderB2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}%"); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}%"); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F3}"); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F3}"); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F3}"); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F3}"); UpdateSliderValues(); }
private void ConvertToLuv() { CurrentColor1 = CurrentColor1.ToColorSpace <Luv>(); CurrentColor2 = CurrentColor2.ToColorSpace <Luv>(); _updatingSliders = true; TextBlockLabelA1.Text = "L"; TextBlockLabelA2.Text = "L"; TextBlockLabelB1.Text = "u"; TextBlockLabelB2.Text = "u"; TextBlockLabelC1.Text = "v"; TextBlockLabelC2.Text = "v"; ConfigureSlider(ref SliderA1, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderA2, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB1, -134.0, 224.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB2, -134.0, 224.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderC1, -140.0, 122.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderC2, -140.0, 122.0, 1.0, 10.0, 10.0); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}%"); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}%"); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}"); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}"); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}"); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}"); UpdateSliderValues(); }
private void ConvertToLch() { CurrentColor1 = CurrentColor1.ToColorSpace <Lch>(); CurrentColor2 = CurrentColor2.ToColorSpace <Lch>(); _updatingSliders = true; TextBlockLabelA1.Text = "L"; TextBlockLabelA2.Text = "L"; TextBlockLabelB1.Text = "C"; TextBlockLabelB2.Text = "C"; TextBlockLabelC1.Text = "h"; TextBlockLabelC2.Text = "h"; ConfigureSlider(ref SliderA1, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderA2, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB1, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB2, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderC1, 0.0, 360.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderC2, 0.0, 360.0, 1.0, 10.0, 10.0); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}%"); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}%"); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}%"); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}%"); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}°", new DegreeConverter()); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}°", new DegreeConverter()); UpdateSliderValues(); }
private void ConvertToHunterLab() { CurrentColor1 = CurrentColor1.ToColorSpace <HunterLab>(); CurrentColor2 = CurrentColor2.ToColorSpace <HunterLab>(); _updatingSliders = true; TextBlockLabelA1.Text = "L"; TextBlockLabelA2.Text = "L"; TextBlockLabelB1.Text = "a"; TextBlockLabelB2.Text = "a"; TextBlockLabelC1.Text = "b"; TextBlockLabelC2.Text = "b"; ConfigureSlider(ref SliderA1, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderA2, 0.0, 100.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB1, -128.0, 128.0, 1.0, 8.0, 8.0); ConfigureSlider(ref SliderB2, -128.0, 128.0, 1.0, 8.0, 8.0); ConfigureSlider(ref SliderC1, -128.0, 128.0, 1.0, 8.0, 8.0); ConfigureSlider(ref SliderC2, -128.0, 128.0, 1.0, 8.0, 8.0); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}%"); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}%"); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}"); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}"); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}"); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}"); UpdateSliderValues(); }
private void ConvertToHsv() { CurrentColor1 = CurrentColor1.ToColorSpace <Hsv>(); CurrentColor2 = CurrentColor2.ToColorSpace <Hsv>(); _updatingSliders = true; TextBlockLabelA1.Text = "H"; TextBlockLabelA2.Text = "H"; TextBlockLabelB1.Text = "S"; TextBlockLabelB2.Text = "S"; TextBlockLabelC1.Text = "V"; TextBlockLabelC2.Text = "V"; ConfigureSlider(ref SliderA1, 0.0, 360.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderA2, 0.0, 360.0, 1.0, 10.0, 10.0); ConfigureSlider(ref SliderB1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderB2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}°", new DegreeConverter()); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}°", new DegreeConverter()); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}%", new PercentageConverter()); UpdateSliderValues(); }
private void ConvertToCmyk() { CurrentColor1 = CurrentColor1.ToColorSpace <Cmyk>(); CurrentColor2 = CurrentColor2.ToColorSpace <Cmyk>(); _updatingSliders = true; TextBlockLabelA1.Text = "C"; TextBlockLabelA2.Text = "C"; TextBlockLabelB1.Text = "M"; TextBlockLabelB2.Text = "M"; TextBlockLabelC1.Text = "Y"; TextBlockLabelC2.Text = "Y"; TextBlockLabelD1.Text = "K"; TextBlockLabelD2.Text = "K"; ConfigureSlider(ref SliderA1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderA2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderB1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderB2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderC2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderD1, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureSlider(ref SliderD2, 0.0, 1.0, 0.01, 0.1, 0.1); ConfigureBinding(ref SliderA1, ref TextBoxValueA1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderA2, ref TextBoxValueA2, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderB1, ref TextBoxValueB1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderB2, ref TextBoxValueB2, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderC1, ref TextBoxValueC1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderC2, ref TextBoxValueC2, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderD1, ref TextBoxValueD1, "{0:F1}%", new PercentageConverter()); ConfigureBinding(ref SliderD2, ref TextBoxValueD2, "{0:F1}%", new PercentageConverter()); UpdateSliderValues(); }
private void ButtonRandomize_Click(object sender, RoutedEventArgs e) { if (CurrentColor1.GetType() != CurrentColor2.GetType()) { throw new ApplicationException("Unexpected ColorSpace mismatch"); } if (CurrentColor1 is Cmy) { Randomize <Cmy>(); } else if (CurrentColor1 is Cmyk) { Randomize <Cmyk>(); } else if (CurrentColor1 is Hsl) { Randomize <Hsl>(); } else if (CurrentColor1 is Hsv) { Randomize <Hsv>(); } else if (CurrentColor1 is HunterLab) { Randomize <HunterLab>(); } else if (CurrentColor1 is Lab) { Randomize <Lab>(); } else if (CurrentColor1 is Lch) { Randomize <Lch>(); } else if (CurrentColor1 is Luv) { Randomize <Luv>(); } else if (CurrentColor1 is Rgb) { Randomize <Rgb>(); } else if (CurrentColor1 is Rgba) { Randomize <Rgba>(); } else if (CurrentColor1 is Xyz) { Randomize <Xyz>(); } else if (CurrentColor1 is Yxy) { Randomize <Yxy>(); } e.Handled = true; }
private void SliderA1_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (!_updatingSliders) { CurrentColor1[0] = e.NewValue; CurrentColor1 = CurrentColor1.Clone() as ColorSpace; if (!_isRandomMode || (_isRandomMode && SliderA1.Value > SliderA2.Value)) { SliderA2.Value = SliderA1.Value; } } e.Handled = true; }