In Textviewer when OS is in dark mode and AllowDarkTheme is enabled in config file use dark background and light text (no syntax highlighting). (#1238)

With AllowDarkTheme disabled (default) use light background and light mode syntax highlighting.
This commit is contained in:
Frank Becker
2022-12-12 06:45:25 -08:00
committed by GitHub
parent 7f7d9805f1
commit 47540eef95
2 changed files with 13 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Xml;
using ICSharpCode.AvalonEdit;
using ICSharpCode.AvalonEdit.Highlighting;
@@ -149,6 +150,18 @@ namespace QuickLook.Plugin.TextViewer
var darkThemeAllowed = SettingHelper.Get("AllowDarkTheme", false, "QuickLook.Plugin.TextViewer");
var isDark = darkThemeAllowed && OSThemeHelper.AppsUseDarkTheme();
tvp.HighlightingManager = isDark ? _hlmDark : _hlmLight;
if (isDark)
{
tvp.Background = Brushes.Transparent;
tvp.SetResourceReference(Control.ForegroundProperty, "WindowTextForeground");
}
else
{
// if os dark mode, but not AllowDarkTheme, make background light
tvp.Background = OSThemeHelper.AppsUseDarkTheme()
? new SolidColorBrush(Color.FromArgb(150, 255, 255, 255))
: Brushes.Transparent;
}
}
}
}

View File

@@ -45,9 +45,6 @@ namespace QuickLook.Plugin.TextViewer
{
_context = context;
Background = OSThemeHelper.AppsUseDarkTheme()
? new SolidColorBrush(Color.FromArgb(150, 255, 255, 255))
: Brushes.Transparent;
FontSize = 14;
ShowLineNumbers = true;
WordWrap = true;