PowerToys/src/modules/colorPicker/ColorPickerUI/ViewModels/ColorEditorViewModel.cs

257 lines
10 KiB
C#
Raw Normal View History

Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
// 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.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Linq;
using System.Windows.Input;
using System.Windows.Media;
using ColorPicker.Common;
using ColorPicker.Helpers;
using ColorPicker.Models;
using ColorPicker.Settings;
using ColorPicker.ViewModelContracts;
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
namespace ColorPicker.ViewModels
{
[Export(typeof(IColorEditorViewModel))]
public class ColorEditorViewModel : ViewModelBase, IColorEditorViewModel
{
private readonly IUserSettings _userSettings;
private readonly List<ColorFormatModel> _allColorRepresentations = new List<ColorFormatModel>();
private Color _selectedColor;
private bool _initializing;
private int _selectedColorIndex;
[ImportingConstructor]
public ColorEditorViewModel(IUserSettings userSettings)
{
OpenColorPickerCommand = new RelayCommand(() => OpenColorPickerRequested?.Invoke(this, EventArgs.Empty));
OpenSettingsCommand = new RelayCommand(() => OpenSettingsRequested?.Invoke(this, EventArgs.Empty));
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
RemoveColorCommand = new RelayCommand(DeleteSelectedColor);
SelectedColorChangedCommand = new RelayCommand((newColor) =>
{
ColorsHistory.Insert(0, (Color)newColor);
SelectedColorIndex = 0;
});
ColorsHistory.CollectionChanged += ColorsHistory_CollectionChanged;
_userSettings = userSettings;
SetupAllColorRepresentations();
SetupAvailableColorRepresentations();
}
public event EventHandler OpenColorPickerRequested;
public event EventHandler OpenSettingsRequested;
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
public ICommand OpenColorPickerCommand { get; }
public ICommand OpenSettingsCommand { get; }
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
public ICommand RemoveColorCommand { get; }
public ICommand SelectedColorChangedCommand { get; }
public ICommand HideColorFormatCommand { get; }
public ObservableCollection<Color> ColorsHistory { get; } = new ObservableCollection<Color>();
public ObservableCollection<ColorFormatModel> ColorRepresentations { get; } = new ObservableCollection<ColorFormatModel>();
public Color SelectedColor
{
get
{
return _selectedColor;
}
set
{
_selectedColor = value;
OnPropertyChanged();
}
}
public int SelectedColorIndex
{
get
{
return _selectedColorIndex;
}
set
{
_selectedColorIndex = value;
if (value >= 0)
{
SelectedColor = ColorsHistory[_selectedColorIndex];
}
OnPropertyChanged();
}
}
public void Initialize()
{
_initializing = true;
ColorsHistory.Clear();
foreach (var item in _userSettings.ColorHistory)
{
var parts = item.Split('|');
ColorsHistory.Add(new Color()
{
A = byte.Parse(parts[0], NumberStyles.Integer, CultureInfo.InvariantCulture),
R = byte.Parse(parts[1], NumberStyles.Integer, CultureInfo.InvariantCulture),
G = byte.Parse(parts[2], NumberStyles.Integer, CultureInfo.InvariantCulture),
B = byte.Parse(parts[3], NumberStyles.Integer, CultureInfo.InvariantCulture),
});
SelectedColorIndex = 0;
}
_initializing = false;
}
private void ColorsHistory_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (!_initializing)
{
_userSettings.ColorHistory.ClearWithoutNotification();
foreach (var item in ColorsHistory)
{
_userSettings.ColorHistory.AddWithoutNotification(item.A + "|" + item.R + "|" + item.G + "|" + item.B);
}
_userSettings.ColorHistory.ReleaseNotification();
}
}
private void DeleteSelectedColor()
{
// select new color on the same index if possible, otherwise the last one
var indexToSelect = SelectedColorIndex == ColorsHistory.Count - 1 ? ColorsHistory.Count - 2 : SelectedColorIndex;
ColorsHistory.RemoveAt(SelectedColorIndex);
SelectedColorIndex = indexToSelect;
2021-03-25 12:11:36 +01:00
SessionEventHelper.Event.EditorHistoryColorRemoved = true;
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
}
private void SetupAllColorRepresentations()
{
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HEX.ToString(),
#pragma warning disable CA1304 // Specify CultureInfo
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HEX).ToLower(); },
#pragma warning restore CA1304 // Specify CultureInfo
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.RGB.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.RGB); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HSL.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HSL); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HSV.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HSV); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.CMYK.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.CMYK); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HSB.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HSB); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HSI.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HSI); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.HWB.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.HWB); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.NCol.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.NCol); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.CIELAB.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.CIELAB); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.CIEXYZ.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.CIEXYZ); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = ColorRepresentationType.VEC4.ToString(),
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.VEC4); },
});
_allColorRepresentations.Add(
new ColorFormatModel()
{
FormatName = "Decimal",
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.DecimalValue); },
});
Color Picker V2 (#7710) * Ground base for WPF version of V2 color picker * Added theming support * Layout fixes, added UWP listview styling * Updated UI * Added theming and Fluent to colorpicker. Styles cleanup * Added animation for "color copied" message * Added color format control, testing transparency * Added roll-over behaviour, selectable textbox and right-click context menu * Revert "Added roll-over behaviour, selectable textbox and right-click context menu" This reverts commit af35a23532046aa096f8a9cd7c1582aa2af3b423. * Delete context menu, mouse-over clipboard button and selectable text * Implemented remove color command, set color editor topmost * Missed some changes * Added all currently supported color formats into editor, added support for future custom formats * Added missed file * Reverted WindowStyle = None * Added drag and drop reorder behavior for color formats * Removed custom close button, UI cleanup, added scrollviewer to colorformats * Added close button * Added color picker color control to configure current color * Added possibility to add and remove color representations, commented out drag&drop reorder behavior * Calculate color variations of the current color, on click adds a new color into the history * Fixed reopening of editor, added rgb textboxes into color picker control, moved add color formats button at bottom * Improved color schemes, similiar to Windows 10X * Updated icon, window name and XAML cleanup * Moved strings to Resources file * Added Narrator support * Accesibility stuff * Revamped color picker color - now 3 sliders to configure color - hue, saturation, value, added bidirectional of setting values HEX/RGB/Sliders, validation of rgb and hex input * UX improvements * Removed color format management * Removed colorformat hide context menu * Improved colorpicker UI * Added colorformats XAML to Settings * Reverted runner change * Margin fix * Updated height of colorpicking tooltip * Using dynamic width for color picker based on a content * Fixed build * Added H,S,V labels in front of gradient sliders in color picker control * Color shades borders are now buttons, improved narrator support * Added tabindexes * Accesiblity improvements * UI bugfix * Fixed issue with occasional issue with saving color/removing colors due to locked settings file, decreased number of writes into settings.json, fixed throuttledActionInvoker to run only once, added rangeobservablecollection data type to be able to control notifications in observablecollection * Updated installer with newly added libs * Hide settings button since required functionality is not available yet * Added comments to resource file * Added reorder and enable/disable color formats from settings, * Show message when colors history empty, open color editor in the center of screen * Styling updates to now color selected popup * Added horizontal gripper icon on pointerover * Typo fix * Added new color formats into editor * Added 3 different activation actions to choose from * Added new color formats into settings for editor * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Updated expect.txt * Removed MahApps * Removed MahApps from installer for Color Picker module * Updated settings page * Typo fix and moved string to Resources * Typo fixes and string improvements * Fixing build * Replacing DispatcherTimer with Timer from System.Timers * Fixing tests * adjustments * adjustments * removed periods * Fixing build * unifiying language * Added using statement in tests * Disabled drop shadow for Color Picker and Zoom Window due to poor performance * Stylecop fixes Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Niels Laute <niels9001@hotmail.com> Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> Co-authored-by: Clint Rutkas <clint@rutkas.com>
2020-11-20 13:50:47 +01:00
_userSettings.VisibleColorFormats.CollectionChanged += VisibleColorFormats_CollectionChanged;
// Any other custom format to be added here as well that are read from settings
}
private void VisibleColorFormats_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
SetupAvailableColorRepresentations();
}
private void SetupAvailableColorRepresentations()
{
ColorRepresentations.Clear();
foreach (var colorFormat in _userSettings.VisibleColorFormats)
{
var colorRepresentation = _allColorRepresentations.FirstOrDefault(it => it.FormatName.ToUpperInvariant() == colorFormat.ToUpperInvariant());
if (colorRepresentation != null)
{
ColorRepresentations.Add(colorRepresentation);
}
}
}
}
}