[ColorPicker]Fluent UX (#28560)

* Init

* UI tweaks

* Remaining UI tweaks

* Update ColorEditorView.xaml.cs

* Getting things up and running

* Tweaks

* Bump WPF version number

* UI tweaks

* Updated sliders styles

* Finalize colorslider styling

* Fix color

* Revert back to a default window

* Adding icon

* Address label feedback

* Correct wrong file change

* Update ColorEditorWindow.xaml.cs

* Tweaks

* Update MainView.xaml

* XAML styler

* Update MainWindow.xaml.cs

* Fix NOTICE.md

* UI tweaks

* Remove IsHitTestVisible

* Bump to WPFUI 3.0

* Fix scrollbars

* Replacing textblock with symbolicon

* Change size

* Update ColorEditorView.xaml
This commit is contained in:
Niels Laute
2024-02-15 15:24:27 +01:00
committed by GitHub
parent c75ac456d7
commit 319a0dd6c2
29 changed files with 1466 additions and 1073 deletions

View File

@@ -90,7 +90,7 @@
<PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" /> <PackageVersion Include="Vanara.PInvoke.User32" Version="3.4.11" />
<PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" /> <PackageVersion Include="Vanara.PInvoke.Shell32" Version="3.4.11" />
<PackageVersion Include="WinUIEx" Version="2.2.0" /> <PackageVersion Include="WinUIEx" Version="2.2.0" />
<PackageVersion Include="WPF-UI" Version="3.0.0-preview.13" /> <PackageVersion Include="WPF-UI" Version="3.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(IsExperimentationLive)'!=''"> <ItemGroup Condition="'$(IsExperimentationLive)'!=''">
<!-- Additional dependencies used by experimentation --> <!-- Additional dependencies used by experimentation -->

View File

@@ -1369,4 +1369,4 @@ EXHIBIT A -Mozilla Public License.
- Vanara.PInvoke.Shell32 3.4.11 - Vanara.PInvoke.Shell32 3.4.11
- Vanara.PInvoke.User32 3.4.11 - Vanara.PInvoke.User32 3.4.11
- WinUIEx 2.2.0 - WinUIEx 2.2.0
- WPF-UI 3.0.0-preview.13 - WPF-UI 3.0.0

View File

@@ -1,14 +1,14 @@
<Application x:Class="ColorPickerUI.App" <Application
x:Class="ColorPickerUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ColorPickerUI" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ui:ThemeResources /> <ui:ThemesDictionary Theme="Dark" />
<ui:XamlControlsResources /> <ui:ControlsDictionary />
<ResourceDictionary Source="Resources/Styles.xaml" /> <ResourceDictionary Source="Resources/Styles.xaml" />
<ResourceDictionary Source="Resources/ViewModelViewMappings.xaml" /> <ResourceDictionary Source="Resources/ViewModelViewMappings.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

View File

@@ -7,7 +7,6 @@ using System.ComponentModel.Composition;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using ColorPicker.Mouse; using ColorPicker.Mouse;
using Common.UI;
using ManagedCommon; using ManagedCommon;
namespace ColorPickerUI namespace ColorPickerUI
@@ -21,7 +20,6 @@ namespace ColorPickerUI
private static string[] _args; private static string[] _args;
private int _powerToysRunnerPid; private int _powerToysRunnerPid;
private bool disposedValue; private bool disposedValue;
private ThemeManager _themeManager;
private CancellationTokenSource NativeThreadCTS { get; set; } private CancellationTokenSource NativeThreadCTS { get; set; }
@@ -62,7 +60,6 @@ namespace ColorPickerUI
_powerToysRunnerPid = -1; _powerToysRunnerPid = -1;
} }
_themeManager = new ThemeManager(this);
base.OnStartup(e); base.OnStartup(e);
} }
@@ -86,8 +83,6 @@ namespace ColorPickerUI
_instanceMutex?.Dispose(); _instanceMutex?.Dispose();
} }
_themeManager?.Dispose();
disposedValue = true; disposedValue = true;
} }
} }

View File

@@ -1,27 +1,47 @@
<Window x:Class="ColorPicker.ColorEditorWindow" <ui:FluentWindow
x:Class="ColorPicker.ColorEditorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:p="clr-namespace:ColorPicker.Properties"
mc:Ignorable="d"
AutomationProperties.Name="{x:Static p:Resources.cp_editor}"
xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:ColorPicker.Behaviors" xmlns:behaviors="clr-namespace:ColorPicker.Behaviors"
ui:TitleBar.ExtendViewIntoTitleBar="True" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
ui:TitleBar.ButtonStyle="{DynamicResource AppTitleBarButtonStyle}" xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
ui:WindowHelper.UseModernWindowStyle="True" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
BorderBrush="{DynamicResource WindowBorderBrush}" xmlns:p="clr-namespace:ColorPicker.Properties"
Background="{DynamicResource PrimaryBackgroundBrush}" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
BorderThickness="1"
Title="Color Picker"
Height="380"
Width="440" Width="440"
Height="380"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
AutomationProperties.Name="{x:Static p:Resources.cp_editor}"
ExtendsContentIntoTitleBar="True"
ResizeMode="NoResize" ResizeMode="NoResize"
Topmost="True" Topmost="True"
WindowStartupLocation="CenterScreen"> WindowCornerPreference="Default"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<e:Interaction.Behaviors> <e:Interaction.Behaviors>
<behaviors:CloseZoomWindowBehavior /> <behaviors:CloseZoomWindowBehavior />
</e:Interaction.Behaviors> </e:Interaction.Behaviors>
</Window> <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ui:TitleBar
x:Name="TitleBar"
Title="{x:Static p:Resources.CP_Title}"
Grid.Row="0"
Height="32"
Padding="16,0,16,0"
ShowMaximize="False"
ShowMinimize="False">
<ui:TitleBar.Icon>
<ui:ImageIcon Source="pack://application:,,,/Assets/ColorPicker/icon.ico" />
</ui:TitleBar.Icon>
</ui:TitleBar>
<ContentPresenter
x:Name="contentPresenter"
Grid.Row="1"
Content="{Binding Content}" />
</Grid>
</ui:FluentWindow>

View File

@@ -5,19 +5,24 @@
using System; using System;
using System.Windows; using System.Windows;
using ColorPicker.Helpers; using ColorPicker.Helpers;
using Common.UI;
using Wpf.Ui.Controls;
namespace ColorPicker namespace ColorPicker
{ {
/// <summary> /// <summary>
/// Interaction logic for ColorEditorWindow.xaml /// Interaction logic for ColorEditorWindow.xaml
/// </summary> /// </summary>
public partial class ColorEditorWindow : Window public partial class ColorEditorWindow : FluentWindow
{ {
private readonly AppStateHandler _appStateHandler; private readonly AppStateHandler _appStateHandler;
public ColorEditorWindow(AppStateHandler appStateHandler) public ColorEditorWindow(AppStateHandler appStateHandler)
{ {
InitializeComponent(); InitializeComponent();
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
WindowBackdropType = OSVersionHelper.IsWindows11() ? WindowBackdropType.Mica : WindowBackdropType = WindowBackdropType.None;
_appStateHandler = appStateHandler; _appStateHandler = appStateHandler;
Closing += ColorEditorWindow_Closing; Closing += ColorEditorWindow_Closing;
} }
@@ -31,7 +36,6 @@ namespace ColorPicker
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
{ {
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
NativeMethods.SetToolWindowStyle(this);
} }
} }
} }

View File

@@ -48,15 +48,21 @@
<ApplicationManifest>App.manifest</ApplicationManifest> <ApplicationManifest>App.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Assets\ColorPicker\icon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\ColorPicker\icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="Shaders\GridShader.cso" /> <Resource Include="Shaders\GridShader.cso" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" /> <PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="ModernWpfUI" />
<PackageReference Include="System.ComponentModel.Composition" /> <PackageReference Include="System.ComponentModel.Composition" />
<PackageReference Include="System.IO.Abstractions" /> <PackageReference Include="System.IO.Abstractions" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
<PackageReference Include="System.Drawing.Common" /> <PackageReference Include="System.Drawing.Common" />
<PackageReference Include="WPF-UI" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="Properties\Settings.settings"> <None Update="Properties\Settings.settings">
@@ -66,9 +72,6 @@
<None Update="Assets\ColorPicker\colorPicker.cur"> <None Update="Assets\ColorPicker\colorPicker.cur">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="Assets\ColorPicker\icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" /> <ProjectReference Include="..\..\..\common\GPOWrapperProjection\GPOWrapperProjection.csproj" />

View File

@@ -1,66 +1,181 @@
<UserControl x:Class="ColorPicker.Controls.ColorFormatControl" <UserControl
xmlns:local="clr-namespace:ColorPicker" x:Class="ColorPicker.Controls.ColorFormatControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ColorPicker.Properties" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:local="clr-namespace:ColorPicker"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:ColorPicker.Properties"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources>
<Border x:Name="MainBorder" <Style x:Key="ReadonlyTextBoxStyle" TargetType="{x:Type TextBox}">
Margin="12,16,12,0" <!-- Universal WPF UI focus -->
Width="348" <Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
Height="36" <!-- Universal WPF UI focus -->
CornerRadius="4" <!-- Universal WPF UI ContextMenu -->
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
<!-- Universal WPF UI ContextMenu -->
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="CaretBrush" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Transparent" />
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Border
x:Name="ContentBorder"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Background="{DynamicResource ColorControlBackgroundBrush}"> VerticalAlignment="Stretch"
<Grid> Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ScrollViewer
x:Name="PART_ContentHost"
VerticalAlignment="Center"
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
Style="{StaticResource DefaultTextBoxScrollViewerStyle}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
</Grid>
</Border>
<!-- The Accent Border is a separate element so that changes to the border thickness do not affect the position of the element -->
<Border
x:Name="AccentBorder"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderThickness="{StaticResource TextBoxAccentBorderThemeThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Border.BorderBrush>
<SolidColorBrush Color="Transparent" />
</Border.BorderBrush>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,0" />
<Setter TargetName="AccentBorder" Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="Transparent" />
</Setter.Value>
</Setter>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="Transparent" />
</Setter.Value>
</Setter>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="ContentBorder" Property="Background">
<Setter.Value>
<SolidColorBrush Color="Transparent" />
</Setter.Value>
</Setter>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Cursor" Value="IBeam" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentBorder" Property="Background" Value="Transparent" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="Transparent" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Border
x:Name="MainBorder"
Height="48"
Margin="0,0,0,8"
HorizontalAlignment="Stretch"
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid Margin="12,0,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="64"/> <ColumnDefinition Width="48" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="36"/> <ColumnDefinition Width="40" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock x:Name="FormatNameTextBlock" <TextBlock
Opacity="0.6" x:Name="FormatNameTextBlock"
Style="{DynamicResource BodyStrongTextBlockStyle}" VerticalAlignment="Center"
Foreground="{DynamicResource PrimaryForegroundBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Margin="8" Style="{StaticResource CaptionTextBlockStyle}"
VerticalAlignment="Center"/> TextTrimming="CharacterEllipsis" />
<TextBox x:Name="ColorTextRepresentationTextBlock" <TextBox
FontFamily="Consolas" x:Name="ColorTextRepresentationTextBlock"
FontSize="14"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Grid.Column="1" Grid.Column="1"
IsTabStop="False" Margin="0,-2,0,0"
VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.Color_Code}"
Background="Transparent" Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
VerticalAlignment="Center" IsTabStop="False"
Padding="8" Style="{StaticResource ReadonlyTextBoxStyle}" />
AutomationProperties.Name="{x:Static p:Resources.Color_Code}"
/>
<Button x:Name="CopyToClipboardButton" <Button
ToolTipService.ToolTip="{x:Static p:Resources.Copy_to_clipboard}" x:Name="CopyToClipboardButton"
Background="{DynamicResource ColorControlBackgroundBrush}"
FontSize="16"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Opacity="0.6"
Height="36"
Width="36"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource DefaultButtonStyle}" Width="36"
Height="36"
Margin="0,0,4,0"
Padding="0"
AutomationProperties.HelpText="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Controls.ColorFormatControl}}, Path=SelectedColorCopyHelperText}"
AutomationProperties.Name="{x:Static p:Resources.Copy_to_clipboard}" AutomationProperties.Name="{x:Static p:Resources.Copy_to_clipboard}"
AutomationProperties.HelpText="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Controls.ColorFormatControl}}, Path=SelectedColorCopyHelperText}"> Background="Transparent"
BorderBrush="Transparent"
Style="{StaticResource SubtleButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Copy_to_clipboard}">
<Button.Content> <Button.Content>
<TextBlock Text="&#xE8C8;" AutomationProperties.Name="{x:Static p:Resources.Copy_to_clipboard}" /> <ui:SymbolIcon FontSize="20" Symbol="Copy20" />
</Button.Content> </Button.Content>
</Button> </Button>
</Grid> </Grid>
<Border.Effect>
<DropShadowEffect BlurRadius="6" Opacity="0.24" ShadowDepth="1" />
</Border.Effect>
</Border> </Border>
</UserControl> </UserControl>

