Browse Source

ColorCanvas: refactored and eliminated some redundant code.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
366e02a044
  1. 24
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorCanvas.cs

24
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorCanvas.cs

@ -42,6 +42,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnSelectedColorChanged(Color oldValue, Color newValue) protected virtual void OnSelectedColorChanged(Color oldValue, Color newValue)
{ {
HexadecimalString = newValue.ToString();
UpdateRGBValues(newValue); UpdateRGBValues(newValue);
UpdateColorShadeSelectorPosition(newValue); UpdateColorShadeSelectorPosition(newValue);
} }
@ -69,7 +70,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnAChanged(byte oldValue, byte newValue) protected virtual void OnAChanged(byte oldValue, byte newValue)
{ {
if (!_surpressPropertyChanged) if (!_surpressPropertyChanged)
UpdateRGBColor(); UpdateSelectedColor();
} }
#endregion //A #endregion //A
@ -93,7 +94,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnRChanged(byte oldValue, byte newValue) protected virtual void OnRChanged(byte oldValue, byte newValue)
{ {
if (!_surpressPropertyChanged) if (!_surpressPropertyChanged)
UpdateRGBColor(); UpdateSelectedColor();
} }
#endregion //R #endregion //R
@ -117,7 +118,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnGChanged(byte oldValue, byte newValue) protected virtual void OnGChanged(byte oldValue, byte newValue)
{ {
if (!_surpressPropertyChanged) if (!_surpressPropertyChanged)
UpdateRGBColor(); UpdateSelectedColor();
} }
#endregion //G #endregion //G
@ -141,7 +142,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnBChanged(byte oldValue, byte newValue) protected virtual void OnBChanged(byte oldValue, byte newValue)
{ {
if (!_surpressPropertyChanged) if (!_surpressPropertyChanged)
UpdateRGBColor(); UpdateSelectedColor();
} }
#endregion //B #endregion //B
@ -167,9 +168,7 @@ namespace Microsoft.Windows.Controls
protected virtual void OnHexadecimalStringChanged(string oldValue, string newValue) protected virtual void OnHexadecimalStringChanged(string oldValue, string newValue)
{ {
if (!SelectedColor.ToString().Equals(newValue)) if (!SelectedColor.ToString().Equals(newValue))
{ UpdateSelectedColor((Color)ColorConverter.ConvertFromString(newValue));
SetSelectedColorAndPositionSelector((Color)ColorConverter.ConvertFromString(newValue));
}
} }
#endregion //HexadecimalString #endregion //HexadecimalString
@ -269,11 +268,9 @@ namespace Microsoft.Windows.Controls
#region Methods #region Methods
private void UpdateRGBColor() private void UpdateSelectedColor()
{ {
SelectedColor = Color.FromArgb(A, R, G, B); SelectedColor = Color.FromArgb(A, R, G, B);
UpdateColorShadeSelectorPosition(SelectedColor);
HexadecimalString = SelectedColor.ToString();
} }
private void UpdateSelectedColor(Color color) private void UpdateSelectedColor(Color color)
@ -293,13 +290,6 @@ namespace Microsoft.Windows.Controls
_surpressPropertyChanged = false; _surpressPropertyChanged = false;
} }
private void SetSelectedColorAndPositionSelector(Color color)
{
UpdateSelectedColor(color);
UpdateRGBValues(color);
UpdateColorShadeSelectorPosition(color);
}
private void UpdateColorShadeSelectorPositionAndCalculateColor(Point p, bool calculateColor) private void UpdateColorShadeSelectorPositionAndCalculateColor(Point p, bool calculateColor)
{ {
if (p.Y < 0) if (p.Y < 0)

Loading…
Cancel
Save