Skip to content

A Swiss Army knife for developers.

Added contrast ratio checker (#594)

Etienne Baudouxb3ab0eeaba0f
diff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csproj
index aff96e0ff..0c93d4b5d 100644
--- a/src/dev/impl/DevToys/DevToys.csproj
+++ b/src/dev/impl/DevToys/DevToys.csproj
@@ -86,9 +86,12 @@
<Compile Include="UI\Controls\ToolProvidersGridView.xaml.cs">
<DependentUpon>ToolProvidersGridView.xaml</DependentUpon>
</Compile>
+ <Compile Include="UI\Converters\BooleanToBrushConverter.cs" />
<Compile Include="UI\Converters\BooleanToDoubleConverter.cs" />
<Compile Include="UI\Converters\BooleanToIntegerConverter.cs" />
+ <Compile Include="UI\Converters\BooleanToStringConverter.cs" />
<Compile Include="UI\Converters\ColorToBrushConverter.cs" />
+ <Compile Include="UI\Extensions\ControlSizeTrigger.cs" />
<Compile Include="UI\MainMenuNavigationViewMenuItemSelector.cs" />
<Compile Include="ViewModels\Tools\AllTools\AllToolsToolProvider.cs" />
<Compile Include="ViewModels\Tools\AllTools\AllToolsToolViewModel.cs" />
diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.cs
index dafab7781..660ed1dc9 100644
--- a/src/dev/impl/DevToys/LanguageManager.cs
+++ b/src/dev/impl/DevToys/LanguageManager.cs
@@ -585,14 +585,9 @@ namespace DevToys
public string SearchKeywords => _resources.GetString("SearchKeywords");
/// <summary>
- /// Gets the resource BlackText.
+ /// Gets the resource TextColor.
/// </summary>
- public string BlackText => _resources.GetString("BlackText");
-
- /// <summary>
- /// Gets the resource ColorPicker.
- /// </summary>
- public string ColorPicker => _resources.GetString("ColorPicker");
+ public string TextColor => _resources.GetString("TextColor");
/// <summary>
/// Gets the resource Configuration.
@@ -620,9 +615,54 @@ namespace DevToys
public string SelectedColor => _resources.GetString("SelectedColor");
/// <summary>
- /// Gets the resource WhiteText.
+ /// Gets the resource BackgroundColor.
+ /// </summary>
+ public string BackgroundColor => _resources.GetString("BackgroundColor");
+
+ /// <summary>
+ /// Gets the resource ContrastRatio.
+ /// </summary>
+ public string ContrastRatio => _resources.GetString("ContrastRatio");
+
+ /// <summary>
+ /// Gets the resource Fail.
+ /// </summary>
+ public string Fail => _resources.GetString("Fail");
+
+ /// <summary>
+ /// Gets the resource LargeText.
+ /// </summary>
+ public string LargeText => _resources.GetString("LargeText");
+
+ /// <summary>
+ /// Gets the resource Pass.
+ /// </summary>
+ public string Pass => _resources.GetString("Pass");
+
+ /// <summary>
+ /// Gets the resource SampleText.
+ /// </summary>
+ public string SampleText => _resources.GetString("SampleText");
+
+ /// <summary>
+ /// Gets the resource SampleTextTitle.
+ /// </summary>
+ public string SampleTextTitle => _resources.GetString("SampleTextTitle");
+
+ /// <summary>
+ /// Gets the resource SmallText.
+ /// </summary>
+ public string SmallText => _resources.GetString("SmallText");
+
+ /// <summary>
+ /// Gets the resource WCAG_AA.
+ /// </summary>
+ public string WCAG_AA => _resources.GetString("WCAG_AA");
+
+ /// <summary>
+ /// Gets the resource WCAG_AAA.
/// </summary>
- public string WhiteText => _resources.GetString("WhiteText");
+ public string WCAG_AAA => _resources.GetString("WCAG_AAA");
}
public class CommonStrings : ObservableObject
diff --git a/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw b/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw
index 81d59ab47..2ee28453b 100644
--- a/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw
+++ b/src/dev/impl/DevToys/Strings/en-US/ColorPicker.resw
@@ -118,25 +118,22 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccessibleName" xml:space="preserve">
- <value>Color Picker tool</value>
+ <value>Color Picker and contrast ratio tool</value>
</data>
<data name="MenuDisplayName" xml:space="preserve">
- <value>Color Picker</value>
+ <value>Color Picker &amp; Contrast</value>
</data>
<data name="Description" xml:space="preserve">
- <value>Pick up a color</value>
+ <value>Pick up a color or two and validate the contrast ratio</value>
</data>
<data name="SearchDisplayName" xml:space="preserve">
- <value>Color Picker</value>
+ <value>Color Picker &amp; Contrast</value>
</data>
<data name="SearchKeywords" xml:space="preserve">
- <value />
+ <value>RGB WCAG</value>
</data>
- <data name="BlackText" xml:space="preserve">
- <value>Black text</value>
- </data>
- <data name="ColorPicker" xml:space="preserve">
- <value>Color picker</value>
+ <data name="TextColor" xml:space="preserve">
+ <value>Text color</value>
</data>
<data name="Configuration" xml:space="preserve">
<value>Configuration</value>
@@ -153,7 +150,36 @@
<data name="SelectedColor" xml:space="preserve">
<value>Selected color</value>
</data>
- <data name="WhiteText" xml:space="preserve">
- <value>White text</value>
+ <data name="BackgroundColor" xml:space="preserve">
+ <value>Background color</value>
+ </data>
+ <data name="ContrastRatio" xml:space="preserve">
+ <value>Contrast ratio</value>
+ </data>
+ <data name="Fail" xml:space="preserve">
+ <value>Fail</value>
+ </data>
+ <data name="LargeText" xml:space="preserve">
+ <value>Large text</value>
+ </data>
+ <data name="Pass" xml:space="preserve">
+ <value>Pass</value>
+ </data>
+ <data name="SampleText" xml:space="preserve">
+ <value>Sit kasd feugait takimata in eirmod sadipscing sanctus consectetuer voluptua dolor dolor dolore rebum.</value>
+ <comment>"Lorem ipsum" text used a sample text for comparing the background color over the text color.</comment>
+ </data>
+ <data name="SampleTextTitle" xml:space="preserve">
+ <value>Lorem ipsum dolor</value>
+ <comment>"Lorem ipsum" text used a sample text for comparing the background color over the text color.</comment>
+ </data>
+ <data name="SmallText" xml:space="preserve">
+ <value>Small text</value>
+ </data>
+ <data name="WCAG_AA" xml:space="preserve">
+ <value>WCAG AA</value>
+ </data>
+ <data name="WCAG_AAA" xml:space="preserve">
+ <value>WCAG AAA</value>
</data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Themes/Generic.xaml b/src/dev/impl/DevToys/Themes/Generic.xaml
index 49018e8e2..2db6d5a15 100644
--- a/src/dev/impl/DevToys/Themes/Generic.xaml
+++ b/src/dev/impl/DevToys/Themes/Generic.xaml
@@ -8,14 +8,14 @@
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="TextEditorForeground" Color="Black"/>
-
+
<!-- REVIEW: If Navigation View Content Grid Border Brush has transparency, it makes WebView being unclickable (can't get focus),
which breaks Monaco Editor. The line below change the border brush to use a solid one (without transparency). -->
<StaticResource x:Key="NavigationViewContentGridBorderBrush" ResourceKey="CardStrokeColorDefaultSolidBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="TextEditorForeground" Color="#F0F0F0"/>
-
+
<!-- REVIEW: If Navigation View Content Grid Border Brush has transparency, it makes WebView being unclickable (can't get focus),
which breaks Monaco Editor. The line below change the border brush to use a solid one (without transparency). -->
<StaticResource x:Key="NavigationViewContentGridBorderBrush" ResourceKey="CardStrokeColorDefaultSolidBrush" />
@@ -43,7 +43,7 @@
<Style TargetType="TextBlock">
<Setter Property="HighContrastAdjustment" Value="None"/>
</Style>
-
+
<Style TargetType="ToggleSwitch">
<Setter Property="OnContent" Value="{Binding Instance.Common.ToggleSwitchOn, Mode=OneTime, Source={StaticResource LanguageManager}}"/>
<Setter Property="OffContent" Value="{Binding Instance.Common.ToggleSwitchOff, Mode=OneTime, Source={StaticResource LanguageManager}}"/>
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToBrushConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToBrushConverter.cs
new file mode 100644
index 000000000..e436e0d00
--- /dev/null
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToBrushConverter.cs
@@ -0,0 +1,41 @@
+#nullable enable
+
+using System;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Media;
+
+namespace DevToys.UI.Converters
+{
+ /// <summary>
+ /// Convert a <see cref="bool"/> to a <see cref="Brush"/> value.
+ /// </summary>
+ public sealed class BooleanToBrushConverter : IValueConverter
+ {
+ /// <summary>
+ /// Gets or sets the value to apply when the input is true.
+ /// </summary>
+ public Brush? ValueOnTrue { get; set; }
+
+ /// <summary>
+ /// Gets or sets the value to apply when the input is false.
+ /// </summary>
+ public Brush? ValueOnFalse { get; set; }
+
+ public object? Convert(object value, Type targetType, object parameter, string language)
+ {
+ bool? valueBool = value as bool?;
+ if (valueBool == null)
+ {
+ return DependencyProperty.UnsetValue;
+ }
+
+ return valueBool.Value ? ValueOnTrue : ValueOnFalse;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToStringConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToStringConverter.cs
new file mode 100644
index 000000000..1a4273dff
--- /dev/null
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToStringConverter.cs
@@ -0,0 +1,40 @@
+#nullable enable
+
+using System;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Data;
+
+namespace DevToys.UI.Converters
+{
+ /// <summary>
+ /// Convert a <see cref="bool"/> to a <see cref="string"/> value.
+ /// </summary>
+ public sealed class BooleanToStringConverter : IValueConverter
+ {
+ /// <summary>
+ /// Gets or sets the text to apply when the input is true.
+ /// </summary>
+ public string? StringOnTrue { get; set; }
+
+ /// <summary>
+ /// Gets or sets the text to apply when the input is false.
+ /// </summary>
+ public string? StringOnFalse { get; set; }
+
+ public object? Convert(object value, Type targetType, object parameter, string language)
+ {
+ bool? valueBool = value as bool?;
+ if (valueBool == null)
+ {
+ return DependencyProperty.UnsetValue;
+ }
+
+ return valueBool.Value ? StringOnTrue : StringOnFalse;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/dev/impl/DevToys/UI/Extensions/ControlSizeTrigger.cs b/src/dev/impl/DevToys/UI/Extensions/ControlSizeTrigger.cs
new file mode 100644
index 000000000..3729664e9
--- /dev/null
+++ b/src/dev/impl/DevToys/UI/Extensions/ControlSizeTrigger.cs
@@ -0,0 +1,74 @@
+#nullable enable
+
+using Windows.UI.Xaml;
+
+namespace DevToys.UI.Extensions
+{
+ public sealed class ControlSizeTrigger : StateTriggerBase
+ {
+ private FrameworkElement? _targetElement;
+ private double _minHeight = -1;
+ private double _minWidth = -1;
+ private double _currentHeight;
+ private double _currentWidth;
+
+ public double MinHeight
+ {
+ get => _minHeight;
+ set => _minHeight = value;
+ }
+
+ public double MinWidth
+ {
+ get => _minWidth;
+ set => _minWidth = value;
+ }
+
+ public FrameworkElement? TargetElement
+ {
+ get => _targetElement;
+ set
+ {
+ if (_targetElement is not null)
+ {
+ _targetElement.SizeChanged -= OnSizeChanged;
+ }
+ _targetElement = value;
+ if (_targetElement is not null)
+ {
+ _targetElement.SizeChanged += OnSizeChanged;
+ }
+ }
+ }
+
+ private void OnSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ _currentHeight = e.NewSize.Height;
+ _currentWidth = e.NewSize.Width;
+ UpdateTrigger();
+ }
+
+ private void UpdateTrigger()
+ {
+ if (_targetElement != null && (_minWidth > 0 || _minHeight > 0))
+ {
+ if (_minHeight > 0 && _minWidth > 0)
+ {
+ SetActive((_currentHeight >= _minHeight) && (_currentWidth >= _minWidth));
+ }
+ else if (_minHeight > 0)
+ {
+ SetActive(_currentHeight >= _minHeight);
+ }
+ else
+ {
+ SetActive(_currentWidth >= _minWidth);
+ }
+ }
+ else
+ {
+ SetActive(false);
+ }
+ }
+ }
+}
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs
index 69e7ed96d..0aaf9664e 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Graphic/ColorPicker/ColorPickerToolViewModel.cs
@@ -30,7 +30,12 @@ namespace DevToys.ViewModels.Tools.Graphic.ColorPicker
defaultValue: ColorPickerModeDisplayPair.HSV.Value);
private readonly ISettingsProvider _settingsProvider;
- private Color _selectedColor;
+ private Color _textColor;
+ private Color _backgroundColor;
+ private bool _wcagAaLevelLargeText;
+ private bool _wcagAaLevelSmallText;
+ private bool _wcagAaaLevelLargeText;
+ private bool _wcagAaaLevelSmallText;
public Type View => typeof(ColorPickerToolPage);
@@ -70,10 +75,63 @@ namespace DevToys.ViewModels.Tools.Graphic.ColorPicker
/// <summary>
/// Gets or sets the selected color.
/// </summary>
- public Color SelectedColor
+ public Color TextColor
{
- get => _selectedColor;
- set => SetProperty(ref _selectedColor, value);
+ get => _textColor;
+ set
+ {
+ SetProperty(ref _textColor, value);
+ CalculateContrastRatio();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the selected color.
+ /// </summary>
+ public Color BackgroundColor
+ {
+ get => _backgroundColor;
+ set
+ {
+ SetProperty(ref _backgroundColor, value);
+ CalculateContrastRatio();
+ }
+ }
+
+ /// <summary>
+ /// Gets whether the color contrast pass the WCAG AA level for large text.
+ /// </summary>
+ public bool WcagAaLevelLargeText
+ {
+ get => _wcagAaLevelLargeText;
+ private set => SetProperty(ref _wcagAaLevelLargeText, value);
+ }
+
+ /// <summary>
+ /// Gets whether the color contrast pass the WCAG AA level for small text.
+ /// </summary>
+ public bool WcagAaLevelSmallText
+ {
+ get => _wcagAaLevelSmallText;
+ private set => SetProperty(ref _wcagAaLevelSmallText, value);
+ }
+
+ /// <summary>
+ /// Gets whether the color contrast pass the WCAG AAA level for large text.
+ /// </summary>
+ public bool WcagAaaLevelLargeText
+ {
+ get => _wcagAaaLevelLargeText;
+ private set => SetProperty(ref _wcagAaaLevelLargeText, value);
+ }
+
+ /// <summary>
+ /// Gets whether the color contrast pass the WCAG AAA level for small text.
+ /// </summary>
+ public bool WcagAaaLevelSmallText
+ {
+ get => _wcagAaaLevelSmallText;
+ private set => SetProperty(ref _wcagAaaLevelSmallText, value);
}
[ImportingConstructor]
@@ -82,7 +140,41 @@ namespace DevToys.ViewModels.Tools.Graphic.ColorPicker
_settingsProvider = settingsProvider;
string? accentColorResourceName = themeListener.ActualAppTheme == ApplicationTheme.Light ? "SystemAccentColorLight2" : "SystemAccentColorDark1";
- SelectedColor = (Color)Application.Current.Resources[accentColorResourceName];
+ BackgroundColor = (Color)Application.Current.Resources[accentColorResourceName];
+ TextColor = themeListener.ActualAppTheme == ApplicationTheme.Light ? Colors.Black : Colors.White;
+ }
+
+ private void CalculateContrastRatio()
+ {
+ double textLuminence = CalculateLuminence(TextColor);
+ double backgroundLuminence = CalculateLuminence(BackgroundColor);
+
+ double contrastRatio
+ = textLuminence > backgroundLuminence
+ ? ((backgroundLuminence + 0.05) / (textLuminence + 0.05))
+ : ((textLuminence + 0.05) / (backgroundLuminence + 0.05));
+
+ WcagAaLevelLargeText = contrastRatio < 1 / 3f;
+ WcagAaLevelSmallText = contrastRatio < 1 / 4.5;
+ WcagAaaLevelLargeText = contrastRatio < 1 / 4.5;
+ WcagAaaLevelSmallText = contrastRatio < 1 / 7f;
+ }
+
+ private double CalculateLuminence(Color color)
+ {
+ double r = Luminence(color.R);
+ double g = Luminence(color.G);
+ double b = Luminence(color.B);
+
+ return r * 0.2126 + g * 0.7152 + b * 0.0722;
+
+ static double Luminence(double value)
+ {
+ value /= 255;
+ return value < 0.03928
+ ? value / 12.92
+ : Math.Pow((value + 0.055) / 1.055, 2.4);
+ }
}
}
}
diff --git a/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml
index bbb157fd2..086395807 100644
--- a/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/Graphic/ColorPicker/ColorPickerToolPage.xaml
@@ -4,97 +4,351 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:DevToys="using:DevToys"
xmlns:controls="using:DevToys.UI.Controls"
xmlns:converters="using:DevToys.UI.Converters"
- xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:ex="using:DevToys.UI.Extensions"
+ xmlns:ex="using:DevToys.UI.Extensions"
+ xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
NavigationCacheMode="Required">
<Page.Resources>
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
+ <converters:BooleanToBrushConverter
+ x:Key="ContrastRatioBooleanToBrushConverter"
+ ValueOnTrue="#10893E"
+ ValueOnFalse="#E81123"/>
+ <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
+ <converters:BooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" IsInverted="True"/>
</Page.Resources>
- <Grid Margin="0,0,0,16" RowSpacing="12">
+ <Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
+ <VisualState>
+ <VisualState.StateTriggers>
+ <ex:ControlSizeTrigger MinWidth="1100" TargetElement="{x:Bind}" />
+ </VisualState.StateTriggers>
+ <VisualState.Setters>
+ <Setter Target="ColorPicker.Orientation" Value="Horizontal"/>
+ <Setter Target="ColorPicker2.Orientation" Value="Horizontal"/>
+ <Setter Target="ColorPickerStackPanel.(Grid.ColumnSpan)" Value="1"/>
+ <Setter Target="ColorPicker2StackPanel.(Grid.Row)" Value="3" />
+ <Setter Target="ColorPicker2StackPanel.(Grid.Column)" Value="1" />
+ <Setter Target="ColorPicker2StackPanel.(Grid.ColumnSpan)" Value="1"/>
+ <Setter Target="SelectedColorGrid.(Grid.ColumnSpan)" Value="1" />
+ <Setter Target="ContrastRatioGrid.(Grid.Row)" Value="1" />
+ <Setter Target="ContrastRatioGrid.(Grid.Column)" Value="1" />
+ <Setter Target="ContrastRatioGrid.(Grid.ColumnSpan)" Value="1" />
+ </VisualState.Setters>
+ </VisualState>
+ <VisualState>
+ <VisualState.StateTriggers>
+ <ex:ControlSizeTrigger MinWidth="512" TargetElement="{x:Bind}" />
+ </VisualState.StateTriggers>
+ <VisualState.Setters>
+ <Setter Target="ColorPickerStackPanel.(Grid.ColumnSpan)" Value="1"/>
+ <Setter Target="ColorPicker2StackPanel.(Grid.Row)" Value="3" />
+ <Setter Target="ColorPicker2StackPanel.(Grid.Column)" Value="1" />
+ <Setter Target="ColorPicker2StackPanel.(Grid.ColumnSpan)" Value="1"/>
+ </VisualState.Setters>
+ </VisualState>
<VisualState>
<VisualState.StateTriggers>
<ex:IsCompactOverlayModeTrigger TargetElement="{x:Bind}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="SettingsStackPanel.Visibility" Value="Collapsed"/>
- <Setter Target="ColorPicker.Orientation" Value="Vertical"/>
- <Setter Target="ColorPicker.HorizontalAlignment" Value="Center"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
+ <Grid
+ Margin="0,0,0,16"
+ RowSpacing="12"
+ ColumnSpacing="12">
- <Grid.ChildrenTransitions>
- <TransitionCollection>
- <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>
- </TransitionCollection>
- </Grid.ChildrenTransitions>
+ <Grid.ChildrenTransitions>
+ <TransitionCollection>
+ <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>
+ </TransitionCollection>
+ </Grid.ChildrenTransitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
- <StackPanel
- x:Name="SettingsStackPanel"
- Grid.Row="0"
- Spacing="4">
- <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.Configuration}" />
-
- <controls:ExpandableSettingControl
- Title="{x:Bind ViewModel.Strings.Mode}">
- <controls:ExpandableSettingControl.Icon>
- <FontIcon Glyph="&#xF2F5;" />
- </controls:ExpandableSettingControl.Icon>
- <ComboBox
- ItemsSource="{x:Bind ViewModel.ColorPickerModes}"
- DisplayMemberPath="DisplayName"
- SelectedItem="{x:Bind ViewModel.ColorPickerMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
- </ComboBox>
- </controls:ExpandableSettingControl>
- </StackPanel>
+ <StackPanel
+ x:Name="SettingsStackPanel"
+ Grid.Row="0"
+ Grid.ColumnSpan="2"
+ Spacing="4">
+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.Configuration}" />
- <StackPanel
- Grid.Row="1"
- Spacing="4">
- <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.SelectedColor}" />
+ <controls:ExpandableSettingControl
+ Title="{x:Bind ViewModel.Strings.Mode}">
+ <controls:ExpandableSettingControl.Icon>
+ <FontIcon Glyph="&#xF2F5;" />
+ </controls:ExpandableSettingControl.Icon>
+ <ComboBox
+ ItemsSource="{x:Bind ViewModel.ColorPickerModes}"
+ DisplayMemberPath="DisplayName"
+ SelectedItem="{x:Bind ViewModel.ColorPickerMode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
+ </ComboBox>
+ </controls:ExpandableSettingControl>
+ </StackPanel>
- <StackPanel
- Spacing="12"
- Padding="0,12,0,12"
- Orientation="Vertical"
- CornerRadius="{ThemeResource ControlCornerRadius}"
- Background="{x:Bind ViewModel.SelectedColor, Mode=OneWay, Converter={StaticResource ColorToBrushConverter}}">
+ <Grid
+ x:Name="SelectedColorGrid"
+ Grid.Row="1"
+ Grid.Column="0"
+ Grid.ColumnSpan="2"
+ RowSpacing="4">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition/>
+ </Grid.RowDefinitions>
<TextBlock
- Foreground="Black"
- HorizontalAlignment="Center"
- Text="{x:Bind ViewModel.Strings.BlackText}"/>
+ Grid.Row="0"
+ Style="{StaticResource SubTitleTextBlock}"
+ Text="{x:Bind ViewModel.Strings.SelectedColor}"
+ VerticalAlignment="Top" />
+
+ <StackPanel
+ Grid.Row="1"
+ Spacing="12"
+ Padding="12"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
+ Background="{x:Bind ViewModel.BackgroundColor, Mode=OneWay, Converter={StaticResource ColorToBrushConverter}}">
+ <TextBlock
+ Style="{StaticResource TitleTextBlockStyle}"
+ Foreground="{x:Bind ViewModel.TextColor, Mode=OneWay, Converter={StaticResource ColorToBrushConverter}}"
+ HorizontalAlignment="Center"
+ FontSize="18"
+ Text="{x:Bind ViewModel.Strings.SampleTextTitle}"/>
+ <TextBlock
+ Style="{StaticResource BodyTextBlockStyle}"
+ FontSize="14"
+ Foreground="{x:Bind ViewModel.TextColor, Mode=OneWay, Converter={StaticResource ColorToBrushConverter}}"
+ HorizontalAlignment="Center"
+ Text="{x:Bind ViewModel.Strings.SampleText}"/>
+ </StackPanel>
+ </Grid>
+
+ <Grid
+ x:Name="ContrastRatioGrid"
+ Grid.Row="2"
+ Grid.ColumnSpan="2"
+ Grid.Column="0"
+ ColumnSpacing="8"
+ RowSpacing="4">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition/>
+ <ColumnDefinition/>
+ <ColumnDefinition/>
+ <ColumnDefinition/>
+ </Grid.ColumnDefinitions>
<TextBlock
- Foreground="White"
- HorizontalAlignment="Center"
- Text="{x:Bind ViewModel.Strings.WhiteText}"/>
+ Grid.Row="0"
+ Grid.ColumnSpan="4"
+ Style="{StaticResource SubTitleTextBlock}"
+ Text="{x:Bind ViewModel.Strings.ContrastRatio}"
+ VerticalAlignment="Top"/>
+ <Border
+ Grid.Row="1"
+ Grid.Column="0"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
+ Background="{x:Bind ViewModel.WcagAaLevelLargeText, Mode=OneWay, Converter={StaticResource ContrastRatioBooleanToBrushConverter}}">
+ <Border.BackgroundTransition>
+ <BrushTransition />
+ </Border.BackgroundTransition>
+ <StackPanel
+ Orientation="Vertical"
+ Padding="12"
+ VerticalAlignment="Center">
+ <TextBlock
+ Text="{x:Bind ViewModel.Strings.LargeText}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.WCAG_AA}"
+ Style="{StaticResource SubtitleTextBlockStyle}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Pass}"
+ Visibility="{x:Bind ViewModel.WcagAaLevelLargeText, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Fail}"
+ Visibility="{x:Bind ViewModel.WcagAaLevelLargeText, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ </StackPanel>
+ </Border>
+ <Border
+ Grid.Row="1"
+ Grid.Column="1"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
+ Background="{x:Bind ViewModel.WcagAaLevelSmallText, Mode=OneWay, Converter={StaticResource ContrastRatioBooleanToBrushConverter}}">
+ <Border.BackgroundTransition>
+ <BrushTransition />
+ </Border.BackgroundTransition>
+ <StackPanel
+ Orientation="Vertical"
+ Padding="12"
+ VerticalAlignment="Center">
+ <TextBlock
+ Text="{x:Bind ViewModel.Strings.SmallText}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.WCAG_AA}"
+ Style="{StaticResource SubtitleTextBlockStyle}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Pass}"
+ Visibility="{x:Bind ViewModel.WcagAaLevelSmallText, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Fail}"
+ Visibility="{x:Bind ViewModel.WcagAaLevelSmallText, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ </StackPanel>
+ </Border>
+ <Border
+ Grid.Row="1"
+ Grid.Column="2"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
+ Background="{x:Bind ViewModel.WcagAaaLevelLargeText, Mode=OneWay, Converter={StaticResource ContrastRatioBooleanToBrushConverter}}">
+ <Border.BackgroundTransition>
+ <BrushTransition />
+ </Border.BackgroundTransition>
+ <StackPanel
+ Orientation="Vertical"
+ Padding="12"
+ VerticalAlignment="Center">
+ <TextBlock
+ Text="{x:Bind ViewModel.Strings.LargeText}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.WCAG_AAA}"
+ Style="{StaticResource SubtitleTextBlockStyle}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Pass}"
+ Visibility="{x:Bind ViewModel.WcagAaaLevelLargeText, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Fail}"
+ Visibility="{x:Bind ViewModel.WcagAaaLevelLargeText, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ </StackPanel>
+ </Border>
+ <Border
+ Grid.Row="1"
+ Grid.Column="3"
+ CornerRadius="{ThemeResource ControlCornerRadius}"
+ Background="{x:Bind ViewModel.WcagAaaLevelSmallText, Mode=OneWay, Converter={StaticResource ContrastRatioBooleanToBrushConverter}}">
+ <Border.BackgroundTransition>
+ <BrushTransition />
+ </Border.BackgroundTransition>
+ <StackPanel
+ Orientation="Vertical"
+ Padding="12"
+ VerticalAlignment="Center">
+ <TextBlock
+ Text="{x:Bind ViewModel.Strings.SmallText}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.WCAG_AAA}"
+ Style="{StaticResource SubtitleTextBlockStyle}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Pass}"
+ Visibility="{x:Bind ViewModel.WcagAaaLevelSmallText, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ <TextBlock
+ Margin="0,4,0,0"
+ Text="{x:Bind ViewModel.Strings.Fail}"
+ Visibility="{x:Bind ViewModel.WcagAaaLevelSmallText, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
+ HorizontalAlignment="Center"
+ Foreground="White"/>
+ </StackPanel>
+ </Border>
+ </Grid>
+
+ <StackPanel
+ x:Name="ColorPickerStackPanel"
+ Grid.Row="3"
+ Grid.Column="0"
+ Grid.ColumnSpan="2"
+ Spacing="4"
+ Margin="0,0,0,12">
+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.TextColor}" />
+
+ <muxc:ColorPicker
+ x:Name="ColorPicker"
+ Color="{x:Bind ViewModel.TextColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ ColorSpectrumShape="Box"
+ ColorSpectrumComponents="{x:Bind ViewModel.ColorPickerMode.Value, Mode=OneWay}"
+ IsAlphaEnabled="True"
+ IsColorPreviewVisible="False"
+ Orientation="Vertical"
+ HorizontalAlignment="Left"/>
</StackPanel>
- </StackPanel>
- <StackPanel
- Grid.Row="2"
- Spacing="4">
- <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.ColorPicker}" />
+ <StackPanel
+ x:Name="ColorPicker2StackPanel"
+ Grid.Row="4"
+ Grid.Column="0"
+ Grid.ColumnSpan="2"
+ Spacing="4">
+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.BackgroundColor}" />
- <muxc:ColorPicker
- x:Name="ColorPicker"
- Color="{x:Bind ViewModel.SelectedColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- ColorSpectrumShape="Box"
- ColorSpectrumComponents="{x:Bind ViewModel.ColorPickerMode.Value, Mode=OneWay}"
- IsAlphaEnabled="True"
- IsColorPreviewVisible="False"
- Orientation="Horizontal"/>
- </StackPanel>
- </Grid>
+ <muxc:ColorPicker
+ x:Name="ColorPicker2"
+ Color="{x:Bind ViewModel.BackgroundColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ ColorSpectrumShape="Box"
+ ColorSpectrumComponents="{x:Bind ViewModel.ColorPickerMode.Value, Mode=OneWay}"
+ IsAlphaEnabled="True"
+ IsColorPreviewVisible="False"
+ Orientation="Vertical"
+ HorizontalAlignment="Left"/>
+ </StackPanel>
+ </Grid>
+ </Border>
</Page>
diff --git a/src/dev/impl/DevToys/Views/Tools/Graphic/PngJpgCompressor/PngJpgCompressorToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/Graphic/PngJpgCompressor/PngJpgCompressorToolPage.xaml
index f76cd431c..76fa2cf68 100644
--- a/src/dev/impl/DevToys/Views/Tools/Graphic/PngJpgCompressor/PngJpgCompressorToolPage.xaml
+++ b/src/dev/impl/DevToys/Views/Tools/Graphic/PngJpgCompressor/PngJpgCompressorToolPage.xaml
@@ -92,7 +92,7 @@
Width="42"
Height="42"
FontSize="42"
- Foreground="Green"
+ Foreground="#10893E"
Glyph="&#xF298;">
<FontIcon.OpacityTransition>
<ScalarTransition/>
@@ -108,7 +108,7 @@
Width="42"
Height="42"
FontSize="42"
- Foreground="Red"
+ Foreground="#E81123"
Glyph="&#xF36D;">
<FontIcon.OpacityTransition>
<ScalarTransition/>