View File

@@ -4,6 +4,7 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Automation.Peers; using System.Windows.Automation.Peers;
using System.Windows.Controls; using System.Windows.Controls;
@@ -111,10 +112,11 @@ namespace ColorPicker.Controls
return; return;
} }
var peer = UIElementAutomationPeer.FromElement(clipboardNotification); var innerTextBlock = ((StackPanel)clipboardNotification).Children.OfType<TextBlock>().FirstOrDefault();
var peer = UIElementAutomationPeer.FromElement(innerTextBlock);
if (peer == null) if (peer == null)
{ {
peer = UIElementAutomationPeer.CreatePeerForElement(clipboardNotification); peer = UIElementAutomationPeer.CreatePeerForElement(innerTextBlock);
} }
peer.RaiseAutomationEvent(AutomationEvents.MenuOpened); peer.RaiseAutomationEvent(AutomationEvents.MenuOpened);

View File

@@ -1,457 +1,392 @@
<UserControl x:Class="ColorPicker.Controls.ColorPickerControl" <UserControl
x:Class="ColorPicker.Controls.ColorPickerControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ColorPicker.Controls" xmlns:helpers="clr-namespace:ColorPicker.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:ColorPicker.Properties" xmlns:p="clr-namespace:ColorPicker.Properties"
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
TabIndex="3"
AutomationProperties.Name="{x:Static p:Resources.Color_Palette}" AutomationProperties.Name="{x:Static p:Resources.Color_Palette}"
FocusManager.IsFocusScope="True" FocusManager.IsFocusScope="True"
KeyboardNavigation.TabNavigation="Once"> KeyboardNavigation.TabNavigation="Once"
TabIndex="3"
mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<Style TargetType="{x:Type Slider}">
<Style TargetType="Thumb" <Setter Property="MinWidth" Value="104" />
x:Key="SliderThumbStyle"> <Setter Property="MinHeight" Value="21" />
<Setter Property="BorderThickness" <Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
Value="4" /> <Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Background" <Setter Property="OverridesDefaultStyle" Value="True" />
Value="{DynamicResource SliderThumbBackground}" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Thumb"> <ControlTemplate TargetType="{x:Type Slider}">
<Border Background="Transparent" <Grid>
BorderBrush="{DynamicResource PrimaryForegroundBrush}" <Grid.RowDefinitions>
BorderThickness="{TemplateBinding BorderThickness}" <RowDefinition Height="Auto" />
CornerRadius="{DynamicResource SliderThumbCornerRadius}" /> <RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TickBar
x:Name="TopTick"
Grid.Row="0"
Height="6"
Fill="Transparent"
Placement="Top"
SnapsToDevicePixels="True"
Visibility="Collapsed" />
<Border
x:Name="TrackBackground"
Grid.Row="1"
Height="8"
Margin="0"
Background="{TemplateBinding Background}"
BorderThickness="0"
CornerRadius="4" />
<Track x:Name="PART_Track" Grid.Row="1">
<Track.DecreaseRepeatButton>
<RepeatButton Command="Slider.DecreaseLarge">
<RepeatButton.Style>
<Style TargetType="{x:Type RepeatButton}">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
</RepeatButton.Style>
<ControlTemplate x:Key="SliderHorizontal" </RepeatButton>
TargetType="Slider">
<Grid Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid x:Name="SliderContainer"
Grid.Row="1"
Background="Transparent"
ui:FocusVisualHelper.IsTemplateFocusTarget="True">
<Border Background="{TemplateBinding Background}"
Margin="1,0,1,0"
CornerRadius="6"
VerticalAlignment="Center"
Height="12">
<Border.Effect>
<DropShadowEffect BlurRadius="6"
Opacity="0.32"
ShadowDepth="2" />
</Border.Effect>
</Border>
<Grid x:Name="HorizontalTemplate"
MinHeight="{DynamicResource SliderHorizontalHeight}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle x:Name="HorizontalTrackRect"
Fill="Transparent"
Height="{DynamicResource SliderTrackThemeHeight}"
Grid.Row="1"
Grid.ColumnSpan="3" />
<Rectangle x:Name="HorizontalDecreaseRect"
Width="{Binding ActualWidth, ElementName=HorizontalDecrease}"
Fill="Transparent"
Grid.Row="1" />
<TickBar x:Name="TopTickBar"
Placement="Top"
Visibility="Collapsed"
Fill="{DynamicResource SliderTickBarFill}"
Height="{DynamicResource SliderOutsideTickBarThemeHeight}"
VerticalAlignment="Bottom"
Margin="0,0,0,4"
Grid.ColumnSpan="3" />
<TickBar x:Name="BottomTickBar"
Placement="Bottom"
Visibility="Collapsed"
Fill="{DynamicResource SliderTickBarFill}"
Height="{DynamicResource SliderOutsideTickBarThemeHeight}"
VerticalAlignment="Top"
Margin="0,4,0,0"
Grid.Row="2"
Grid.ColumnSpan="3" />
<Track x:Name="PART_Track"
Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="0"
Grid.ColumnSpan="3">
<Track.DecreaseRepeatButton>
<RepeatButton x:Name="HorizontalDecrease"
Command="{x:Static Slider.DecreaseLarge}"
Style="{StaticResource RepeatButtonTransparent}" />
</Track.DecreaseRepeatButton> </Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}"
Style="{StaticResource RepeatButtonTransparent}" />
</Track.IncreaseRepeatButton>
<Track.Thumb> <Track.Thumb>
<Thumb x:Name="HorizontalThumb" <Thumb x:Name="Thumb">
Style="{StaticResource SliderThumbStyle}" <Thumb.Style>
DataContext="{TemplateBinding Value}" <Style TargetType="{x:Type Thumb}">
Height="20" <Setter Property="Height" Value="20" />
VerticalAlignment="Center" <Setter Property="Width" Value="20" />
Margin="0,0,0,0" <Setter Property="SnapsToDevicePixels" Value="True" />
Width="20" <Setter Property="OverridesDefaultStyle" Value="True" />
ui:FocusVisualHelper.FocusVisualMargin="-14,-6,-14,-6"> <Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Thumb.Resources> <Setter Property="Foreground" Value="Black" />
<Style TargetType="ToolTip" <Setter Property="BorderThickness" Value="1" />
BasedOn="{StaticResource SliderAutoToolTipStyle}" /> <Setter Property="Background" Value="{DynamicResource SliderOuterThumbBackground}" />
</Thumb.Resources> <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="16">
<Ellipse
x:Name="Ellipse"
Width="12"
Height="12"
Fill="{TemplateBinding Foreground}"
Stroke="Transparent"
StrokeThickness="0" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb> </Thumb>
</Track.Thumb> </Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="Slider.IncreaseLarge">
<RepeatButton.Style>
<Style TargetType="{x:Type RepeatButton}">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</RepeatButton.Style>
</RepeatButton>
</Track.IncreaseRepeatButton>
</Track> </Track>
</Grid> <TickBar
</Grid> x:Name="BottomTick"
Grid.Row="2"
Height="6"
Fill="Transparent"
Placement="Bottom"
SnapsToDevicePixels="True"
Visibility="Collapsed" />
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="TickPlacement" <Trigger Property="TickPlacement" Value="TopLeft">
Value="TopLeft"> <Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
<Setter TargetName="TopTickBar"
Property="Visibility"
Value="Visible" />
</Trigger> </Trigger>
<Trigger Property="TickPlacement" <Trigger Property="TickPlacement" Value="BottomRight">
Value="BottomRight"> <Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
<Setter TargetName="BottomTickBar"
Property="Visibility"
Value="Visible" />
</Trigger> </Trigger>
<Trigger Property="TickPlacement" <Trigger Property="TickPlacement" Value="Both">
Value="Both"> <Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
<Setter TargetName="TopTickBar" <Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
Property="Visibility"
Value="Visible" />
<Setter TargetName="BottomTickBar"
Property="Visibility"
Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="HorizontalThumb"
Property="Opacity"
Value="0.8" />
</Trigger>
<Trigger SourceName="HorizontalThumb"
Property="IsDragging"
Value="True">
<Setter TargetName="HorizontalThumb"
Property="Opacity"
Value="0.6" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter TargetName="HorizontalDecreaseRect"
Property="Fill"
Value="{DynamicResource SliderTrackValueFillDisabled}" />
<Setter TargetName="HorizontalTrackRect"
Property="Fill"
Value="{DynamicResource SliderTrackFillDisabled}" />
<Setter TargetName="HorizontalThumb"
Property="Background"
Value="{DynamicResource SliderThumbBackgroundDisabled}" />
<Setter TargetName="TopTickBar"
Property="Fill"
Value="{DynamicResource SliderTickBarFillDisabled}" />
<Setter TargetName="BottomTickBar"
Property="Fill"
Value="{DynamicResource SliderTickBarFillDisabled}" />
<Setter TargetName="SliderContainer"
Property="Background"
Value="{DynamicResource SliderContainerBackgroundDisabled}" />
</Trigger> </Trigger>
<Trigger Property="IsMouseOver" Value="True" />
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value>
</Setter>
<Style x:Key="CustomSLiderStyle"
TargetType="Slider">
<Setter Property="OverridesDefaultStyle"
Value="True" />
<Setter Property="Stylus.IsPressAndHoldEnabled"
Value="false" />
<Setter Property="Background"
Value="{DynamicResource SliderTrackFill}" />
<Setter Property="BorderThickness"
Value="{DynamicResource SliderBorderThemeThickness}" />
<Setter Property="Foreground"
Value="{DynamicResource SliderTrackValueFill}" />
<Setter Property="FontFamily"
Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize"
Value="{DynamicResource ControlContentThemeFontSize}" />
<!--<Setter Property="ManipulationMode" Value="None" />-->
<Setter Property="FocusVisualStyle"
Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="ui:FocusVisualHelper.UseSystemFocusVisuals"
Value="{DynamicResource UseSystemFocusVisuals}" />
<Setter Property="ui:FocusVisualHelper.FocusVisualMargin"
Value="-7,0,-7,0" />
<Setter Property="ui:ControlHelper.CornerRadius"
Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Template"
Value="{StaticResource SliderHorizontal}" />
<Style.Triggers>
<Trigger Property="Orientation"
Value="Vertical">
<Setter Property="Template"
Value="{StaticResource SliderVertical}" />
</Trigger>
</Style.Triggers>
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid x:Name="PickerPanel" <Border
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{DynamicResource ControlCornerRadius}">
<Grid
x:Name="PickerPanel"
Height="248"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Margin="12,2,12,2"> ClipToBounds="True"
<Grid.Effect> Opacity="1">
<DropShadowEffect BlurRadius="6" <Grid.RowDefinitions>
Opacity="0.32" <RowDefinition Height="36" />
ShadowDepth="2" /> <RowDefinition Height="36" />
</Grid.Effect> <RowDefinition Height="*" />
<Grid.ColumnDefinitions> <RowDefinition Height="36" />
<ColumnDefinition Width="46" /> <RowDefinition Height="36" />
<ColumnDefinition Width="46" /> </Grid.RowDefinitions>
<ColumnDefinition Width="165" />
<ColumnDefinition Width="46" />
<ColumnDefinition Width="46" />
</Grid.ColumnDefinitions>
<Button x:Name="colorVariation1Button" <Button
x:Name="colorVariation1Button"
Grid.Column="0" Grid.Column="0"
TabIndex="3" helpers:ControlHelper.CornerRadius="4,4,0,0"
ui:ControlHelper.CornerRadius="2,0,0,2"
Background="LightPink"
Click="ColorVariationButton_Click"
AutomationProperties.Name="{x:Static p:Resources.Lightest_color}" AutomationProperties.Name="{x:Static p:Resources.Lightest_color}"
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button x:Name="colorVariation2Button"
Grid.Column="1"
ui:ControlHelper.CornerRadius="0"
Background="LightPink" Background="LightPink"
Click="ColorVariationButton_Click" Click="ColorVariationButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}"
TabIndex="3"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button
x:Name="colorVariation2Button"
Grid.Row="1"
AutomationProperties.Name="{x:Static p:Resources.Lighter_color}" AutomationProperties.Name="{x:Static p:Resources.Lighter_color}"
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button x:Name="colorVariation3Button"
Grid.Column="3"
ui:ControlHelper.CornerRadius="0"
Background="LightPink" Background="LightPink"
Click="ColorVariationButton_Click" Click="ColorVariationButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button
x:Name="colorVariation3Button"
Grid.Row="3"
AutomationProperties.Name="{x:Static p:Resources.Darker_color}" AutomationProperties.Name="{x:Static p:Resources.Darker_color}"
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button x:Name="colorVariation4Button"
Grid.Column="4"
ui:ControlHelper.CornerRadius="0,2,2,0"
Background="LightPink" Background="LightPink"
Click="ColorVariationButton_Click" Click="ColorVariationButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button
x:Name="colorVariation4Button"
Grid.Row="4"
helpers:ControlHelper.CornerRadius="0,0,4,4"
AutomationProperties.Name="{x:Static p:Resources.Darkest_color}" AutomationProperties.Name="{x:Static p:Resources.Darkest_color}"
Background="LightPink"
Click="ColorVariationButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}" Style="{DynamicResource ColorShadeButtonStyle}"
ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" /> ToolTipService.ToolTip="{x:Static p:Resources.Select_color}" />
<Button x:Name="CurrentColorButton" <Button
HorizontalAlignment="Left" x:Name="CurrentColorButton"
Grid.Column="0" Grid.RowSpan="5"
Grid.ColumnSpan="5" Height="104"
ui:ControlHelper.CornerRadius="0" Margin="0,72,0,72"
Background="Red" VerticalAlignment="Top"
Width="165"
Height="48"
Margin="92,0,0,0"
AutomationProperties.Name="{x:Static p:Resources.Selected_color}"
AutomationProperties.HelpText="{x:Static p:Resources.Selected_color_helptext}" AutomationProperties.HelpText="{x:Static p:Resources.Selected_color_helptext}"
ToolTipService.ToolTip="{x:Static p:Resources.Selected_color_tooltip}" AutomationProperties.Name="{x:Static p:Resources.Selected_color}"
Click="CurrentColorButton_Click" Click="CurrentColorButton_Click"
Style="{DynamicResource ColorShadeButtonStyle}"> Style="{DynamicResource ColorShadeButtonStyle}"
<ui:FlyoutService.Flyout> ToolTipService.ToolTip="{x:Static p:Resources.Selected_color_tooltip}">
<ui:Flyout x:Name="DetailsFlyout"
Placement="Bottom" <ui:Flyout
x:Name="DetailsFlyout"
Closed="DetailsFlyout_Closed"
Opened="DetailsFlyout_Opened" Opened="DetailsFlyout_Opened"
Closed="DetailsFlyout_Closed"> Placement="Top">
<Grid Margin="0,4,0,12" <Grid x:Name="detailsGrid" KeyboardNavigation.TabNavigation="Contained">
KeyboardNavigation.TabNavigation="Contained" <Grid.ColumnDefinitions>
x:Name="detailsGrid"> <ColumnDefinition Width="44" />
<StackPanel x:Name="detailsStackPanel"> <ColumnDefinition Width="86" />
<ColumnDefinition Width="86" />
<ColumnDefinition Width="86" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="8" />
<RowDefinition Height="Auto" />
<RowDefinition Height="8" />
<RowDefinition Height="Auto" />
<RowDefinition Height="12" />
<RowDefinition Height="Auto" />
<RowDefinition Height="12" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"> <TextBlock
<TextBlock Text="H"
Width="38"
FontWeight="SemiBold"
TextAlignment="Center"
VerticalAlignment="Center" />
<Slider x:Name="HueGradientSlider"
Width="214"
IsMoveToPointEnabled="True"
AutomationProperties.Name="{x:Static p:Resources.Hue_slider}"
Style="{StaticResource CustomSLiderStyle}"
ValueChanged="HueGradientSlider_ValueChanged"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="H"
TextAlignment="Center" />
<Slider
x:Name="HueGradientSlider"
Grid.Column="1" Grid.Column="1"
Grid.ColumnSpan="3"
VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.Hue_slider}"
IsMoveToPointEnabled="True"
Maximum="289"
Minimum="0" Minimum="0"
Maximum="289" /> ValueChanged="HueGradientSlider_ValueChanged" />
</StackPanel>
<StackPanel Orientation="Horizontal"> <TextBlock
<TextBlock Text="S" Grid.Row="2"
Grid.Row="1" VerticalAlignment="Center"
Width="38" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextAlignment="Center" Style="{StaticResource CaptionTextBlockStyle}"
FontWeight="SemiBold" Text="S"
VerticalAlignment="Center" /> TextAlignment="Center" />
<Slider x:Name="SaturationGradientSlider" <Slider
x:Name="SaturationGradientSlider"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="3"
AutomationProperties.Name="{x:Static p:Resources.Saturation_slider}" AutomationProperties.Name="{x:Static p:Resources.Saturation_slider}"
Style="{StaticResource CustomSLiderStyle}"
ValueChanged="SaturationGradientSlider_ValueChanged"
Grid.Column="1"
Width="214"
IsMoveToPointEnabled="True" IsMoveToPointEnabled="True"
Grid.Row="1" Maximum="289"
Minimum="0" Minimum="0"
Maximum="289"> ValueChanged="SaturationGradientSlider_ValueChanged">
<Slider.Background> <Slider.Background>
<LinearGradientBrush EndPoint="1,0.5" <LinearGradientBrush StartPoint="0, 0.5" EndPoint="1,0.5">
StartPoint="0, 0.5"> <GradientStop x:Name="SaturationStartColor" Color="Black" />
<GradientStop x:Name="SaturationStartColor" <GradientStop x:Name="SaturationStopColor" Offset="1" Color="Red" />
Color="Black" />
<GradientStop x:Name="SaturationStopColor"
Color="Red"
Offset="1" />
</LinearGradientBrush> </LinearGradientBrush>
</Slider.Background> </Slider.Background>
</Slider> </Slider>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="V"
Grid.Row="2"
Width="38"
TextAlignment="Center"
FontWeight="SemiBold"
VerticalAlignment="Center" />
<Slider x:Name="ValueGradientSlider" <TextBlock
Grid.Row="4"
VerticalAlignment="Center"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="V"
TextAlignment="Center" />
<Slider
x:Name="ValueGradientSlider"
Grid.Row="4"
Grid.Column="1"
Grid.ColumnSpan="3"
AutomationProperties.Name="{x:Static p:Resources.Value_slider}" AutomationProperties.Name="{x:Static p:Resources.Value_slider}"
Style="{StaticResource CustomSLiderStyle}"
ValueChanged="ValueGradientSlider_ValueChanged"
Grid.Column="1"
IsMoveToPointEnabled="True" IsMoveToPointEnabled="True"
Grid.Row="2" Maximum="289"
Width="214"
Minimum="0" Minimum="0"
Maximum="289"> ValueChanged="ValueGradientSlider_ValueChanged">
<Slider.Background> <Slider.Background>
<LinearGradientBrush EndPoint="1,0.5" <LinearGradientBrush StartPoint="0, 0.5" EndPoint="1,0.5">
StartPoint="0, 0.5"> <GradientStop x:Name="ValueStartColor" Color="Black" />
<GradientStop x:Name="ValueStartColor" <GradientStop x:Name="ValueStopColor" Offset="1" Color="Red" />
Color="Black" />
<GradientStop x:Name="ValueStopColor"
Color="Red"
Offset="1" />
</LinearGradientBrush> </LinearGradientBrush>
</Slider.Background> </Slider.Background>
</Slider> </Slider>
</StackPanel>
<TextBlock
Grid.Row="6"
VerticalAlignment="Center"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="RGB"
TextAlignment="Center" />
<StackPanel Orientation="Horizontal" <ui:NumberBox
Margin="0,16,0,0"> x:Name="RNumberBox"
<TextBlock Text="RGB" Grid.Row="6"
Width="38" Grid.Column="1"
FontWeight="SemiBold"
TextAlignment="Center"
VerticalAlignment="Center" />
<ui:NumberBox x:Name="RNumberBox"
Height="32"
Width="72"
ui:ControlHelper.CornerRadius="2,0,0,2"
AutomationProperties.Name="{x:Static p:Resources.Red_value}" AutomationProperties.Name="{x:Static p:Resources.Red_value}"
TextBoxBase.TextChanged="RGBNumberBox_TextChanged" Maximum="255"
Minimum="0" Minimum="0"
Maximum="255" /> SpinButtonPlacementMode="Compact"
TextBoxBase.TextChanged="RGBNumberBox_TextChanged" />
<ui:NumberBox x:Name="GNumberBox" <ui:NumberBox
Height="32" x:Name="GNumberBox"
Margin="-1,0,0,0" Grid.Row="6"
Width="72" Grid.Column="2"
ui:ControlHelper.CornerRadius="0" Margin="4,0,0,0"
AutomationProperties.Name="{x:Static p:Resources.Green_value}" AutomationProperties.Name="{x:Static p:Resources.Green_value}"
TextBoxBase.TextChanged="RGBNumberBox_TextChanged" Maximum="255"
Minimum="0" Minimum="0"
Maximum="255" /> SpinButtonPlacementMode="Compact"
TextBoxBase.TextChanged="RGBNumberBox_TextChanged" />
<ui:NumberBox x:Name="BNumberBox" <ui:NumberBox
Height="32" x:Name="BNumberBox"
Width="72" Grid.Row="6"
Margin="-1,0,0,0" Grid.Column="3"
ui:ControlHelper.CornerRadius="0,2,2,0" Margin="4,0,0,0"
AutomationProperties.Name="{x:Static p:Resources.Blue_value}" AutomationProperties.Name="{x:Static p:Resources.Blue_value}"
TextBoxBase.TextChanged="RGBNumberBox_TextChanged" Maximum="255"
Minimum="0" Minimum="0"
Maximum="255" /> SpinButtonPlacementMode="Compact"
</StackPanel> TextBoxBase.TextChanged="RGBNumberBox_TextChanged" />
<StackPanel Orientation="Horizontal" <TextBlock
Margin="0,16,0,0"> Grid.Row="8"
<TextBlock Text="HEX"
Width="38" Width="38"
TextAlignment="Center" VerticalAlignment="Center"
FontWeight="SemiBold" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
VerticalAlignment="Center" /> Style="{StaticResource CaptionTextBlockStyle}"
<TextBox x:Name="HexCode" Text="HEX"
Height="32" TextAlignment="Center" />
Width="214" <TextBox
x:Name="HexCode"
Grid.Row="8"
Grid.Column="1"
Grid.ColumnSpan="3"
HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Static p:Resources.Hex_value}" AutomationProperties.Name="{x:Static p:Resources.Hex_value}"
CharacterCasing="Lower"
GotKeyboardFocus="HexCode_GotKeyboardFocus" GotKeyboardFocus="HexCode_GotKeyboardFocus"
TextChanged="HexCode_TextChanged"
TextWrapping="Wrap"
MaxLength="7" MaxLength="7"
CharacterCasing="Lower" /> TextChanged="HexCode_TextChanged"
</StackPanel> TextWrapping="Wrap" />
<Button Margin="0,32,0,0" <ui:Button
x:Name="OKButton" x:Name="OKButton"
Click="OKButton_Click" Grid.Row="9"
Style="{StaticResource AccentButtonStyle}" Grid.ColumnSpan="4"
Margin="0,32,0,0"
HorizontalAlignment="Stretch"
Appearance="Primary"
AutomationProperties.Name="{x:Static p:Resources.Select}" AutomationProperties.Name="{x:Static p:Resources.Select}"
Content="{x:Static p:Resources.Select}" Click="OKButton_Click"
HorizontalAlignment="Stretch" /> Content="{x:Static p:Resources.Select}" />
</StackPanel>
</Grid> </Grid>
</ui:Flyout> </ui:Flyout>
</ui:FlyoutService.Flyout>
</Button> </Button>
</Grid> </Grid>
</Border>
</UserControl> </UserControl>

