From 57dd0ce113b97b1239726c0ca11d30b545af1c37 Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Fri, 23 Oct 2020 14:32:57 +0200 Subject: [PATCH] Add Ncol, HWB, HSB color format + cleanup --- .../ColorPickerProperties.cs | 29 +--- .../ColorPickerSettings.cs | 8 +- .../Enumerations/ColorRepresentationType.cs | 54 +++++++ .../ViewModels/ColorPickerViewModel.cs | 1 + .../Views/ColorPickerPage.xaml | 4 + .../ColorPickerUI/Helpers/ColorHelper.cs | 150 +++++++++++++----- .../Helpers/ColorRepresentationHelper.cs | 103 +++++++++--- .../ColorPickerUI/Settings/IUserSettings.cs | 2 +- .../ColorPickerUI/Settings/UserSettings.cs | 1 + .../Helpers/ColorRepresentationHelperTest.cs | 6 +- 10 files changed, 260 insertions(+), 98 deletions(-) create mode 100644 src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerProperties.cs index 7f65789992..f5305f5960 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerProperties.cs @@ -4,37 +4,10 @@ using System.Text.Json; using System.Text.Json.Serialization; +using Microsoft.PowerToys.Settings.UI.Library.Enumerations; namespace Microsoft.PowerToys.Settings.UI.Library { - public enum ColorRepresentationType - { - /// - /// Color presentation as hexadecimal color value without the alpha-value (e.g. #0055FF) - /// - HEX = 0, - - /// - /// Color presentation as RGB color value (red[0..255], green[0..255], blue[0..255]) - /// - 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, - } - public class ColorPickerProperties { public ColorPickerProperties() diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerSettings.cs index 72ebb295c9..a27a1076a3 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerSettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/ColorPickerSettings.cs @@ -40,14 +40,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library } public string GetModuleName() - { - return Name; - } + => Name; // This can be utilized in the future if the settings.json file is to be modified/deleted. public bool UpgradeSettingsConfiguration() - { - return false; - } + => false; } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs b/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs new file mode 100644 index 0000000000..abcc78f775 --- /dev/null +++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/Enumerations/ColorRepresentationType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Microsoft.PowerToys.Settings.UI.Library.Enumerations +{ + public enum ColorRepresentationType + { + /// + /// Color presentation as hexadecimal color value without the alpha-value (e.g. #0055FF) + /// + HEX = 0, + + /// + /// Color presentation as RGB color value (red[0..255], green[0..255], blue[0..255]) + /// + 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%], value[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, saturation[0%..100%], value[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 ff4f37f612..520427929e 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Library/ViewModels/ColorPickerViewModel.cs @@ -5,6 +5,7 @@ using System; using System.Globalization; using System.Text.Json; +using Microsoft.PowerToys.Settings.UI.Library.Enumerations; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml index 7fb9e40c5d..dac5f414d4 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml +++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml @@ -74,6 +74,10 @@ + + + +