FirstFloor.ModernUI.Windows.Controls.ColorPickerPanel.ThumbMoved C# (CSharp) Method

ThumbMoved() private method

private ThumbMoved ( ) : void
return void
        private void ThumbMoved() {
            if (_palette == null) return;

            var position = Mouse.GetPosition(_palette);
            var x = position.X / _palette.ActualWidth;
            var y = 1 - position.Y / _palette.ActualHeight;

            switch (Mode) {
                case ColorPickingMode.Hue:
                    Saturation = (int)(100d * x);
                    Brightness = (int)(100d * y);
                    break;

                case ColorPickingMode.Saturation:
                    Hue = (int)(359d * x);
                    Brightness = (int)(100d * y);
                    break;

                case ColorPickingMode.Brightness:
                    Hue = (int)(359d * x);
                    Saturation = (int)(100d * y);
                    break;

                case ColorPickingMode.Red:
                    Blue = (int)(255d * x);
                    Green = (int)(255d * y);
                    break;

                case ColorPickingMode.Green:
                    Blue = (int)(255d * x);
                    Red = (int)(255d * y);
                    break;

                case ColorPickingMode.Blue:
                    Red = (int)(255d * x);
                    Green = (int)(255d * y);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            UpdateThumbPosition();
        }