Ejemplo n.º 1
0
        private void UpdateSelection(int yPos)
        {
            int   huePos        = (int)(yPos / rectHueMonitor.ActualHeight * 255);
            int   gradientStops = 6;
            Color c             = ColorSpace.GetColorFromPosition(huePos * gradientStops);

            rectSample.Fill    = new SolidColorBrush(c);
            HueSelector.Margin = new Thickness(0, yPos - (HueSelector.ActualHeight / 2), 0, 0);
            m_selectedHue      = (float)(yPos / rectHueMonitor.ActualHeight) * 360;
            UpdateSample(m_sampleX, m_sampleY);
        }
Ejemplo n.º 2
0
        private void UpdateOnColorChanged(byte a, byte r, byte g, byte b)
        {
            m_selectedColor.A = a;
            m_selectedColor.R = r;
            m_selectedColor.G = g;
            m_selectedColor.B = b;

            double h, s, v;

            ColorSpace.ConvertRgbToHsv(r / 255.0, g / 255.0, b / 255.0, out h, out s, out v);

            // update selected color
            SelectedColor.Fill = new SolidColorBrush(m_selectedColor);

            // update Saturation and Value locator
            double xPos = s * rectSample.ActualWidth;
            double yPos = (1 - v) * rectSample.ActualHeight;

            m_sampleX             = xPos;
            m_sampleY             = yPos;
            SampleSelector.Margin = new Thickness(xPos - (SampleSelector.Height / 2), yPos - (SampleSelector.Height / 2), 0, 0);

            m_selectedHue = (float)h;
            h            /= 360;
            const int gradientStops = 6;

            rectSample.Fill = new SolidColorBrush(ColorSpace.GetColorFromPosition(((int)(h * 255)) * gradientStops));

            // Update Hue locator
            HueSelector.Margin = new Thickness(0, (h * rectHueMonitor.ActualHeight) - (HueSelector.ActualHeight / 2), 0, 0);

            // update alpha selector
            ctlAlphaSelect.DisplayColor = m_selectedColor;

            if (ColorSelected != null)
            {
                ColorSelected(this, new RoutedEventArgs());
            }
        }