コード例 #1
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);
            }
        }
コード例 #2
0
        private static void OnColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ColorPickerControl ColorPickerControl = o as ColorPickerControl;

            if (ColorPickerControl != null)
            {
                ColorPickerControl.OnColorChanged((Color)e.OldValue, (Color)e.NewValue);
            }
        }
コード例 #3
0
        private static object OnCoerceColor(DependencyObject o, object value)
        {
            ColorPickerControl ColorPickerControl = o as ColorPickerControl;

            if (ColorPickerControl != null)
            {
                return(ColorPickerControl.OnCoerceColor((Color)value));
            }
            else
            {
                return(value);
            }
        }