diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs index ce9b8f48..aa87a36f 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs @@ -13,7 +13,6 @@ namespace Microsoft.Windows.Controls { #region Members - //private ToggleButton _colorPickerToggleButton; private Popup _colorPickerCanvasPopup; private ListBox _availableColors; private ListBox _standardColors; @@ -45,29 +44,6 @@ namespace Microsoft.Windows.Controls #endregion //ButtonStyle - #region DisplayAvailableColors - - public static readonly DependencyProperty DisplayAvailableColorsProperty = DependencyProperty.Register("DisplayAvailableColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true, OnDisplayAvailableColorsChanged)); - public bool DisplayAvailableColors - { - get { return (bool)GetValue(DisplayAvailableColorsProperty); } - set { SetValue(DisplayAvailableColorsProperty, value); } - } - - private static void OnDisplayAvailableColorsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ColorPicker colorPicker = o as ColorPicker; - if (colorPicker != null) - colorPicker.OnDisplayAvailableColorsChanged((bool)e.OldValue, (bool)e.NewValue); - } - - protected virtual void OnDisplayAvailableColorsChanged(bool oldValue, bool newValue) - { - // TODO: Add your property changed side-effects. Descendants can override as well. - } - - #endregion //DisplayAvailableColors - #region DisplayColorAndName public static readonly DependencyProperty DisplayColorAndNameProperty = DependencyProperty.Register("DisplayColorAndName", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false)); @@ -79,52 +55,6 @@ namespace Microsoft.Windows.Controls #endregion //DisplayColorAndName - #region DisplayRecentColors - - public static readonly DependencyProperty DisplayRecentColorsProperty = DependencyProperty.Register("DisplayRecentColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true, OnDisplayRecentColorsChanged)); - public bool DisplayRecentColors - { - get { return (bool)GetValue(DisplayRecentColorsProperty); } - set { SetValue(DisplayRecentColorsProperty, value); } - } - - private static void OnDisplayRecentColorsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ColorPicker colorPicker = o as ColorPicker; - if (colorPicker != null) - colorPicker.OnDisplayRecentColorsChanged((bool)e.OldValue, (bool)e.NewValue); - } - - protected virtual void OnDisplayRecentColorsChanged(bool oldValue, bool newValue) - { - // TODO: Add your property changed side-effects. Descendants can override as well. - } - - #endregion //DisplayRecentColors - - #region DisplayStandardColors - - public static readonly DependencyProperty DisplayStandardColorsProperty = DependencyProperty.Register("DisplayStandardColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true, OnDisplayStandardColorsChanged)); - public bool DisplayStandardColors - { - get { return (bool)GetValue(DisplayStandardColorsProperty); } - set { SetValue(DisplayStandardColorsProperty, value); } - } - - private static void OnDisplayStandardColorsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) - { - ColorPicker colorPicker = o as ColorPicker; - if (colorPicker != null) - colorPicker.OnDisplayStandardColorsChanged((bool)e.OldValue, (bool)e.NewValue); - } - - protected virtual void OnDisplayStandardColorsChanged(bool oldValue, bool newValue) - { - // TODO: Add your property changed side-effects. Descendants can override as well. - } - - #endregion //DisplayStandardColors - #region IsOpen public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false)); @@ -185,6 +115,50 @@ namespace Microsoft.Windows.Controls #endregion //SelectedColorText + #region ShowAdvancedButton + + public static readonly DependencyProperty ShowAdvancedButtonProperty = DependencyProperty.Register("ShowAdvancedButton", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true)); + public bool ShowAdvancedButton + { + get { return (bool)GetValue(ShowAdvancedButtonProperty); } + set { SetValue(ShowAdvancedButtonProperty, value); } + } + + #endregion //ShowAdvancedButton + + #region ShowAvailableColors + + public static readonly DependencyProperty ShowAvailableColorsProperty = DependencyProperty.Register("ShowAvailableColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true)); + public bool ShowAvailableColors + { + get { return (bool)GetValue(ShowAvailableColorsProperty); } + set { SetValue(ShowAvailableColorsProperty, value); } + } + + #endregion //ShowAvailableColors + + #region ShowRecentColors + + public static readonly DependencyProperty ShowRecentColorsProperty = DependencyProperty.Register("ShowRecentColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false)); + public bool ShowRecentColors + { + get { return (bool)GetValue(ShowRecentColorsProperty); } + set { SetValue(ShowRecentColorsProperty, value); } + } + + #endregion //DisplayRecentColors + + #region ShowStandardColors + + public static readonly DependencyProperty ShowStandardColorsProperty = DependencyProperty.Register("ShowStandardColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true)); + public bool ShowStandardColors + { + get { return (bool)GetValue(ShowStandardColorsProperty); } + set { SetValue(ShowStandardColorsProperty, value); } + } + + #endregion //DisplayStandardColors + #region StandardColors public static readonly DependencyProperty StandardColorsProperty = DependencyProperty.Register("StandardColors", typeof(ObservableCollection), typeof(ColorPicker), new UIPropertyMetadata(CreateStandardColors())); @@ -220,10 +194,8 @@ namespace Microsoft.Windows.Controls { base.OnApplyTemplate(); - //_colorPickerToggleButton = (ToggleButton)GetTemplateChild("PART_ColorPickerToggleButton"); - _colorPickerCanvasPopup = (Popup)GetTemplateChild("PART_ColorPickerPalettePopup"); - _colorPickerCanvasPopup.Opened += ColorPickerCanvasPopup_Opened; + //_colorPickerCanvasPopup.Opened += ColorPickerCanvasPopup_Opened; _availableColors = (ListBox)GetTemplateChild("PART_AvailableColors"); _availableColors.SelectionChanged += Color_SelectionChanged; @@ -241,7 +213,7 @@ namespace Microsoft.Windows.Controls void ColorPickerCanvasPopup_Opened(object sender, EventArgs e) { - Mouse.Capture(this, CaptureMode.SubTree); + } private void OnKeyDown(object sender, KeyEventArgs e) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml index 7c2af261..96e1f751 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml @@ -15,6 +15,7 @@ + @@ -102,7 +103,13 @@ - + + + @@ -115,41 +122,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -173,8 +146,10 @@ - - + + @@ -186,79 +161,97 @@ - + - + - - + - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - + + + + + + + - - - - - - - - - - + + + + + + + + - - - - - - + + + + + + + - - - - - - - - - - + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + @@ -268,6 +261,11 @@ + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs index 9d5364ce..cb2d7c18 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs @@ -13,7 +13,12 @@ namespace Microsoft.Windows.Controls.Core.Utilities public static string GetColorName(this Color color) { - return KnownColors.Where(kvp => kvp.Value.Equals(color)).Select(kvp => kvp.Key).FirstOrDefault(); + string colorName = KnownColors.Where(kvp => kvp.Value.Equals(color)).Select(kvp => kvp.Key).FirstOrDefault(); + + if (String.IsNullOrEmpty(colorName)) + colorName = color.ToString(); + + return colorName; } private static Dictionary GetKnownColors()