Skip to content

A Swiss Army knife for developers.

Changed the highlighting color so it use the accent color. (#112)

Etienne Baudoux43125618c3d6
diff --git a/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs b/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
index cdbaa56fa..eb90c749a 100644
--- a/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
+++ b/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
@@ -59,9 +59,14 @@ namespace DevToys.UI.Extensions
if (value.Length > 0)
{
+ ElementTheme currentTheme = ((Frame)Window.Current.Content).ActualTheme;
+ string? highlighterBackgroundResourceName = currentTheme == ElementTheme.Light ? "SystemAccentColorLight2" : "SystemAccentColorDark1";
+ Color highlighterForegroundColor = currentTheme == ElementTheme.Light ? Colors.Black : Colors.White;
+
var highlighter = new TextHighlighter()
{
- Background = new SolidColorBrush(Colors.Yellow)
+ Background = new SolidColorBrush((Color)Application.Current.Resources[highlighterBackgroundResourceName]),
+ Foreground = new SolidColorBrush(highlighterForegroundColor)
};
for (int i = 0; i < value.Length; i++)
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Text/RegEx/RegExToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Text/RegEx/RegExToolViewModel.cs
index b9184aa2c..de5d12bbb 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Text/RegEx/RegExToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Text/RegEx/RegExToolViewModel.cs
@@ -14,6 +14,8 @@ using DevToys.UI.Controls;
using DevToys.Views.Tools.RegEx;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Windows.UI;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
namespace DevToys.ViewModels.Tools.RegEx
{
@@ -218,6 +220,16 @@ namespace DevToys.ViewModels.Tools.RegEx
_calculationInProgress = true;
+ Color highlighterForegroundColor;
+ Color highlighterBackgroundColor;
+ await ThreadHelper.RunOnUIThreadAsync(() =>
+ {
+ ElementTheme currentTheme = ((Frame)Window.Current.Content).ActualTheme;
+ string? highlighterBackgroundResourceName = currentTheme == ElementTheme.Light ? "SystemAccentColorLight2" : "SystemAccentColorDark1";
+ highlighterForegroundColor = currentTheme == ElementTheme.Light ? Colors.Black : Colors.White;
+ highlighterBackgroundColor = (Color)Application.Current.Resources[highlighterBackgroundResourceName];
+ });
+
await TaskScheduler.Default;
while (_regExMatchingQueue.TryDequeue(out (string pattern, string text) data))
@@ -238,8 +250,8 @@ namespace DevToys.ViewModels.Tools.RegEx
{
StartIndex = match.Index,
Length = match.Length,
- BackgroundColor = Colors.Yellow,
- ForegroundColor = Colors.Black
+ BackgroundColor = highlighterBackgroundColor,
+ ForegroundColor = highlighterForegroundColor
});
}
}