コード例 #1
0
        /// <summary>
        /// 当 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" /> 属性更改时,更新 <see cref="T:System.Windows.Controls.Slider" /> 的当前位置。
        /// </summary>
        /// <param name="oldValue"><see cref="T:System.Windows.Controls.Slider" /> 的旧 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" />。</param>
        /// <param name="newValue"><see cref="T:System.Windows.Controls.Slider" /> 的新 <see cref="P:System.Windows.Controls.Primitives.RangeBase.Value" />。</param>
        protected override void OnValueChanged(double oldValue, double newValue)
        {
            base.OnValueChanged(oldValue, newValue);

            Color color = ColorUtilities.ConvertHsvToRgb(360 - newValue, 1, 1);

            SelectedColor = color;
        }
コード例 #2
0
ファイル: ColorUtilities.cs プロジェクト: candyzkn/WPF
        /// <summary>
        /// Generates a list of colors with hues ranging from 0 360 and a saturation and value of 1.
        /// </summary>
        /// <returns>List&lt;Color&gt;.</returns>
        public static List <Color> GenerateHsvSpectrum()
        {
            List <Color> colorsList = new List <Color>(8);

            for (int i = 0; i < 29; i++)
            {
                colorsList.Add(ColorUtilities.ConvertHsvToRgb(i * 12, 1, 1));
            }

            colorsList.Add(ColorUtilities.ConvertHsvToRgb(0, 1, 1));

            return(colorsList);
        }
コード例 #3
0
        /// <summary>
        /// Calculates the color.
        /// </summary>
        /// <param name="p">The p.</param>
        private void CalculateColor(Point p)
        {
            HsvColor hsv = new HsvColor(360 - _spectrumSlider.Value, 1, 1)
            {
                S = p.X,
                V = 1 - p.Y
            };
            var currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V);

            currentColor.A = A;
            SelectedColor  = currentColor;
            SetHexadecimalStringProperty(GetFormatedColorString(SelectedColor), false);
        }