Example #1
0
        /// <summary>
        /// Set the current color.
        /// </summary>
        /// <param name="color">The color.</param>
        private void SetColor(WColor?color)
        {
            color ??= default;

            var z = color.Value;

            Color = z;

            _customColorSwatch.CurrentColor = z;

            _isSettingValues = true;

            _rSlider._slider.Value = z.R;
            _gSlider._slider.Value = z.G;
            _bSlider._slider.Value = z.B;
            _aSlider._slider.Value = z.A;
            _sSlider._slider.Value = z.GetSaturation();
            _lSlider._slider.Value = z.GetBrightness();
            _hSlider._slider.Value = z.GetHue();

            _colorDisplayBorder.Background = new SolidColorBrush(z);

            _isSettingValues = false;
            PickingColor?.Invoke(z);
        }
Example #2
0
        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is Border border))
            {
                e.Handled = true;
                return;
            }

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

                if (border.DataContext is ColorSwatchItem data)
                {
                    data.Color     = CurrentColor;
                    data.HexString = CurrentColor.ToHexString();
                }

                if (!(ColorPickerControl is null))
                {
                    ColorPickerControl.CustomColorsChanged();
                }
            }
            else
            {
                PickingColor?.Invoke(((SolidColorBrush)border.Background).Color);
            }
        }