private void ctlAlphaSelect_AlphaChanged(byte newAlpha) { m_selectedColor.A = newAlpha; HexValue.Text = ColorSpace.GetHexCode(m_selectedColor); ((SolidColorBrush)SelectedColor.Fill).Color = m_selectedColor; if (ColorSelected != null) { ColorSelected(this, new RoutedEventArgs()); } SetValue(ColorpPoperty, m_selectedColor); }
private void HexValue_TextChanged(object sender, TextChangedEventArgs e) { string text = HexValue.Text; if (text == ColorSpace.GetHexCode(m_selectedColor)) { return; } byte a, r, g, b; if (!GetArgb(text, out a, out r, out g, out b)) { return; // invalid color } UpdateOnColorChanged(a, r, g, b); }
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); }