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());
            }
        }
        private void UpdateSample(double xPos, double yPos)
        {
            SampleSelector.Margin = new Thickness(xPos - (SampleSelector.Height / 2), yPos - (SampleSelector.Height / 2), 0, 0);

            float yComponent = 1 - (float)(yPos / rectSample.ActualHeight);
            float xComponent = (float)(xPos / rectSample.ActualWidth);

            byte a = m_selectedColor.A;

            m_selectedColor   = ColorSpace.ConvertHsvToRgb((float)m_selectedHue, xComponent, yComponent);
            m_selectedColor.A = a;
            ((SolidColorBrush)SelectedColor.Fill).Color = m_selectedColor;
            HexValue.Text = ColorSpace.GetHexCode(m_selectedColor);

            ctlAlphaSelect.DisplayColor = m_selectedColor;
            if (ColorSelected != null)
            {
                ColorSelected(this, new RoutedEventArgs());
            }

            SetValue(ColorpPoperty, m_selectedColor);
        }