private void UIElement_Click(object sender, RoutedEventArgs e)
        {
            var button = (sender as Button);

            if (button == null)
            {
                return;
            }

            if (Editable && Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                button.Background = new SolidColorBrush(CurrentColor);

                var data = button.DataContext as ColorItem;
                if (data != null)
                {
                    data.Color = CurrentColor;
                    data.Hex   = CurrentColor.ToString();
                }

                if (ColorPickerCntrl != null)
                {
                    CustomColorsChanged();
                }
            }
            else
            {
                var color = button.Background as SolidColorBrush;
                OnPickColor?.Invoke(color.Color);
                MessageBox.Show("SelectedColor: " + color.ToString());;
            }
        }
示例#2
0
        private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            var border = (sender as Border);

            if (border == null)
            {
                return;
            }

            if (Editable && Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                border.Background = new SolidColorBrush(CurrentColor);

                var data = border.DataContext as ColorSwatchItem;
                if (data != null)
                {
                    data.Color     = CurrentColor;
                    data.HexString = CurrentColor.ToHexString();
                }

                //if (ColorPickerControl != null)
                //{
                //    ColorPickerControl.CustomColorsChanged();
                //}
            }
            else
            {
                var color = border.Background as SolidColorBrush;
                OnPickColor?.Invoke(color.Color);
            }
        }
示例#3
0
        public void SetColor(Color color)
        {
            Color = color;


            IsSettingValues = true;

            RSlider.Slider.Value = Color.R;
            GSlider.Slider.Value = Color.G;
            BSlider.Slider.Value = Color.B;
            ASlider.Slider.Value = Color.A;

            SSlider.Slider.Value = Color.GetSaturation();
            LSlider.Slider.Value = Color.GetBrightness();
            HSlider.Slider.Value = Color.GetHue();

            string colorHex = Color.ToString().Remove(1, 2);

            hexCode.Text = colorHex;

            ColorDisplayBorder.Background = new SolidColorBrush(Color);

            IsSettingValues = false;
            OnPickColor?.Invoke(color);
        }
示例#4
0
        public void updateSelectedColor()
        {
            Color color = Color.FromRgb(System.Convert.ToByte(red), System.Convert.ToByte(green), System.Convert.ToByte(blue));

            ColorRectangle.Fill = new SolidColorBrush(color);
            CurrentColor        = color;
            OnPickColor?.Invoke(color);
        }
示例#5
0
 public void SetColor(Color color)
 {
     mainColor             = color;
     RSlider.Slider.Value  = mainColor.R;
     GSlider.Slider.Value  = mainColor.G;
     BSlider.Slider.Value  = mainColor.B;
     TestBorder.Background = new SolidColorBrush(mainColor);
     OnPickColor?.Invoke(color);
 }
示例#6
0
        public void SetColor(Color color)
        {
            Color = color;

            IsSettingValues = true;

            RSlider.Slider.Value = Color.R;
            GSlider.Slider.Value = Color.G;
            BSlider.Slider.Value = Color.B;
            ASlider.Slider.Value = Color.A;

            SSlider.Slider.Value = Color.GetSaturation();
            LSlider.Slider.Value = Color.GetBrightness();
            HSlider.Slider.Value = Color.GetHue();

            ColorDisplayBorder.Background = new SolidColorBrush(Color);

            IsSettingValues = false;
            OnPickColor?.Invoke(color);
        }
示例#7
0
 public void SetColor(Color color)
 {
     IsSettingValues         = true;
     ResultColor             = color;
     RSlider.Value           = ResultColor.R;
     GSlider.Value           = ResultColor.G;
     BSlider.Value           = ResultColor.B;
     ASlider.Value           = ResultColor.A;
     Alpha10.Text            = ResultColor.A.ToString();
     Alpha16.Text            = ResultColor.A.ToString("X");
     Red10.Text              = ResultColor.R.ToString();
     Red16.Text              = ResultColor.R.ToString("X");
     Green10.Text            = ResultColor.G.ToString();
     Green16.Text            = ResultColor.G.ToString("X");
     Blue10.Text             = ResultColor.B.ToString();
     Blue16.Text             = ResultColor.B.ToString("X");
     ColorDisplayBorder.Fill = new SolidColorBrush(ResultColor);
     ARGBLabel.Content       = "ARGB(" + ResultColor.A + "," + ResultColor.R + "," + ResultColor.G + "," + ResultColor.B + ")";
     ColorCode.Content       = ResultColor.ToString();
     IsSettingValues         = false;
     OnPickColor?.Invoke(color);
 }
        public void SetColor(Color color)
        {
            Color = color;

            IsSettingValues = true;

            RSlider.Slider.Value  = Color.R;
            RSlider.Label.Content = "Red";
            GSlider.Slider.Value  = Color.G;
            GSlider.Label.Content = "Green";
            BSlider.Slider.Value  = Color.B;
            BSlider.Label.Content = "Blue";

            SSlider.Slider.Value          = Color.GetSaturation();
            SSlider.Label.Content         = "Saturation";
            LSlider.Slider.Value          = Color.GetBrightness();
            LSlider.Label.Content         = "Brightness";
            HSlider.Slider.Value          = Color.GetHue();
            HSlider.Label.Content         = "Hue";
            ColorDisplayBorder.Background = new System.Windows.Media.SolidColorBrush(MColor.FromRgb(Color.R, Color.G, Color.B));

            IsSettingValues = false;
            OnPickColor?.Invoke(color);
        }
示例#9
0
 private void Swatch_OnOnPickColor(Color color)
 {
     SetColor(color);
     OnPickColor?.Invoke(color);
 }