Skip to content

Commit

Permalink
Added the possibility to toggle highlight (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Mar 17, 2024
1 parent 80d47cf commit ba61f41
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 23 deletions.
9 changes: 9 additions & 0 deletions ColorPicker/Pages/ContrastPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,15 @@
Foreground="{DynamicResource AccentColor}"
GroupName="ScoreToggles"
Style="{DynamicResource DefaultToggleButton}" />
<CheckBox
x:Name="ShowHighlight"
VerticalContentAlignment="Center"
BorderThickness="2"
Checked="ShowHighlight_Checked"
Content="{x:Static lang:Resources.HighlightColorGrid}"
Foreground="{DynamicResource Foreground1}"
Style="{DynamicResource CheckBoxStyle1}"
Unchecked="ShowHighlight_Checked" />
</StackPanel>
<Grid x:Name="ContrastGrid" Grid.Row="3">
<Grid.ColumnDefinitions>
Expand Down
54 changes: 31 additions & 23 deletions ColorPicker/Pages/ContrastPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,31 +409,34 @@ internal void InitGrid(double limit)
}


Border ColBorder = new()
if (ShowHighlight.IsChecked ?? false)
{
Name = "ColBorder",
BorderBrush = Global.GetColorFromResource("AccentColor"),
BorderThickness = new Thickness(2),
CornerRadius = new CornerRadius(5)
};
Border ColBorder = new()
{
Name = "ColBorder",
BorderBrush = Global.GetColorFromResource("AccentColor"),
BorderThickness = new Thickness(2),
CornerRadius = new CornerRadius(5)
};

Border RowBorder = new()
{
Name = "RowBorder",
BorderBrush = Global.GetColorFromResource("AccentColor"),
BorderThickness = new Thickness(2),
CornerRadius = new CornerRadius(5)
};

Grid.SetColumn(ColBorder, 11-lumValues.IndexOf(ColorInfo.HSL.L) );
Grid.SetRow(RowBorder, 11-lumValues.IndexOf(ColorInfo.HSL.L));
Grid.SetRowSpan(ColBorder, 12);
Grid.SetColumnSpan(RowBorder, 12);
Panel.SetZIndex(ColBorder, 10);
Panel.SetZIndex(RowBorder, 10);

ContrastGrid.Children.Add(ColBorder);
ContrastGrid.Children.Add(RowBorder);
Border RowBorder = new()
{
Name = "RowBorder",
BorderBrush = Global.GetColorFromResource("AccentColor"),
BorderThickness = new Thickness(2),
CornerRadius = new CornerRadius(5)
};

Grid.SetColumn(ColBorder, 11 - lumValues.IndexOf(ColorInfo.HSL.L));
Grid.SetRow(RowBorder, 11 - lumValues.IndexOf(ColorInfo.HSL.L));
Grid.SetRowSpan(ColBorder, 12);
Grid.SetColumnSpan(RowBorder, 12);
Panel.SetZIndex(ColBorder, 10);
Panel.SetZIndex(RowBorder, 10);

ContrastGrid.Children.Add(ColBorder);
ContrastGrid.Children.Add(RowBorder);
}

// Load the bookmark icon
if (!Global.Bookmarks.ColorBookmarks.Contains($"#{ColorInfo.HEX.Value}"))
Expand Down Expand Up @@ -463,4 +466,9 @@ private void ScoreAAAToggle_Checked(object sender, RoutedEventArgs e)
contrastLimit = 7;
InitGrid(contrastLimit);
}

private void ShowHighlight_Checked(object sender, RoutedEventArgs e)
{
InitGrid(contrastLimit);
}
}
9 changes: 9 additions & 0 deletions ColorPicker/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,7 @@
<data name="Save" xml:space="preserve">
<value>Save</value>
</data>
<data name="HighlightColorGrid" xml:space="preserve">
<value>Highlight color</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,7 @@
<data name="Save" xml:space="preserve">
<value>Enregistrer</value>
</data>
<data name="HighlightColorGrid" xml:space="preserve">
<value>Mettre en évidence la couleur</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -724,4 +724,7 @@
<data name="Save" xml:space="preserve">
<value>Save</value>
</data>
<data name="HighlightColorGrid" xml:space="preserve">
<value>Highlight color</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -752,4 +752,7 @@
<data name="Save" xml:space="preserve">
<value>节省</value>
</data>
<data name="HighlightColorGrid" xml:space="preserve">
<value>高光颜色</value>
</data>
</root>

0 comments on commit ba61f41

Please sign in to comment.