Пример #1
0
        private void UpdateControls()
        {
            // Prevent infinite loops
            if (_ignoreUpdates)
            {
                return;
            }
            _ignoreUpdates = true;
            if (_hsl)
            {
                // Don't use the colors directly, here mainly because saturation
                // loses information when going back and forth from a color.
                if (_startHue != _endHue)
                {
                    sldHue.Inverted = _startHue > _endHue;
                }

                sldHue.LeftValue  = _startHue;
                sldHue.RightValue = _endHue;
                if (_startSat != _endSat)
                {
                    sldSaturation.Inverted = _startSat > _endSat;
                }

                sldSaturation.LeftValue  = _startSat;
                sldSaturation.RightValue = _endSat;

                if (_startLight != _endLight)
                {
                    sldLightness.Inverted = _startLight > _endLight;
                }
                sldLightness.LeftValue  = _startLight;
                sldLightness.RightValue = _endLight;
            }
            else
            {
                sldHue.SetRange(_startColor, _endColor);
                sldSaturation.SetSaturation(_startColor, _endColor);
                sldLightness.SetLightness(_startColor, _endColor);

                sldHue.HueShift    = _hueShift;
                cbStartColor.Color = _startColor;
                cbEndColor.Color   = _endColor;
            }

            tabColorRange.SelectedTab = _hsl ? tabHSL : tabRGB;
            _ignoreUpdates            = false;
            OnColorChanged();
        }