diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs
index 76bddff8ef..9e456dfef6 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs
@@ -4,51 +4,56 @@
namespace Microsoft.PowerToys.Settings.UI.Library.Enumerations
{
+ // NOTE: don't change the order (numbers) of the enumeration entires
+
+ ///
+ /// The type of the color representation
+ ///
public enum ColorRepresentationType
{
- ///
- /// Color presentation as CMYK color value (cyan[0%..100%], magenta[0%..100%], yellow[0%..100%], black key[0%..100%])
- ///
- CMYK = 0,
-
///
/// Color presentation as hexadecimal color value without the alpha-value (e.g. #0055FF)
///
- HEX = 1,
-
- ///
- /// Color presentation as HSB color value (hue[0°..360°], saturation[0%..100%], brightness[0%..100%])
- ///
- HSB = 2,
-
- ///
- /// Color presentation as HSI color value (hue[0°..360°], saturation[0%..100%], intensity[0%..100%])
- ///
- HSI = 3,
-
- ///
- /// Color presentation as HSL color value (hue[0°..360°], saturation[0..100%], lightness[0%..100%])
- ///
- HSL = 4,
-
- ///
- /// Color presentation as HSV color value (hue[0°..360°], saturation[0%..100%], value[0%..100%])
- ///
- HSV = 5,
-
- ///
- /// Color presentation as HWB color value (hue[0°..360°], whiteness[0%..100%], blackness[0%..100%])
- ///
- HWB = 6,
-
- ///
- /// Color presentation as natural color (hue, whiteness[0%..100%], blackness[0%..100%])
- ///
- NCol = 7,
+ HEX = 0,
///
/// Color presentation as RGB color value (red[0..255], green[0..255], blue[0..255])
///
- RGB = 8,
+ RGB = 1,
+
+ ///
+ /// Color presentation as CMYK color value (cyan[0%..100%], magenta[0%..100%], yellow[0%..100%], black key[0%..100%])
+ ///
+ CMYK = 2,
+
+ ///
+ /// Color presentation as HSL color value (hue[0°..360°], saturation[0..100%], lightness[0%..100%])
+ ///
+ HSL = 3,
+
+ ///
+ /// Color presentation as HSV color value (hue[0°..360°], saturation[0%..100%], value[0%..100%])
+ ///
+ HSV = 4,
+
+ ///
+ /// Color presentation as HSB color value (hue[0°..360°], saturation[0%..100%], brightness[0%..100%])
+ ///
+ HSB = 5,
+
+ ///
+ /// Color presentation as HSI color value (hue[0°..360°], saturation[0%..100%], intensity[0%..100%])
+ ///
+ HSI = 6,
+
+ ///
+ /// Color presentation as HWB color value (hue[0°..360°], whiteness[0%..100%], blackness[0%..100%])
+ ///
+ HWB = 7,
+
+ ///
+ /// Color presentation as natural color (hue, whiteness[0%..100%], blackness[0%..100%])
+ ///
+ NCol = 8,
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs
index 520427929e..cbff24aba7 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
@@ -17,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private readonly ISettingsUtils _settingsUtils;
- private ColorPickerSettings _colorPickerSettings;
+ private readonly ColorPickerSettings _colorPickerSettings;
private bool _isEnabled;
@@ -31,6 +32,19 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
throw new ArgumentNullException(nameof(settingsRepository));
}
+ SelectableColorRepresentations = new Dictionary
+ {
+ { ColorRepresentationType.CMYK, "CMYK - cmyk(100%, 50%, 75%, 0%)" },
+ { ColorRepresentationType.HEX, "HEX - #FFAA00" },
+ { ColorRepresentationType.HSB, "HSB - hsb(100, 50%, 75%)" },
+ { ColorRepresentationType.HSI, "HSI - hsi(100, 50%, 75%)" },
+ { ColorRepresentationType.HSL, "HSL - hsl(100, 50%, 75%)" },
+ { ColorRepresentationType.HSV, "HSV - hsv(100, 50%, 75%)" },
+ { ColorRepresentationType.HWB, "HWB - hwb(100, 50%, 75%)" },
+ { ColorRepresentationType.NCol, "NCol - R10, 50%, 75%" },
+ { ColorRepresentationType.RGB, "RGB - rgb(100, 50, 75)" },
+ };
+
GeneralSettingsConfig = settingsRepository.SettingsConfig;
_settingsUtils = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));
@@ -49,80 +63,77 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
SendConfigMSG = ipcMSGCallBackFunc;
}
+ ///
+ /// Gets a list with all selectable s
+ ///
+ public IReadOnlyDictionary SelectableColorRepresentations { get; }
+
public bool IsEnabled
{
- get
- {
- return _isEnabled;
- }
-
+ get => _isEnabled;
set
{
- if (_isEnabled != value)
+ if (_isEnabled == value)
{
- _isEnabled = value;
- OnPropertyChanged(nameof(IsEnabled));
-
- // Set the status of ColorPicker in the general settings
- GeneralSettingsConfig.Enabled.ColorPicker = value;
- OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
-
- SendConfigMSG(outgoing.ToString());
+ return;
}
+
+ _isEnabled = value;
+ OnPropertyChanged(nameof(IsEnabled));
+
+ // Set the status of ColorPicker in the general settings
+ GeneralSettingsConfig.Enabled.ColorPicker = value;
+ var outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
+
+ SendConfigMSG(outgoing.ToString());
}
}
public bool ChangeCursor
{
- get
- {
- return _colorPickerSettings.Properties.ChangeCursor;
- }
-
+ get => _colorPickerSettings.Properties.ChangeCursor;
set
{
- if (_colorPickerSettings.Properties.ChangeCursor != value)
+ if (_colorPickerSettings.Properties.ChangeCursor == value)
{
- _colorPickerSettings.Properties.ChangeCursor = value;
- OnPropertyChanged(nameof(ChangeCursor));
- NotifySettingsChanged();
+ return;
}
+
+ _colorPickerSettings.Properties.ChangeCursor = value;
+ OnPropertyChanged(nameof(ChangeCursor));
+ NotifySettingsChanged();
}
}
public HotkeySettings ActivationShortcut
{
- get
- {
- return _colorPickerSettings.Properties.ActivationShortcut;
- }
-
+ get => _colorPickerSettings.Properties.ActivationShortcut;
set
{
- if (_colorPickerSettings.Properties.ActivationShortcut != value)
+ if (_colorPickerSettings.Properties.ActivationShortcut == value)
{
- _colorPickerSettings.Properties.ActivationShortcut = value;
- OnPropertyChanged(nameof(ActivationShortcut));
- NotifySettingsChanged();
+ return;
}
+
+ _colorPickerSettings.Properties.ActivationShortcut = value;
+ OnPropertyChanged(nameof(ActivationShortcut));
+ NotifySettingsChanged();
}
}
- public int CopiedColorRepresentationIndex
+ public ColorRepresentationType SelectedColorRepresentationValue
{
- get
- {
- return (int)_colorPickerSettings.Properties.CopiedColorRepresentation;
- }
-
+ get => _colorPickerSettings.Properties.CopiedColorRepresentation;
set
{
- if (_colorPickerSettings.Properties.CopiedColorRepresentation != (ColorRepresentationType)value)
+ if (_colorPickerSettings.Properties.CopiedColorRepresentation == value)
{
- _colorPickerSettings.Properties.CopiedColorRepresentation = (ColorRepresentationType)value;
- OnPropertyChanged(nameof(CopiedColorRepresentationIndex));
- NotifySettingsChanged();
+ return;
}
+
+ _colorPickerSettings.Properties.CopiedColorRepresentation = value;
+ OnPropertyChanged(nameof(SelectedColorRepresentationValue));
+ NotifySettingsChanged();
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml
index 5151bcd65b..1c9b6333b7 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml
@@ -13,6 +13,95 @@
AutomationProperties.LandmarkType="Main">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -26,113 +115,16 @@
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml.cs
index 6d994eedc2..8c9a3cd80e 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml.cs
@@ -21,5 +21,33 @@ namespace Microsoft.PowerToys.Settings.UI.Views
DataContext = ViewModel;
InitializeComponent();
}
+
+ ///
+ /// Event is called when the is completly loaded, inclusive the ItemSource
+ ///
+ /// The sender of this event
+ /// The arguments of this event
+ private void ColorPicker_ComboBox_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
+ {
+ /**
+ * UWP hack
+ * because UWP load the binded ItemSource of the ComboBox asyncronous,
+ * so after InitializeComponent() the ItemSource is still empty and can't automatically select a entry.
+ * Selection via SelectedItem and SelectedValue is still not working too
+ */
+ var index = 0;
+
+ foreach (var item in ViewModel.SelectableColorRepresentations)
+ {
+ if (item.Key == ViewModel.SelectedColorRepresentationValue)
+ {
+ break;
+ }
+
+ index++;
+ }
+
+ ColorPicker_ComboBox.SelectedIndex = index;
+ }
}
}