View File

@@ -13,8 +13,8 @@ using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using ColorPicker.Helpers; using ColorPicker.Helpers;
using ManagedCommon; using ManagedCommon;
using ModernWpf.Controls; using Wpf.Ui.Controls;
using ModernWpf.Controls.Primitives; using static System.Net.Mime.MediaTypeNames;
namespace ColorPicker.Controls namespace ColorPicker.Controls
{ {
@@ -74,9 +74,9 @@ namespace ColorPicker.Controls
control._ignoreRGBChanges = true; control._ignoreRGBChanges = true;
control.HexCode.Text = ColorToHex(newColor); control.HexCode.Text = ColorToHex(newColor);
control.RNumberBox.Text = newColor.R.ToString(CultureInfo.InvariantCulture); control.RNumberBox.Value = newColor.R;
control.GNumberBox.Text = newColor.G.ToString(CultureInfo.InvariantCulture); control.GNumberBox.Value = newColor.G;
control.BNumberBox.Text = newColor.B.ToString(CultureInfo.InvariantCulture); control.BNumberBox.Value = newColor.B;
control.SetColorFromTextBoxes(System.Drawing.Color.FromArgb(newColor.R, newColor.G, newColor.B)); control.SetColorFromTextBoxes(System.Drawing.Color.FromArgb(newColor.R, newColor.G, newColor.B));
control._ignoreRGBChanges = false; control._ignoreRGBChanges = false;
@@ -173,9 +173,9 @@ namespace ColorPicker.Controls
if (!_ignoreRGBChanges) if (!_ignoreRGBChanges)
{ {
RNumberBox.Text = currentColor.R.ToString(CultureInfo.InvariantCulture); RNumberBox.Value = currentColor.R;
GNumberBox.Text = currentColor.G.ToString(CultureInfo.InvariantCulture); GNumberBox.Value = currentColor.G;
BNumberBox.Text = currentColor.B.ToString(CultureInfo.InvariantCulture); BNumberBox.Value = currentColor.B;
} }
_currentColor = currentColor; _currentColor = currentColor;
@@ -193,17 +193,17 @@ namespace ColorPicker.Controls
{ {
_isCollapsed = false; _isCollapsed = false;
var resizeColor = new DoubleAnimation(349, new Duration(TimeSpan.FromMilliseconds(250))); var resizeColor = new DoubleAnimation(256, new Duration(TimeSpan.FromMilliseconds(250)));
resizeColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut }; resizeColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut };
var moveColor = new ThicknessAnimation(new Thickness(0), new Duration(TimeSpan.FromMilliseconds(250))); var moveColor = new ThicknessAnimation(new Thickness(0), new Duration(TimeSpan.FromMilliseconds(250)));
moveColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut }; moveColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut };
ControlHelper.SetCornerRadius(CurrentColorButton, new CornerRadius(2)); CurrentColorButton.BeginAnimation(System.Windows.Controls.Button.HeightProperty, resizeColor);
CurrentColorButton.BeginAnimation(Button.WidthProperty, resizeColor); CurrentColorButton.BeginAnimation(System.Windows.Controls.Button.MarginProperty, moveColor);
CurrentColorButton.BeginAnimation(Button.MarginProperty, moveColor);
CurrentColorButton.IsEnabled = false; CurrentColorButton.IsEnabled = false;
SessionEventHelper.Event.EditorAdjustColorOpened = true; SessionEventHelper.Event.EditorAdjustColorOpened = true;
DetailsFlyout.IsOpen = true;
} }
} }
@@ -216,19 +216,17 @@ namespace ColorPicker.Controls
var resizeColor = new DoubleAnimation(165, new Duration(TimeSpan.FromMilliseconds(150))); var resizeColor = new DoubleAnimation(165, new Duration(TimeSpan.FromMilliseconds(150)));
resizeColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut }; resizeColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut };
var moveColor = new ThicknessAnimation(new Thickness(92, 0, 0, 0), new Duration(TimeSpan.FromMilliseconds(150))); var moveColor = new ThicknessAnimation(new Thickness(0, 72, 0, 72), new Duration(TimeSpan.FromMilliseconds(150)));
moveColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut }; moveColor.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut };
ControlHelper.SetCornerRadius(CurrentColorButton, new CornerRadius(0)); CurrentColorButton.BeginAnimation(System.Windows.Controls.Button.HeightProperty, resizeColor);
CurrentColorButton.BeginAnimation(Button.WidthProperty, resizeColor); CurrentColorButton.BeginAnimation(System.Windows.Controls.Button.MarginProperty, moveColor);
CurrentColorButton.BeginAnimation(Button.MarginProperty, moveColor);
CurrentColorButton.IsEnabled = true; CurrentColorButton.IsEnabled = true;
} }
} }
private void OKButton_Click(object sender, RoutedEventArgs e) private void OKButton_Click(object sender, RoutedEventArgs e)
{ {
HideDetails();
SelectedColorChangedCommand.Execute(_currentColor); SelectedColorChangedCommand.Execute(_currentColor);
SessionEventHelper.Event.EditorColorAdjusted = true; SessionEventHelper.Event.EditorColorAdjusted = true;
DetailsFlyout.Hide(); DetailsFlyout.Hide();
@@ -253,7 +251,7 @@ namespace ColorPicker.Controls
private void ColorVariationButton_Click(object sender, RoutedEventArgs e) private void ColorVariationButton_Click(object sender, RoutedEventArgs e)
{ {
var selectedColor = ((SolidColorBrush)((Button)sender).Background).Color; var selectedColor = ((SolidColorBrush)((System.Windows.Controls.Button)sender).Background).Color;
SelectedColorChangedCommand.Execute(selectedColor); SelectedColorChangedCommand.Execute(selectedColor);
SessionEventHelper.Event.EditorSimilarColorPicked = true; SessionEventHelper.Event.EditorSimilarColorPicked = true;
} }
@@ -284,7 +282,7 @@ namespace ColorPicker.Controls
private void HexCode_TextChanged(object sender, TextChangedEventArgs e) private void HexCode_TextChanged(object sender, TextChangedEventArgs e)
{ {
var newValue = (sender as TextBox).Text; var newValue = (sender as System.Windows.Controls.TextBox).Text;
// support hex with 3 and 6 characters and optional with hashtag // support hex with 3 and 6 characters and optional with hashtag
var reg = new Regex("^#?([0-9A-Fa-f]{3}){1,2}$"); var reg = new Regex("^#?([0-9A-Fa-f]{3}){1,2}$");
@@ -362,9 +360,11 @@ namespace ColorPicker.Controls
if (!_ignoreRGBChanges) if (!_ignoreRGBChanges)
{ {
var numberBox = sender as NumberBox; var numberBox = sender as NumberBox;
var r = numberBox.Name == "RNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)RNumberBox.Value;
var g = numberBox.Name == "GNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)GNumberBox.Value; byte r = numberBox.Name == "RNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)RNumberBox.Value;
var b = numberBox.Name == "BNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)BNumberBox.Value; byte g = numberBox.Name == "GNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)GNumberBox.Value;
byte b = numberBox.Name == "BNumberBox" ? GetValueFromNumberBox(numberBox) : (byte)BNumberBox.Value;
_ignoreRGBChanges = true; _ignoreRGBChanges = true;
SetColorFromTextBoxes(System.Drawing.Color.FromArgb(r, g, b)); SetColorFromTextBoxes(System.Drawing.Color.FromArgb(r, g, b));
_ignoreRGBChanges = false; _ignoreRGBChanges = false;
@@ -379,11 +379,12 @@ namespace ColorPicker.Controls
/// <returns>Validated value as per numberbox conditions, if content is invalid it returns previous value</returns> /// <returns>Validated value as per numberbox conditions, if content is invalid it returns previous value</returns>
private static byte GetValueFromNumberBox(NumberBox numberBox) private static byte GetValueFromNumberBox(NumberBox numberBox)
{ {
var internalTextBox = GetChildOfType<TextBox>(numberBox); double? parsedValue = ParseDouble(numberBox.Text);
var parsedValue = numberBox.NumberFormatter.ParseDouble(internalTextBox.Text);
if (parsedValue != null) if (parsedValue != null)
{ {
var parsedValueByte = (byte)parsedValue; var parsedValueByte = (byte)parsedValue;
if (parsedValueByte >= numberBox.Minimum && parsedValueByte <= numberBox.Maximum) if (parsedValueByte >= numberBox.Minimum && parsedValueByte <= numberBox.Maximum)
{ {
return parsedValueByte; return parsedValueByte;
@@ -394,6 +395,16 @@ namespace ColorPicker.Controls
return (byte)numberBox.Value; return (byte)numberBox.Value;
} }
public static double? ParseDouble(string text)
{
if (double.TryParse(text, out double result))
{
return result;
}
return null;
}
public static T GetChildOfType<T>(DependencyObject depObj) public static T GetChildOfType<T>(DependencyObject depObj)
where T : DependencyObject where T : DependencyObject
{ {

View File

@@ -150,7 +150,7 @@ namespace ColorPicker.Helpers
if (_colorEditorWindow == null) if (_colorEditorWindow == null)
{ {
_colorEditorWindow = new ColorEditorWindow(this); _colorEditorWindow = new ColorEditorWindow(this);
_colorEditorWindow.Content = _colorEditorViewModel; _colorEditorWindow.contentPresenter.Content = _colorEditorViewModel;
_colorEditorViewModel.OpenColorPickerRequested += ColorEditorViewModel_OpenColorPickerRequested; _colorEditorViewModel.OpenColorPickerRequested += ColorEditorViewModel_OpenColorPickerRequested;
_colorEditorViewModel.OpenSettingsRequested += ColorEditorViewModel_OpenSettingsRequested; _colorEditorViewModel.OpenSettingsRequested += ColorEditorViewModel_OpenSettingsRequested;
_colorEditorViewModel.OpenColorPickerRequested += (object sender, EventArgs e) => _colorEditorViewModel.OpenColorPickerRequested += (object sender, EventArgs e) =>

View File

@@ -0,0 +1,317 @@
// 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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ColorPicker.Helpers
{
public static class ControlHelper
{
/// <summary>
/// Gets the radius for the corners of the control's border.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>
/// The degree to which the corners are rounded, expressed as values of the CornerRadius
/// structure.
/// </returns>
public static CornerRadius GetCornerRadius(Control control)
{
return (CornerRadius)control.GetValue(CornerRadiusProperty);
}
/// <summary>
/// Sets the radius for the corners of the control's border.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetCornerRadius(Control control, CornerRadius value)
{
control.SetValue(CornerRadiusProperty, value);
}
/// <summary>
/// Identifies the CornerRadius dependency property.
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.RegisterAttached(
"CornerRadius",
typeof(CornerRadius),
typeof(ControlHelper),
null);
/// <summary>
/// Identifies the Header dependency property.
/// </summary>
public static readonly DependencyProperty HeaderProperty =
DependencyProperty.RegisterAttached(
"Header",
typeof(object),
typeof(ControlHelper),
new FrameworkPropertyMetadata(OnHeaderChanged));
/// <summary>
/// Gets the content for the control's header.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>The content of the control's header. The default is **null**.</returns>
public static object GetHeader(Control control)
{
return control.GetValue(HeaderProperty);
}
/// <summary>
/// Sets the content for the control's header.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetHeader(Control control, object value)
{
control.SetValue(HeaderProperty, value);
}
private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
UpdateHeaderVisibility((Control)d);
}
/// <summary>
/// Identifies the HeaderTemplate dependency property.
/// </summary>
public static readonly DependencyProperty HeaderTemplateProperty =
DependencyProperty.RegisterAttached(
"HeaderTemplate",
typeof(DataTemplate),
typeof(ControlHelper),
new FrameworkPropertyMetadata(OnHeaderTemplateChanged));
/// <summary>
/// Gets the DataTemplate used to display the content of the control's header.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>
/// The template that specifies the visualization of the header object. The default
/// is **null**.
/// </returns>
public static DataTemplate GetHeaderTemplate(Control control)
{
return (DataTemplate)control.GetValue(HeaderTemplateProperty);
}
/// <summary>
/// Sets the DataTemplate used to display the content of the control's header.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetHeaderTemplate(Control control, DataTemplate value)
{
control.SetValue(HeaderTemplateProperty, value);
}
private static void OnHeaderTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
UpdateHeaderVisibility((Control)d);
}
private static readonly DependencyPropertyKey HeaderVisibilityPropertyKey =
DependencyProperty.RegisterAttachedReadOnly(
"HeaderVisibility",
typeof(Visibility),
typeof(ControlHelper),
new FrameworkPropertyMetadata(Visibility.Collapsed));
public static readonly DependencyProperty HeaderVisibilityProperty =
HeaderVisibilityPropertyKey.DependencyProperty;
public static Visibility GetHeaderVisibility(Control control)
{
return (Visibility)control.GetValue(HeaderVisibilityProperty);
}
private static void SetHeaderVisibility(Control control, Visibility value)
{
control.SetValue(HeaderVisibilityPropertyKey, value);
}
private static void UpdateHeaderVisibility(Control control)
{
Visibility visibility;
if (GetHeaderTemplate(control) != null)
{
visibility = Visibility.Visible;
}
else
{
visibility = IsNullOrEmptyString(GetHeader(control)) ? Visibility.Collapsed : Visibility.Visible;
}
SetHeaderVisibility(control, visibility);
}
/// <summary>
/// Gets the text that is displayed in the control until the value is changed
/// by a user action or some other operation.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>
/// The text that is displayed in the control when no value is entered. The default
/// is an empty string ("").
/// </returns>
public static string GetPlaceholderText(Control control)
{
return (string)control.GetValue(PlaceholderTextProperty);
}
/// <summary>
/// Sets the text that is displayed in the control until the value is changed
/// by a user action or some other operation.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetPlaceholderText(Control control, string value)
{
control.SetValue(PlaceholderTextProperty, value);
}
/// <summary>
/// Identifies the PlaceholderText dependency property.
/// </summary>
public static readonly DependencyProperty PlaceholderTextProperty =
DependencyProperty.RegisterAttached(
"PlaceholderText",
typeof(string),
typeof(ControlHelper),
new FrameworkPropertyMetadata(string.Empty, OnPlaceholderTextChanged));
private static void OnPlaceholderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
UpdatePlaceholderTextVisibility((Control)d);
}
public static Visibility GetPlaceholderTextVisibility(Control control)
{
return (Visibility)control.GetValue(PlaceholderTextVisibilityProperty);
}
private static void SetPlaceholderTextVisibility(Control control, Visibility value)
{
control.SetValue(PlaceholderTextVisibilityPropertyKey, value);
}
private static readonly DependencyPropertyKey PlaceholderTextVisibilityPropertyKey =
DependencyProperty.RegisterAttachedReadOnly(
"PlaceholderTextVisibility",
typeof(Visibility),
typeof(ControlHelper),
new FrameworkPropertyMetadata(Visibility.Collapsed));
public static readonly DependencyProperty PlaceholderTextVisibilityProperty =
PlaceholderTextVisibilityPropertyKey.DependencyProperty;
private static void UpdatePlaceholderTextVisibility(Control control)
{
SetPlaceholderTextVisibility(control, string.IsNullOrEmpty(GetPlaceholderText(control)) ? Visibility.Collapsed : Visibility.Visible);
}
/// <summary>
/// Gets a brush that describes the color of placeholder text.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>The brush that describes the color of placeholder text.</returns>
public static Brush GetPlaceholderForeground(Control control)
{
return (Brush)control.GetValue(PlaceholderForegroundProperty);
}
/// <summary>
/// Sets a brush that describes the color of placeholder text.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetPlaceholderForeground(Control control, Brush value)
{
control.SetValue(PlaceholderForegroundProperty, value);
}
/// <summary>
/// Identifies the PlaceholderForeground dependency property.
/// </summary>
public static readonly DependencyProperty PlaceholderForegroundProperty =
DependencyProperty.RegisterAttached(
"PlaceholderForeground",
typeof(Brush),
typeof(ControlHelper),
null);
/// <summary>
/// Gets content that is shown below the control. The content should provide
/// guidance about the input expected by the control.
/// </summary>
/// <param name="control">The element from which to read the property value.</param>
/// <returns>The content to be displayed below the control. The default is **null**.</returns>
public static object GetDescription(Control control)
{
return control.GetValue(DescriptionProperty);
}
/// <summary>
/// Sets content that is shown below the control. The content should provide
/// guidance about the input expected by the control.
/// </summary>
/// <param name="control">The element on which to set the attached property.</param>
/// <param name="value">The property value to set.</param>
public static void SetDescription(Control control, object value)
{
control.SetValue(DescriptionProperty, value);
}
/// <summary>
/// Identifies the Description dependency property.
/// </summary>
public static readonly DependencyProperty DescriptionProperty =
DependencyProperty.RegisterAttached(
"Description",
typeof(object),
typeof(ControlHelper),
new FrameworkPropertyMetadata(OnDescriptionChanged));
private static void OnDescriptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
UpdateDescriptionVisibility((Control)d);
}
private static readonly DependencyPropertyKey DescriptionVisibilityPropertyKey =
DependencyProperty.RegisterAttachedReadOnly(
"DescriptionVisibility",
typeof(Visibility),
typeof(ControlHelper),
new FrameworkPropertyMetadata(Visibility.Collapsed));
public static readonly DependencyProperty DescriptionVisibilityProperty =
DescriptionVisibilityPropertyKey.DependencyProperty;
public static Visibility GetDescriptionVisibility(Control control)
{
return (Visibility)control.GetValue(DescriptionVisibilityProperty);
}
private static void SetDescriptionVisibility(Control control, Visibility value)
{
control.SetValue(DescriptionVisibilityPropertyKey, value);
}
private static void UpdateDescriptionVisibility(Control control)
{
SetDescriptionVisibility(control, IsNullOrEmptyString(GetDescription(control)) ? Visibility.Collapsed : Visibility.Visible);
}
internal static bool IsNullOrEmptyString(object obj)
{
return obj == null || (obj is string s && string.IsNullOrEmpty(s));
}
}
}

View File

@@ -1,21 +1,26 @@
<Window x:Class="ColorPicker.MainWindow" <Window
x:Class="ColorPicker.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:ColorPicker.Behaviors" xmlns:behaviors="clr-namespace:ColorPicker.Behaviors"
WindowStyle="None" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Opacity="0.01" xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
ShowInTaskbar="False" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
ResizeMode="NoResize" Width="120"
Topmost="True" Height="64"
Background="Transparent" MinWidth="0"
SizeToContent="WidthAndHeight" MinHeight="0"
AllowsTransparency="True" AllowsTransparency="True"
AutomationProperties.Name="Color Picker"
Background="Transparent"
Opacity="0.1"
ResizeMode="NoResize"
ShowInTaskbar="False"
SizeToContent="WidthAndHeight"
SourceInitialized="MainWindowSourceInitialized" SourceInitialized="MainWindowSourceInitialized"
AutomationProperties.Name="Color Picker"> Topmost="True"
WindowStyle="None"
mc:Ignorable="d">
<e:Interaction.Behaviors> <e:Interaction.Behaviors>
<behaviors:ChangeWindowPositionBehavior /> <behaviors:ChangeWindowPositionBehavior />
<behaviors:AppearAnimationBehavior /> <behaviors:AppearAnimationBehavior />

View File

@@ -6,6 +6,7 @@ using System.ComponentModel.Composition;
using System.Windows; using System.Windows;
using System.Windows.Interop; using System.Windows.Interop;
using ColorPicker.ViewModelContracts; using ColorPicker.ViewModelContracts;
using Wpf.Ui.Controls;
namespace ColorPicker namespace ColorPicker
{ {
@@ -18,6 +19,7 @@ namespace ColorPicker
{ {
Closing += MainWindow_Closing; Closing += MainWindow_Closing;
Bootstrapper.InitializeContainer(this); Bootstrapper.InitializeContainer(this);
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this, WindowBackdropType.None);
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
Show(); // Call show just to make sure source is initialized at startup. Show(); // Call show just to make sure source is initialized at startup.

View File

@@ -141,6 +141,15 @@ namespace ColorPicker.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Color Picker.
/// </summary>
public static string CP_Title {
get {
return ResourceManager.GetString("CP_Title", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Color dark 1. /// Looks up a localized string similar to Color dark 1.
/// </summary> /// </summary>
@@ -231,6 +240,15 @@ namespace ColorPicker.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Pick.
/// </summary>
public static string New_Label {
get {
return ResourceManager.GetString("New_Label", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Press the Color Picker icon to capture a color from your screen.. /// Looks up a localized string similar to Press the Color Picker icon to capture a color from your screen..
/// </summary> /// </summary>

View File

@@ -400,4 +400,12 @@
<value>Plum</value> <value>Plum</value>
<comment>Plum color</comment> <comment>Plum color</comment>
</data> </data>
<data name="New_Label" xml:space="preserve">
<value>Pick</value>
<comment>Button label to pick a new color</comment>
</data>
<data name="CP_Title" xml:space="preserve">
<value>Color Picker</value>
<comment>Do not translate product name</comment>
</data>
</root> </root>

View File

@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:converters="clr-namespace:ColorPicker.Converters"
xmlns:converters="clr-namespace:ColorPicker.Converters"> xmlns:helpers="clr-namespace:ColorPicker.Helpers">
<!-- CONVERTERS --> <!-- CONVERTERS -->
<BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" /> <BooleanToVisibilityConverter x:Key="bool2VisibilityConverter" />
<converters:BoolToInvertedVisibilityConverter x:Key="bool2InvertedVisibilityConverter" /> <converters:BoolToInvertedVisibilityConverter x:Key="bool2InvertedVisibilityConverter" />
@@ -9,47 +10,50 @@
<converters:ColorToStringConverter x:Key="colorToStringConverter" /> <converters:ColorToStringConverter x:Key="colorToStringConverter" />
<converters:NumberToVisibilityConverter x:Key="numberToVisibilityConverter" /> <converters:NumberToVisibilityConverter x:Key="numberToVisibilityConverter" />
<converters:NumberToInvertedVisibilityConverter x:Key="numberToInvertedVisibilityConverter" /> <converters:NumberToInvertedVisibilityConverter x:Key="numberToInvertedVisibilityConverter" />
<Style x:Key="ColorHistoryListViewStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True"/> <Style x:Key="SubtleButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="0" /> <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}"/> <Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="MinWidth" <Setter Property="Focusable" Value="False" />
Value="0" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="ui:FocusVisualHelper.FocusVisualMargin" <Setter Property="VerticalContentAlignment" Value="Center" />
Value="0" /> <Setter Property="Padding" Value="1" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}"> <ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="Bd" Width="64" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="True"> <Border
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> x:Name="border"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<MultiTrigger> <Trigger Property="IsDefaulted" Value="true">
<MultiTrigger.Conditions> <Setter TargetName="border" Property="Background" Value="Transparent" />
<Condition Property="IsMouseOver" Value="True"/> </Trigger>
</MultiTrigger.Conditions> <Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ListViewPointerOverBrush}"/> <Setter TargetName="border" Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
</MultiTrigger> <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
<MultiTrigger> </Trigger>
<MultiTrigger.Conditions> <Trigger Property="IsPressed" Value="true">
<Condition Property="Selector.IsSelectionActive" Value="False"/> <Setter TargetName="border" Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
<Condition Property="IsSelected" Value="True"/> <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
</MultiTrigger.Conditions> </Trigger>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ListViewPressedBrush}"/> <Trigger Property="IsEnabled" Value="false">
</MultiTrigger> <!-- <Setter TargetName="border" Property="Background" Value="{DynamicResource ControlFillColorDisabledBrush}" />
<MultiTrigger> <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{DynamicResource TextFillColorDisabledBrush}"/>-->
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="True"/>
<Condition Property="IsSelected" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ListViewPressedBrush}"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@@ -63,18 +67,19 @@
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> <Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="8,5,8,6" /> <Setter Property="Padding" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" /> <Setter Property="FontWeight" Value="Normal" />
<Setter Property="Width" Value="12" />
<Setter Property="MinWidth" Value="20" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" /> <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="ui:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" /> <!--<Setter Property="ui:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
<Setter Property="ui:FocusVisualHelper.FocusVisualMargin" Value="-2" /> <Setter Property="ui:FocusVisualHelper.FocusVisualMargin" Value="-2" />-->
<Setter Property="ui:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" /> <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
@@ -82,35 +87,30 @@
<Border <Border
x:Name="Background" x:Name="Background"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius}" CornerRadius="{TemplateBinding helpers:ControlHelper.CornerRadius}"
SnapsToDevicePixels="True"> SnapsToDevicePixels="True">
<Border <Border
x:Name="Border" x:Name="Border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius}"> BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter <ContentPresenter
x:Name="ContentPresenter" x:Name="ContentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False" Focusable="False"
Visibility="Collapsed"
RecognizesAccessKey="True" RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Visibility="Collapsed" />
</Border> </Border>
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Background" Property="Opacity" Value="0.8" /> <Setter TargetName="Background" Property="Opacity" Value="0.8" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" /> <Setter TargetName="ContentPresenter" Property="Visibility" Value="Visible" />
<Setter TargetName="ContentPresenter"
Property="Visibility" Value="Visible" />
</Trigger> </Trigger>
<Trigger Property="IsPressed" Value="True"> <Trigger Property="IsPressed" Value="True">
<Setter TargetName="Background" Property="Opacity" Value="0.9" /> <Setter TargetName="Background" Property="Opacity" Value="0.9" />
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" />
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>

View File

@@ -1,4 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewModels="clr-namespace:ColorPicker.ViewModels" xmlns:viewModels="clr-namespace:ColorPicker.ViewModels"
xmlns:views="clr-namespace:ColorPicker.Views"> xmlns:views="clr-namespace:ColorPicker.Views">

View File

@@ -1,24 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">Dark.Accent1</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent1 (Dark)</system:String>
<system:String x:Key="Theme.BaseColorScheme">Dark</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">Black</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FF535353"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF6b6b6b" />
</ResourceDictionary>

View File

@@ -1,24 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent2</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent2 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent2</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFffff00"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFffff00" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF00ff00" />
</ResourceDictionary>

View File

@@ -1,25 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent3</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent3 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent3</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FF00ff00"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF00ff00" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FFc0c0c0" />
</ResourceDictionary>

View File

@@ -1,25 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent4</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent4 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent4</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FF3a3a3a" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FF333333" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFffffff"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF9a9a9a"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#FF242424"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FF333333"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FF454545"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FFffffff" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF1aebff" />
</ResourceDictionary>

View File

@@ -1,25 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">HighContrast.Accent5</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent5 (HighContrast)</system:String>
<system:String x:Key="Theme.BaseColorScheme">HighContrast</system:String>
<system:String x:Key="Theme.ColorScheme">Accent5</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FFededed" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FFe5e5e5" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="Black"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF949494"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#e9e9e9"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FFe5e5e5"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FFf9f9f9"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF000000" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF37006e" />
</ResourceDictionary>

View File

@@ -1,25 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Metadata -->
<system:String x:Key="Theme.Name">Light.Accent1</system:String>
<system:String x:Key="Theme.Origin">PowerToysRun</system:String>
<system:String x:Key="Theme.DisplayName">Accent1 (Light)</system:String>
<system:String x:Key="Theme.BaseColorScheme">Light</system:String>
<system:String x:Key="Theme.ColorScheme">Accent1</system:String>
<Color x:Key="Theme.PrimaryAccentColor">White</Color>
<SolidColorBrush x:Key="SecondaryBackgroundBrush" Color="#FFededed" />
<SolidColorBrush x:Key="PrimaryBackgroundBrush" Color="#FFe5e5e5" />
<SolidColorBrush x:Key="WindowBorderBrush" Color="#FFf7f7f7"/>
<SolidColorBrush x:Key="TitleBarSecondaryForegroundBrush" Color="#FF949494"/>
<SolidColorBrush x:Key="ListViewPointerOverBrush" Color="#e9e9e9"/>
<SolidColorBrush x:Key="ListViewPressedBrush" Color="#FFe5e5e5"/>
<SolidColorBrush x:Key="ColorControlBackgroundBrush" Color="#FFf9f9f9"/>
<SolidColorBrush x:Key="PrimaryForegroundBrush" Color="#FF000000" />
<SolidColorBrush x:Key="SecondaryForegroundBrush" Color="#FF949494" />
</ResourceDictionary>

View File

@@ -1,213 +1,306 @@
<UserControl x:Class="ColorPicker.Views.ColorEditorView" <UserControl
x:Class="ColorPicker.Views.ColorEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:ColorPicker.Properties"
mc:Ignorable="d"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
xmlns:controls="clr-namespace:ColorPicker.Controls" xmlns:controls="clr-namespace:ColorPicker.Controls"
xmlns:behaviors="clr-namespace:ColorPicker.Behaviors" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
WindowChrome.IsHitTestVisibleInChrome="True" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="colorEditorControl"> xmlns:p="clr-namespace:ColorPicker.Properties"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
x:Name="colorEditorControl"
mc:Ignorable="d">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.RowDefinitions>
<ColumnDefinition Width="64"/> <RowDefinition Height="64" />
<ColumnDefinition Width="*"/> <RowDefinition Height="*" />
</Grid.ColumnDefinitions> </Grid.RowDefinitions>
<!-- Side bar --> <!-- Side bar -->
<Grid Background="{DynamicResource SecondaryBackgroundBrush}"> <Grid Margin="16,16,16,0">
<ui:ListView x:Name="HistoryColors" <Grid.ColumnDefinitions>
Margin="0,48,0,0" <ColumnDefinition Width="Auto" />
Grid.Row="1" <ColumnDefinition Width="*" />
Padding="0" <ColumnDefinition Width="Auto" />
TabIndex="2" </Grid.ColumnDefinitions>
KeyboardNavigation.DirectionalNavigation="Contained" <ui:Button
Width="64" Height="36"
VerticalAlignment="Top"
AutomationProperties.Name="{x:Static p:Resources.Pick_color}"
Command="{Binding OpenColorPickerCommand}"
TabIndex="0"
ToolTipService.ToolTip="{x:Static p:Resources.Pick_color}">
<Button.Content>
<StackPanel Orientation="Horizontal">
<ui:SymbolIcon FontSize="18" Symbol="Eyedropper20" />
<TextBlock Margin="8,0,0,0" Text="{x:Static p:Resources.New_Label}" />
</StackPanel>
</Button.Content>
</ui:Button>
<ListView
x:Name="HistoryColors"
Grid.Column="1"
Height="48"
Margin="12,4,12,0"
VerticalAlignment="Top"
VerticalContentAlignment="Top"
AutomationProperties.Name="{x:Static p:Resources.Color_History}" AutomationProperties.Name="{x:Static p:Resources.Color_History}"
HorizontalAlignment="Center"
ui:FocusVisualHelper.UseSystemFocusVisuals="True"
ItemsSource="{Binding ColorsHistory}" ItemsSource="{Binding ColorsHistory}"
KeyboardNavigation.DirectionalNavigation="Contained"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
SelectedIndex="{Binding SelectedColorIndex}" SelectedIndex="{Binding SelectedColorIndex}"
ItemContainerStyle="{DynamicResource ColorHistoryListViewStyle}"
IsItemClickEnabled="True"
SelectionMode="Extended" SelectionMode="Extended"
ItemClick="HistoryColors_ItemClick"> TabIndex="2">
<ui:ListView.ContextMenu> <ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VerticalAlignment="Top" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ContextMenu>
<ContextMenu Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}"> <ContextMenu Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}">
<MenuItem Header="{x:Static p:Resources.Remove}" <MenuItem
Command="{Binding RemoveColorsCommand}" Command="{Binding RemoveColorsCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}"> CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}"
Header="{x:Static p:Resources.Remove}">
<MenuItem.Icon> <MenuItem.Icon>
<ui:FontIcon Glyph="&#xE74D;" /> <ui:SymbolIcon Symbol="Delete24" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="{x:Static p:Resources.Export_by}"> <MenuItem Header="{x:Static p:Resources.Export_by}">
<MenuItem.Icon> <MenuItem.Icon>
<ui:FontIcon Glyph="&#xEDE1;"/> <ui:SymbolIcon Symbol="ArrowExportLtr24" />
</MenuItem.Icon> </MenuItem.Icon>
<MenuItem Header="{x:Static p:Resources.Export_by_color}" <MenuItem
Command="{Binding ExportColorsGroupedByColorCommand}" Command="{Binding ExportColorsGroupedByColorCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}"> CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}"
Header="{x:Static p:Resources.Export_by_color}">
<MenuItem.Icon> <MenuItem.Icon>
<ui:FontIcon Glyph="&#xE790;"/> <ui:SymbolIcon Symbol="Color20" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="{x:Static p:Resources.Export_by_format}" <MenuItem
Command="{Binding ExportColorsGroupedByFormatCommand}" Command="{Binding ExportColorsGroupedByFormatCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}" > CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.SelectedItems}"
Header="{x:Static p:Resources.Export_by_format}">
<MenuItem.Icon> <MenuItem.Icon>
<ui:FontIcon Glyph="&#xE943;"/> <ui:SymbolIcon Symbol="Code20" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
</MenuItem> </MenuItem>
</ContextMenu> </ContextMenu>
</ui:ListView.ContextMenu> </ListView.ContextMenu>
<ui:ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Width="64" Height="48"> <Grid Width="28" Height="28">
<Border <Ellipse
Width="26" Width="20"
Height="26" Height="20"
CornerRadius="4" Stroke="{DynamicResource SurfaceStrokeColorDefaultBrush}"
HorizontalAlignment="Center" StrokeThickness="1">
VerticalAlignment="Center" <Ellipse.Fill>
Background="{Binding Path=., Converter={StaticResource colorToBrushConverter}}"> <SolidColorBrush Color="{Binding Path=.}" />
<Border.Effect> </Ellipse.Fill>
<DropShadowEffect BlurRadius="6" Opacity="0.32" ShadowDepth="2" /> </Ellipse>
</Border.Effect>
</Border>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ui:ListView.ItemTemplate> </ListView.ItemTemplate>
</ui:ListView> <ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Grid x:Name="RootGrid" Height="30">
<Ellipse
x:Name="SelectionStroke"
Width="28"
Height="28"
Fill="Transparent"
Opacity="0"
StrokeThickness="2">
<Ellipse.Stroke>
<SolidColorBrush Color="{Binding Path=.}" />
</Ellipse.Stroke>
</Ellipse>
<ContentPresenter
x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid> </Grid>
<!-- Title bar --> <ControlTemplate.Triggers>
<Grid Grid.ColumnSpan="2" <!-- Focused -->
Height="32" <!--
Background="Transparent" <Trigger Property="ui:FocusVisualHelper.ShowFocusVisual" Value="True">
VerticalAlignment="Top" <Setter TargetName="BorderRectangle" Property="Visibility" Value="Collapsed" />
KeyboardNavigation.DirectionalNavigation="Contained" </Trigger>-->
IsHitTestVisible="True">
<e:Interaction.Behaviors>
<behaviors:DragWindowBehavior/>
</e:Interaction.Behaviors>
<Border
Background="{DynamicResource TitleBarSecondaryForegroundBrush}"
Grid.ColumnSpan="2"
Width="30"
Height="3"
CornerRadius="1.5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0,1,0,0" />
<Button Width="46" <!-- PointerOver -->
Command="{Binding OpenSettingsCommand}" <MultiTrigger>
Height="32" <MultiTrigger.Conditions>
Content="&#xE713;" <Condition Property="IsMouseOver" Value="True" />
TabIndex="2" <Condition Property="IsSelected" Value="False" />
Background="Transparent" </MultiTrigger.Conditions>
FontFamily="Segoe MDL2 Assets" <Setter TargetName="RootGrid" Property="Opacity" Value="0.8" />
</MultiTrigger>
<!-- Selected -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsSelected" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="SelectionStroke" Property="Opacity" Value="1" />
</MultiTrigger>
<!-- PointerOverSelected -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsSelected" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="SelectionStroke" Property="Opacity" Value="1" />
<Setter TargetName="RootGrid" Property="Opacity" Value="0.8" />
</MultiTrigger>
<!-- Disabled -->
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="RootGrid" Property="Opacity" Value="{DynamicResource ListViewItemDisabledThemeOpacity}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<Button
Grid.Column="2"
Width="36"
Height="36"
Padding="0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,0,46,0" VerticalAlignment="Top"
ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}" AutomationProperties.Name="{x:Static p:Resources.Open_settings}"
AutomationProperties.Name="{x:Static p:Resources.Open_settings}" />
<Button Width="64"
Height="32"
TabIndex="0"
Command="{Binding OpenColorPickerCommand}"
Background="Transparent" Background="Transparent"
FontFamily="Segoe MDL2 Assets" BorderBrush="Transparent"
ui:FocusVisualHelper.FocusVisualMargin="-1" Command="{Binding OpenSettingsCommand}"
ToolTipService.ToolTip="{x:Static p:Resources.Pick_color}" Style="{StaticResource SubtleButtonStyle}"
AutomationProperties.Name="{x:Static p:Resources.Pick_color}"> TabIndex="2"
ToolTipService.ToolTip="{x:Static p:Resources.Open_settings}">
<Button.Content> <Button.Content>
<TextBlock Text="&#xEF3C;" AutomationProperties.Name="{x:Static p:Resources.Pick_color}" /> <ui:SymbolIcon FontSize="18" Symbol="Settings20" />
</Button.Content> </Button.Content>
</Button> </Button>
</Grid> </Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="2"
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="0,1,0,0" />
<controls:ColorPickerControl
Margin="16,0,12,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsTabStop="True"
KeyboardNavigation.DirectionalNavigation="Contained"
SelectedColor="{Binding SelectedColor}"
SelectedColorChangedCommand="{Binding SelectedColorChangedCommand}"
TabIndex="2"
Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}" />
<!-- Main grid --> <!-- Main grid -->
<Grid Grid.Column="1" <Grid
Grid.Column="1"
Margin="0,2,0,0"
Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}"> Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}">
<ScrollViewer IsTabStop="False" <ScrollViewer IsTabStop="False">
Margin="0,90,0,0"> <ItemsControl
<StackPanel>
<ItemsControl IsTabStop="False"
TabIndex="4"
KeyboardNavigation.DirectionalNavigation="Contained"
FocusManager.IsFocusScope="True" FocusManager.IsFocusScope="True"
IsTabStop="False"
ItemsSource="{Binding ColorRepresentations}"
KeyboardNavigation.DirectionalNavigation="Contained"
KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.TabNavigation="Once"
ItemsSource="{Binding ColorRepresentations}"> TabIndex="4">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<controls:ColorFormatControl <controls:ColorFormatControl
ColorCopiedNotificationBorder="{Binding ElementName=CopiedBorderIndicator}"
ColorFormatModel="{Binding}" ColorFormatModel="{Binding}"
SelectedColor="{Binding ElementName=colorEditorControl, Path=DataContext.SelectedColor}" SelectedColor="{Binding ElementName=colorEditorControl, Path=DataContext.SelectedColor}" />
ColorCopiedNotificationBorder="{Binding ElementName=CopiedBorderIndicator}" />
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<StackPanel <StackPanel
Orientation="Vertical" Margin="0,14,12,10"
Margin="0,16,0,16"/> Background="Transparent"
Orientation="Vertical" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
</ItemsControl> </ItemsControl>
</StackPanel>
</ScrollViewer> </ScrollViewer>
<controls:ColorPickerControl HorizontalAlignment="Left"
Margin="0,44,0,0"
Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToVisibilityConverter}}"
IsTabStop="True"
TabIndex="2"
KeyboardNavigation.DirectionalNavigation="Contained"
SelectedColor="{Binding SelectedColor}"
SelectedColorChangedCommand="{Binding SelectedColorChangedCommand}"
Grid.Column="1"
VerticalAlignment="Top" />
</Grid> </Grid>
</Grid>
<!-- Empty history --> <!-- Empty history -->
<StackPanel Grid.Column="1" Margin="24, 12" VerticalAlignment="Center" Orientation="Vertical" Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToInvertedVisibilityConverter}}"> <StackPanel
<TextBlock Text="&#xEF3C;" Grid.Row="1"
FontFamily="Segoe MDL2 Assets" Grid.ColumnSpan="2"
FontSize="44" Margin="0,-12,0,0"
VerticalAlignment="Center"
Orientation="Vertical"
Visibility="{Binding ColorsHistory.Count, Converter={StaticResource numberToInvertedVisibilityConverter}}">
<ui:SymbolIcon FontSize="40" Symbol="Eyedropper20" />
<TextBlock
Margin="24,16,24,16"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Foreground="{DynamicResource SecondaryForegroundBrush}" /> Foreground="{DynamicResource TextFillColorSecondaryBrush}"
<TextBlock Margin="0,16,0,0" Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" Text="{x:Static p:Resources.No_colors_yet}"
TextAlignment="Center" TextAlignment="Center"
HorizontalAlignment="Center" TextWrapping="Wrap" />
Foreground="{DynamicResource SecondaryForegroundBrush}"
Text="{x:Static p:Resources.No_colors_yet}"/>
</StackPanel> </StackPanel>
<Border x:Name="CopiedBorderIndicator" <Border
Opacity="0" x:Name="CopiedBorderIndicator"
Grid.Row="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Height="0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Height="0" BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
Background="{DynamicResource SystemControlBackgroundAccentBrush}"> BorderThickness="0,1,0,0"
Opacity="0">
<TextBlock FontSize="16" <Border.Background>
Foreground="White" <SolidColorBrush Color="{DynamicResource SystemAccentColorPrimary}" />
</Border.Background>
<StackPanel
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Assertive" AutomationProperties.LiveSetting="Assertive"
AutomationProperties.Name="{x:Static p:Resources.Copied_to_clipboard}"> AutomationProperties.Name="{x:Static p:Resources.Copied_to_clipboard}"
<Run Text="&#xE8C8; " FontFamily="Segoe MDL2 Assets"/> Orientation="Horizontal">
<Run Text="{x:Static p:Resources.Copied_to_clipboard}" FontWeight="SemiBold"/> <ui:SymbolIcon
</TextBlock> Margin="0,0,8,0"
FontSize="20"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
Symbol="Copy20" />
<TextBlock
FontSize="16"
Foreground="{DynamicResource TextOnAccentFillColorPrimaryBrush}"
Text="{x:Static p:Resources.Copied_to_clipboard}" />
</StackPanel>
</Border> </Border>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -42,11 +42,13 @@ namespace ColorPicker.Views
}; };
} }
private void HistoryColors_ItemClick(object sender, ModernWpf.Controls.ItemClickEventArgs e) /*
private void HistoryColors_ItemClick(object sender, ItemClickEventArgs e)
{ {
// Note: it does not handle clicking on the same color. // Note: it does not handle clicking on the same color.
// More appropriate event would be SelectionChanged but we can not distinguish between user action and program action inside of it. // More appropriate event would be SelectionChanged but we can not distinguish between user action and program action inside of it.
SessionEventHelper.Event.EditorHistoryColorPicked = true; SessionEventHelper.Event.EditorHistoryColorPicked = true;
} }
*/
} }
} }

