A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Added a Color Picker tool (#587)
Etienne Baudoux0a917c504a5b
diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csprojindex b78818271..085430652 100644--- a/src/dev/impl/DevToys/DevToys.csproj+++ b/src/dev/impl/DevToys/DevToys.csproj@@ -68,6 +68,7 @@<Compile Include="Messages\PinToolToStartMessage.cs" /><Compile Include="Messages\OpenToolInNewWindowMessage.cs" /><Compile Include="Messages\ChangeSelectedMenuItemMessage.cs" />+ <Compile Include="Models\ColorPickerModeDisplayPair.cs" /><Compile Include="Models\HashComparisonResult.cs" /><Compile Include="Models\HashingAlgorithm.cs" /><Compile Include="Models\HashingAlgorithmDisplayPair.cs" />@@ -87,6 +88,7 @@</Compile><Compile Include="UI\Converters\BooleanToDoubleConverter.cs" /><Compile Include="UI\Converters\BooleanToIntegerConverter.cs" />+ <Compile Include="UI\Converters\ColorToBrushConverter.cs" /><Compile Include="UI\MainMenuNavigationViewMenuItemSelector.cs" /><Compile Include="ViewModels\Tools\AllTools\AllToolsToolProvider.cs" /><Compile Include="ViewModels\Tools\AllTools\AllToolsToolViewModel.cs" />@@ -120,6 +122,8 @@<Compile Include="ViewModels\Tools\Generators\LoremIpsumGenerator\LoremIpsumGeneratorToolViewModel.cs" /><Compile Include="ViewModels\Tools\Graphic\ColorBlindnessSimulator\ColorBlindnessSimulatorToolProvider.cs" /><Compile Include="ViewModels\Tools\Graphic\ColorBlindnessSimulator\ColorBlindnessSimulatorToolViewModel.cs" />+ <Compile Include="ViewModels\Tools\Graphic\ColorPicker\ColorPickerToolProvider.cs" />+ <Compile Include="ViewModels\Tools\Graphic\ColorPicker\ColorPickerToolViewModel.cs" /><Compile Include="ViewModels\Tools\Graphic\GraphicGroupToolProvider.cs" /><Compile Include="ViewModels\Tools\Graphic\ImageConverter\ImageConversionWorkItem.cs" /><Compile Include="ViewModels\Tools\Graphic\ImageConverter\ImageConverterToolProvider.cs" />@@ -181,6 +185,9 @@<Compile Include="UI\Controls\ImagePreview.xaml.cs"><DependentUpon>ImagePreview.xaml</DependentUpon></Compile>+ <Compile Include="Views\Tools\Graphic\ColorPicker\ColorPickerToolPage.xaml.cs">+ <DependentUpon>ColorPickerToolPage.xaml</DependentUpon>+ </Compile><Compile Include="Views\Tools\GroupToolPage.xaml.cs"><DependentUpon>GroupToolPage.xaml</DependentUpon></Compile>@@ -584,6 +591,10 @@<AppxManifest Include="Package.appxmanifest"><SubType>Designer</SubType></AppxManifest>+ <Page Include="Views\Tools\Graphic\ColorPicker\ColorPickerToolPage.xaml">+ <Generator>MSBuild:Compile</Generator>+ <SubType>Designer</SubType>+ </Page><Page Include="Views\Tools\Text\XmlValidator\XmlValidatorToolPage.xaml"><Generator>MSBuild:Compile</Generator><SubType>Designer</SubType>@@ -792,6 +803,7 @@<Name>Windows Desktop Extensions for the UWP</Name></SDKReference></ItemGroup>+ <ItemGroup /><Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /><!-- To modify your build process, add your task inside one of the targets below and uncomment it.Other similar extension points exist, see Microsoft.Common.targets.diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex 4a177a3b6..dafab7781 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -29,6 +29,7 @@ namespace DevToysprivate readonly Base64ImageEncoderDecoderStrings _base64imageencoderdecoder = new Base64ImageEncoderDecoderStrings();private readonly CheckSumGeneratorStrings _checksumgenerator = new CheckSumGeneratorStrings();private readonly ColorBlindnessSimulatorStrings _colorblindnesssimulator = new ColorBlindnessSimulatorStrings();+ private readonly ColorPickerStrings _colorpicker = new ColorPickerStrings();private readonly CommonStrings _common = new CommonStrings();private readonly CRONParserStrings _cronparser = new CRONParserStrings();private readonly GuidGeneratorStrings _guidgenerator = new GuidGeneratorStrings();@@ -92,6 +93,11 @@ namespace DevToys/// </summary>public ColorBlindnessSimulatorStrings ColorBlindnessSimulator => _colorblindnesssimulator;+ /// <summary>+ /// Gets the <see cref="ColorPickerStrings"/>.+ /// </summary>+ public ColorPickerStrings ColorPicker => _colorpicker;+/// <summary>/// Gets the <see cref="CommonStrings"/>./// </summary>@@ -549,6 +555,76 @@ namespace DevToyspublic string SearchKeywords => _resources.GetString("SearchKeywords");}+ public class ColorPickerStrings : ObservableObject+ {+ private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("ColorPicker");++ /// <summary>+ /// Gets the resource AccessibleName.+ /// </summary>+ public string AccessibleName => _resources.GetString("AccessibleName");++ /// <summary>+ /// Gets the resource MenuDisplayName.+ /// </summary>+ public string MenuDisplayName => _resources.GetString("MenuDisplayName");++ /// <summary>+ /// Gets the resource Description.+ /// </summary>+ public string Description => _resources.GetString("Description");++ /// <summary>+ /// Gets the resource SearchDisplayName.+ /// </summary>+ public string SearchDisplayName => _resources.GetString("SearchDisplayName");++ /// <summary>+ /// Gets the resource SearchKeywords.+ /// </summary>+ public string SearchKeywords => _resources.GetString("SearchKeywords");++ /// <summary>+ /// Gets the resource BlackText.+ /// </summary>+ public string BlackText => _resources.GetString("BlackText");++ /// <summary>+ /// Gets the resource ColorPicker.+ /// </summary>+ public string ColorPicker => _resources.GetString("ColorPicker");++ /// <summary>+ /// Gets the resource Configuration.+ /// </summary>+ public string Configuration => _resources.GetString("Configuration");++ /// <summary>+ /// Gets the resource Mode.+ /// </summary>+ public string Mode => _resources.GetString("Mode");++ /// <summary>+ /// Gets the resource ModeHSL.+ /// </summary>+ public string ModeHSL => _resources.GetString("ModeHSL");++ /// <summary>+ /// Gets the resource ModeHSV.+ /// </summary>+ public string ModeHSV => _resources.GetString("ModeHSV");++ /// <summary>+ /// Gets the resource SelectedColor.+ /// </summary>+ public string SelectedColor => _resources.GetString("SelectedColor");++ /// <summary>+ /// Gets the resource WhiteText.+ /// </summary>+ public string WhiteText => _resources.GetString("WhiteText");+ }+public class CommonStrings : ObservableObject{private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("Common");diff --git a/src/dev/impl/DevToys/Models/ColorPickerModeDisplayPair.cs b/src/dev/impl/DevToys/Models/ColorPickerModeDisplayPair.csnew file mode 100644index 000000000..a5da9ec68--- /dev/null+++ b/src/dev/impl/DevToys/Models/ColorPickerModeDisplayPair.cs@@ -0,0 +1,31 @@+#nullable enable++using System;+using Microsoft.UI.Xaml.Controls;++namespace DevToys.Models+{+ public class ColorPickerModeDisplayPair : IEquatable<ColorPickerModeDisplayPair>+ {+ private static ColorPickerStrings Strings => LanguageManager.Instance.ColorPicker;++ public static readonly ColorPickerModeDisplayPair HSV = new(Strings.ModeHSV, ColorSpectrumComponents.HueSaturation);++ public static readonly ColorPickerModeDisplayPair HSL = new(Strings.ModeHSL, ColorSpectrumComponents.SaturationValue);++ public string DisplayName { get; }++ public ColorSpectrumComponents Value { get; }++ private ColorPickerModeDisplayPair(string displayName, ColorSpectrumComponents value)+ {+ DisplayName = displayName;+ Value = value;+ }++ public bool Equals(ColorPickerModeDisplayPair other)+ {+ return other.Value == Value;+ }+ }+}diff --git a/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs b/src/dev/impl/DevToys/Models/IndentationDisplayPair.csindex 45991dde5..cf2243491 100644--- a/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs+++ b/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs@@ -1,4 +1,6 @@-using System;+#nullable enable++using System;namespace DevToys.Models{diff --git a/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw b/src/dev/impl/DevToys/Strings/en-US/ColorPicker.reswnew file mode 100644index 000000000..81d59ab47--- /dev/null+++ b/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw@@ -0,0 +1,159 @@+<?xml version="1.0" encoding="utf-8"?>+<root>+ <!--+ Microsoft ResX Schema++ Version 2.0++ The primary goals of this format is to allow a simple XML format+ that is mostly human readable. The generation and parsing of the+ various data types are done through the TypeConverter classes+ associated with the data types.++ Example:++ ... ado.net/XML headers & schema ...+ <resheader name="resmimetype">text/microsoft-resx</resheader>+ <resheader name="version">2.0</resheader>+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">+ <value>[base64 mime encoded serialized .NET Framework object]</value>+ </data>+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>+ <comment>This is a comment</comment>+ </data>++ There are any number of "resheader" rows that contain simple+ name/value pairs.++ Each data row contains a name, and value. The row also contains a+ type or mimetype. Type corresponds to a .NET class that support+ text/value conversion through the TypeConverter architecture.+ Classes that don't support this are serialized and stored with the+ mimetype set.++ The mimetype is used for serialized objects, and tells the+ ResXResourceReader how to depersist the object. This is currently not+ extensible. For a given mimetype the value must be set accordingly:++ Note - application/x-microsoft.net.object.binary.base64 is the format+ that the ResXResourceWriter will generate, however the reader can+ read any of the formats listed below.++ mimetype: application/x-microsoft.net.object.binary.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.soap.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.bytearray.base64+ value : The object must be serialized into a byte array+ : using a System.ComponentModel.TypeConverter+ : and then encoded with base64 encoding.+ -->+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />+ <xsd:element name="root" msdata:IsDataSet="true">+ <xsd:complexType>+ <xsd:choice maxOccurs="unbounded">+ <xsd:element name="metadata">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" />+ </xsd:sequence>+ <xsd:attribute name="name" use="required" type="xsd:string" />+ <xsd:attribute name="type" type="xsd:string" />+ <xsd:attribute name="mimetype" type="xsd:string" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="assembly">+ <xsd:complexType>+ <xsd:attribute name="alias" type="xsd:string" />+ <xsd:attribute name="name" type="xsd:string" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="data">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="resheader">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" />+ </xsd:complexType>+ </xsd:element>+ </xsd:choice>+ </xsd:complexType>+ </xsd:element>+ </xsd:schema>+ <resheader name="resmimetype">+ <value>text/microsoft-resx</value>+ </resheader>+ <resheader name="version">+ <value>2.0</value>+ </resheader>+ <resheader name="reader">+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <resheader name="writer">+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <data name="AccessibleName" xml:space="preserve">+ <value>Color Picker tool</value>+ </data>+ <data name="MenuDisplayName" xml:space="preserve">+ <value>Color Picker</value>+ </data>+ <data name="Description" xml:space="preserve">+ <value>Pick up a color</value>+ </data>+ <data name="SearchDisplayName" xml:space="preserve">+ <value>Color Picker</value>+ </data>+ <data name="SearchKeywords" xml:space="preserve">+ <value />+ </data>+ <data name="BlackText" xml:space="preserve">+ <value>Black text</value>+ </data>+ <data name="ColorPicker" xml:space="preserve">+ <value>Color picker</value>+ </data>+ <data name="Configuration" xml:space="preserve">+ <value>Configuration</value>+ </data>+ <data name="Mode" xml:space="preserve">+ <value>Mode</value>+ </data>+ <data name="ModeHSL" xml:space="preserve">+ <value>HSL</value>+ </data>+ <data name="ModeHSV" xml:space="preserve">+ <value>HSV</value>+ </data>+ <data name="SelectedColor" xml:space="preserve">+ <value>Selected color</value>+ </data>+ <data name="WhiteText" xml:space="preserve">+ <value>White text</value>+ </data>+</root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/UI/Converters/ColorToBrushConverter.cs b/src/dev/impl/DevToys/UI/Converters/ColorToBrushConverter.csnew file mode 100644index 000000000..671195c9d--- /dev/null+++ b/src/dev/impl/DevToys/UI/Converters/ColorToBrushConverter.cs@@ -0,0 +1,33 @@+#nullable enable++using System;+using Windows.UI;+using Windows.UI.Xaml;+using Windows.UI.Xaml.Data;+using Windows.UI.Xaml.Media;++namespace DevToys.UI.Converters+{+ /// <summary>+ /// Convert a <see cref="Color"/> to a inverted <see cref="SolidColorBrush"/> value.+ /// </summary>+ public sealed class ColorToBrushConverter : IValueConverter+ {+ public object Convert(object value, Type targetType, object parameter, string language)+ {+ var valueColor = value as Color?;+ if (valueColor == null)+ {+ return DependencyProperty.UnsetValue;+ }++ return new SolidColorBrush(valueColor.Value);+ }++ public object ConvertBack(object value, Type targetType, object parameter, string language)+ {+ throw new NotImplementedException();+ }+ }+}+diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Converters/JsonYaml/JsonYamlToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Converters/JsonYaml/JsonYamlToolViewModel.csindex facb63894..745acecd2 100644--- a/src/dev/impl/DevToys/ViewModels/Tools/Converters/JsonYaml/JsonYamlToolViewModel.cs+++ b/src/dev/impl/DevToys/ViewModels/Tools/Converters/JsonYaml/JsonYamlToolViewModel.cs@@ -42,8 +42,6 @@ namespace DevToys.ViewModels.Tools.JsonYamlinternal const string JsonToYaml = nameof(JsonToYaml);internal const string YamlToJson = nameof(YamlToJson);- private const string TwoSpaceIndentation = "TwoSpaces";- private const string FourSpaceIndentation = "FourSpaces";private readonly IMarketingService _marketingService;private readonly Queue<string> _conversionQueue = new();diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolProvider.csnew file mode 100644index 000000000..f47145d9a--- /dev/null+++ b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolProvider.cs@@ -0,0 +1,48 @@+#nullable enable++using System.Composition;+using DevToys.Api.Tools;+using DevToys.Core.Threading;+using DevToys.Shared.Api.Core;+using Windows.UI.Xaml.Controls;++namespace DevToys.ViewModels.Tools.Graphic.ColorPicker+{+ [Export(typeof(IToolProvider))]+ [Name("Color Picker")]+ [Parent(GraphicGroupToolProvider.InternalName)]+ [ProtocolName("color")]+ [Order(0)]+ internal class ColorPickerToolProvider : ToolProviderBase, IToolProvider+ {+ private readonly IMefProvider _mefProvider;++ public string MenuDisplayName => LanguageManager.Instance.ColorPicker.MenuDisplayName;++ public string? SearchDisplayName => LanguageManager.Instance.ColorPicker.SearchDisplayName;++ public string? Description => LanguageManager.Instance.ColorPicker.Description;++ public string AccessibleName => LanguageManager.Instance.ColorPicker.AccessibleName;++ public string? SearchKeywords => LanguageManager.Instance.ColorPicker.SearchKeywords;++ public TaskCompletionNotifier<IconElement> IconSource => CreateFontIcon("\uF2F5");++ [ImportingConstructor]+ public ColorPickerToolProvider(IMefProvider mefProvider)+ {+ _mefProvider = mefProvider;+ }++ public bool CanBeTreatedByTool(string data)+ {+ return false;+ }++ public IToolViewModel CreateTool()+ {+ return _mefProvider.Import<ColorPickerToolViewModel>();+ }+ }+}diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.csnew file mode 100644index 000000000..69e7ed96d--- /dev/null+++ b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs@@ -0,0 +1,88 @@+#nullable enable++using System;+using System.Collections.Generic;+using System.Collections.ObjectModel;+using System.Composition;+using System.Linq;+using DevToys.Api.Core.Settings;+using DevToys.Api.Core.Theme;+using DevToys.Api.Tools;+using DevToys.Models;+using DevToys.Views.Tools.ColorPicker;+using Microsoft.Toolkit.Mvvm.ComponentModel;+using Microsoft.UI.Xaml.Controls;+using Windows.UI;+using Windows.UI.Xaml;++namespace DevToys.ViewModels.Tools.Graphic.ColorPicker+{+ [Export(typeof(ColorPickerToolViewModel))]+ public sealed class ColorPickerToolViewModel : ObservableRecipient, IToolViewModel+ {+ /// <summary>+ /// The mode of the color picker.+ /// </summary>+ private static readonly SettingDefinition<ColorSpectrumComponents> Mode+ = new(+ name: $"{nameof(ColorPickerToolViewModel)}.{nameof(Mode)}",+ isRoaming: true,+ defaultValue: ColorPickerModeDisplayPair.HSV.Value);++ private readonly ISettingsProvider _settingsProvider;+ private Color _selectedColor;++ public Type View => typeof(ColorPickerToolPage);++ internal ColorPickerStrings Strings => LanguageManager.Instance.ColorPicker;++ /// <summary>+ /// Gets or sets the desired color picker mode.+ /// </summary>+ public ColorPickerModeDisplayPair ColorPickerMode+ {+ get+ {+ ColorSpectrumComponents settingsValue = _settingsProvider.GetSetting(Mode);+ ColorPickerModeDisplayPair? mode = ColorPickerModes.FirstOrDefault(x => x.Value == settingsValue);+ return mode ?? ColorPickerModeDisplayPair.HSV;+ }+ set+ {+ if (ColorPickerMode != value)+ {+ _settingsProvider.SetSetting(Mode, value.Value);+ OnPropertyChanged();+ }+ }+ }++ /// <summary>+ /// Get a list of supported color picker modes+ /// </summary>+ public IReadOnlyList<ColorPickerModeDisplayPair> ColorPickerModes+ = new ObservableCollection<ColorPickerModeDisplayPair>+ {+ ColorPickerModeDisplayPair.HSV,+ ColorPickerModeDisplayPair.HSL+ };++ /// <summary>+ /// Gets or sets the selected color.+ /// </summary>+ public Color SelectedColor+ {+ get => _selectedColor;+ set => SetProperty(ref _selectedColor, value);+ }++ [ImportingConstructor]+ public ColorPickerToolViewModel(ISettingsProvider settingsProvider, IThemeListener themeListener)+ {+ _settingsProvider = settingsProvider;++ string? accentColorResourceName = themeListener.ActualAppTheme == ApplicationTheme.Light ? "SystemAccentColorLight2" : "SystemAccentColorDark1";+ SelectedColor = (Color)Application.Current.Resources[accentColorResourceName];+ }+ }+}diff --git a/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xamlnew file mode 100644index 000000000..bbb157fd2--- /dev/null+++ b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml@@ -0,0 +1,100 @@+<Page+ x:Class="DevToys.Views.Tools.ColorPicker.ColorPickerToolPage"+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"+ xmlns:controls="using:DevToys.UI.Controls"+ xmlns:converters="using:DevToys.UI.Converters"+ xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:ex="using:DevToys.UI.Extensions"+ mc:Ignorable="d"+ NavigationCacheMode="Required">+ <Page.Resources>+ <converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>+ </Page.Resources>++ <Grid Margin="0,0,0,16" RowSpacing="12">+ <VisualStateManager.VisualStateGroups>+ <VisualStateGroup>+ <VisualState>+ <VisualState.StateTriggers>+ <ex:IsCompactOverlayModeTrigger TargetElement="{x:Bind}" />+ </VisualState.StateTriggers>+ <VisualState.Setters>+ <Setter Target="SettingsStackPanel.Visibility" Value="Collapsed"/>+ <Setter Target="ColorPicker.Orientation" Value="Vertical"/>+ <Setter Target="ColorPicker.HorizontalAlignment" Value="Center"/>+ </VisualState.Setters>+ </VisualState>+ </VisualStateGroup>+ </VisualStateManager.VisualStateGroups>++ <Grid.ChildrenTransitions>+ <TransitionCollection>+ <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>+ </TransitionCollection>+ </Grid.ChildrenTransitions>++ <Grid.RowDefinitions>+ <RowDefinition Height="Auto"/>+ <RowDefinition Height="Auto"/>+ <RowDefinition Height="Auto"/>+ </Grid.RowDefinitions>++ <StackPanel+ x:Name="SettingsStackPanel"+ Grid.Row="0"+ Spacing="4">+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.Configuration}" />++ <controls:ExpandableSettingControl+ Title="{x:Bind ViewModel.Strings.Mode}">+ <controls:ExpandableSettingControl.Icon>+ <FontIcon Glyph="" />+ </controls:ExpandableSettingControl.Icon>+ <ComboBox+ ItemsSource="{x:Bind ViewModel.ColorPickerModes}"+ DisplayMemberPath="DisplayName"+ SelectedItem="{x:Bind ViewModel.ColorPickerMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">+ </ComboBox>+ </controls:ExpandableSettingControl>+ </StackPanel>++ <StackPanel+ Grid.Row="1"+ Spacing="4">+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.SelectedColor}" />++ <StackPanel+ Spacing="12"+ Padding="0,12,0,12"+ Orientation="Vertical"+ CornerRadius="{ThemeResource ControlCornerRadius}"+ Background="{x:Bind ViewModel.SelectedColor, Mode=OneWay, Converter={StaticResource ColorToBrushConverter}}">+ <TextBlock+ Foreground="Black"+ HorizontalAlignment="Center"+ Text="{x:Bind ViewModel.Strings.BlackText}"/>+ <TextBlock+ Foreground="White"+ HorizontalAlignment="Center"+ Text="{x:Bind ViewModel.Strings.WhiteText}"/>+ </StackPanel>+ </StackPanel>++ <StackPanel+ Grid.Row="2"+ Spacing="4">+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.ColorPicker}" />++ <muxc:ColorPicker+ x:Name="ColorPicker"+ Color="{x:Bind ViewModel.SelectedColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"+ ColorSpectrumShape="Box"+ ColorSpectrumComponents="{x:Bind ViewModel.ColorPickerMode.Value, Mode=OneWay}"+ IsAlphaEnabled="True"+ IsColorPreviewVisible="False"+ Orientation="Horizontal"/>+ </StackPanel>+ </Grid>+</Page>diff --git a/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml.cs b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml.csnew file mode 100644index 000000000..6762ff407--- /dev/null+++ b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml.cs@@ -0,0 +1,50 @@+#nullable enable++using DevToys.Api.Core.Navigation;+using DevToys.Shared.Core;+using DevToys.ViewModels.Tools.Graphic.ColorPicker;+using Windows.UI.Xaml;+using Windows.UI.Xaml.Controls;+using Windows.UI.Xaml.Navigation;++namespace DevToys.Views.Tools.ColorPicker+{+ public sealed partial class ColorPickerToolPage : Page+ {+ public static readonly DependencyProperty ViewModelProperty+ = DependencyProperty.Register(+ nameof(ViewModel),+ typeof(ColorPickerToolViewModel),+ typeof(ColorPickerToolPage),+ new PropertyMetadata(null));++ /// <summary>+ /// Gets the page's view model.+ /// </summary>+ public ColorPickerToolViewModel ViewModel+ {+ get => (ColorPickerToolViewModel)GetValue(ViewModelProperty);+ set => SetValue(ViewModelProperty, value);+ }++ public ColorPickerToolPage()+ {+ InitializeComponent();+ }++ protected override void OnNavigatedTo(NavigationEventArgs e)+ {+ var parameters = (NavigationParameter)e.Parameter;++ if (ViewModel is null)+ {+ // Set the view model+ Assumes.NotNull(parameters.ViewModel, nameof(parameters.ViewModel));+ ViewModel = (ColorPickerToolViewModel)parameters.ViewModel!;+ DataContext = ViewModel;+ }++ base.OnNavigatedTo(e);+ }+ }+}