Example #1
0
        public static void BluePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RantaColor rantaColor = (RantaColor)d;

            rantaColor.color = Color.FromRgb(rantaColor.Red, rantaColor.Green, rantaColor.Blue);

            rantaColor.brush = new SolidColorBrush(rantaColor.color);

            rantaColor.OnColorChanged();
        }
Example #2
0
        public static void RGBAPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RantaColor rantaColor = (RantaColor)d;

            var rgba  = rantaColor.RGBA.Split(',');
            var scale = 1.0f / (rantaColor.Scale > 0 ? rantaColor.Scale : 1.0f);

            if (rgba.Count() > 2)
            {
                byte r = (byte)(float.Parse(rgba[0]) * 255 * scale);
                byte g = (byte)(float.Parse(rgba[1]) * 255 * scale);
                byte b = (byte)(float.Parse(rgba[2]) * 255 * scale);
                rantaColor.color = Color.FromRgb(r, g, b);
            }
            else
            {
                rantaColor.color = Color.FromRgb(rantaColor.Red, rantaColor.Green, rantaColor.Blue);
            }

            rantaColor.brush = new SolidColorBrush(rantaColor.color);

            rantaColor.OnColorChanged();
        }