View File

@@ -1,19 +1,22 @@
<UserControl x:Class="ColorPicker.Views.MainView" <UserControl
x:Class="ColorPicker.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ColorPicker.Views" xmlns:local="clr-namespace:ColorPicker.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModel="clr-namespace:ColorPicker.ViewModels" xmlns:viewModel="clr-namespace:ColorPicker.ViewModels"
mc:Ignorable="d" d:DesignHeight="64" d:DataContext="{d:DesignInstance viewModel:MainViewModel,
d:DataContext="{d:DesignInstance viewModel:MainViewModel, IsDesignTimeCreatable=True}"> IsDesignTimeCreatable=True}"
d:DesignHeight="64"
mc:Ignorable="d">
<Grid Background="Transparent"> <Grid Background="Transparent">
<Border BorderBrush="{DynamicResource WindowBorderBrush}" <Border
Margin="12" Background="{DynamicResource ApplicationBackgroundBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1" BorderThickness="1"
Background="{DynamicResource PrimaryBackgroundBrush}" CornerRadius="8">
CornerRadius="4">
<!-- Disabled due to the poor performance of drawing shadows in WPF --> <!-- Disabled due to the poor performance of drawing shadows in WPF -->
<!--<Border.Effect> <!--<Border.Effect>
<DropShadowEffect <DropShadowEffect
@@ -30,23 +33,23 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Background="{Binding ColorBrush}" <Border
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
BorderBrush="{DynamicResource WindowBorderBrush}" Background="{Binding ColorBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1" BorderThickness="1"
CornerRadius="4"/> CornerRadius="{DynamicResource ControlCornerRadius}" />
<TextBlock <TextBlock
x:Name="ColorTextBlock" x:Name="ColorTextBlock"
Grid.Column="1"
Margin="8,5,8,8" Margin="8,5,8,8"
AutomationProperties.LiveSetting="Assertive"
AutomationProperties.Name="{Binding ColorName}"
FontSize="16" FontSize="16"
FontWeight="SemiBold" FontWeight="SemiBold"
Foreground="{DynamicResource PrimaryForegroundBrush}" Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Grid.Column="1"
AutomationProperties.LiveSetting="Assertive"
AutomationProperties.LabeledBy="{Binding ColorName}"
AutomationProperties.Name="{Binding ColorName}"
Text="{Binding ColorText}" /> Text="{Binding ColorText}" />
</Grid> </Grid>
@@ -61,33 +64,34 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Background="{Binding ColorBrush}" <Border
HorizontalAlignment="Stretch"
Grid.RowSpan="2"
VerticalAlignment="Stretch"
BorderBrush="{DynamicResource WindowBorderBrush}"
BorderThickness="1"
Margin="1"
x:Name="ColorBorderBig" x:Name="ColorBorderBig"
CornerRadius="4"/> Grid.RowSpan="2"
Margin="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{Binding ColorBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{DynamicResource ControlCornerRadius}" />
<TextBlock Margin="8,5,6,0" <TextBlock
FontSize="16"
Grid.Row="0" Grid.Row="0"
FontWeight="SemiBold"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Grid.Column="1" Grid.Column="1"
Margin="8,5,6,0"
FontSize="16"
FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="{Binding ColorText}" /> Text="{Binding ColorText}" />
<TextBlock Margin="8,0,8,2" <TextBlock
Height="26"
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
FontSize="16" Height="26"
FontWeight="SemiBold" Margin="8,0,8,2"
Foreground="{DynamicResource PrimaryForegroundBrush}" Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Opacity="0.6" Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding ColorName}" /> Text="{Binding ColorName}" />
</Grid> </Grid>
</Grid> </Grid>

View File

@@ -1,33 +1,38 @@
<UserControl x:Class="ColorPicker.Views.ZoomView" <UserControl
x:Class="ColorPicker.Views.ZoomView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:shaders="clr-namespace:ColorPicker.Shaders"
xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:ColorPicker.Behaviors" xmlns:behaviors="clr-namespace:ColorPicker.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:e="http://schemas.microsoft.com/xaml/behaviors"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shaders="clr-namespace:ColorPicker.Shaders"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Background="Transparent" Background="Transparent"
Focusable="False"> Focusable="False"
mc:Ignorable="d">
<Border x:Name="WindowBorder" <Border
x:Name="WindowBorder"
Margin="12"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
BorderBrush="{DynamicResource WindowBorderBrush}" Background="{DynamicResource LayerFillColorDefaultBrush}"
Margin="12" BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1" BorderThickness="1"
Background="{DynamicResource PrimaryBackgroundBrush}" CornerRadius="{DynamicResource ControlCornerRadius}">
CornerRadius="4">
<!-- Disabled due to the poor performance of drawing shadows in WPF --> <!-- Disabled due to the poor performance of drawing shadows in WPF -->
<!--<Border.Effect> <!--<Border.Effect>
<DropShadowEffect BlurRadius="16" Opacity="0.28" ShadowDepth="1" /> <DropShadowEffect BlurRadius="16" Opacity="0.28" ShadowDepth="1" />
</Border.Effect>--> </Border.Effect>-->
<Grid> <Grid>
<Image Margin="3" Source="{Binding ZoomArea}" <Image
RenderOptions.BitmapScalingMode="NearestNeighbor"
Stretch="Fill"
Width="{Binding Width, Mode=TwoWay}" Width="{Binding Width, Mode=TwoWay}"
Height="{Binding Height, Mode=TwoWay}"> Height="{Binding Height, Mode=TwoWay}"
Margin="3"
RenderOptions.BitmapScalingMode="NearestNeighbor"
Source="{Binding ZoomArea}"
Stretch="Fill">
<e:Interaction.Behaviors> <e:Interaction.Behaviors>
<behaviors:ResizeBehavior Width="{Binding DesiredWidth}" Height="{Binding DesiredHeight}" /> <behaviors:ResizeBehavior Width="{Binding DesiredWidth}" Height="{Binding DesiredHeight}" />
<behaviors:GridEffectBehavior Effect="{Binding ElementName=gridEffect}" ZoomFactor="{Binding ZoomFactor}" /> <behaviors:GridEffectBehavior Effect="{Binding ElementName=gridEffect}" ZoomFactor="{Binding ZoomFactor}" />
@@ -38,11 +43,11 @@
</Image> </Image>
<!-- Non-functional close button --> <!-- Non-functional close button -->
<Border HorizontalAlignment="Right" <Border
Visibility="Collapsed" HorizontalAlignment="Right"
VerticalAlignment="Top" VerticalAlignment="Top"
CornerRadius="0,4,0,4" CornerRadius="0,4,0,4"
Background="{DynamicResource PrimaryBackgroundBrush}"> Visibility="Collapsed">
<Border.Style> <Border.Style>
<Style TargetType="Border"> <Style TargetType="Border">
<Style.Triggers> <Style.Triggers>
@@ -52,11 +57,12 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</Border.Style> </Border.Style>
<Button Height="40" <Button
Width="40" Width="40"
Content="&#xE8BB;" Height="40"
FontFamily="Segoe MDL2 Assets" Background="Transparent">
Background="Transparent"/> <ui:SymbolIcon Symbol="Dismiss20" />
</Button>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>