diff --git a/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.ts b/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.ts
index 47f5a9b01e..365bd6e8a1 100644
--- a/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.ts
+++ b/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.ts
@@ -115,7 +115,7 @@ var updateOptions = function (opt: monaco.editor.IEditorOptions) {
var updateDiffOptions = function (opt: monaco.editor.IDiffEditorOptions) {
var diffEditor = (editor as unknown) as monaco.editor.IStandaloneDiffEditor;
- if (opt != null && typeof opt === "object") {
+ if (diffEditor != null && opt != null && typeof opt === "object") {
diffEditor.updateOptions(opt);
}
};
diff --git a/src/dev/impl/DevToys/Api/Core/Theme/IThemeListener.cs b/src/dev/impl/DevToys/Api/Core/Theme/IThemeListener.cs
index 28b04bcfee..a6ea87e98e 100644
--- a/src/dev/impl/DevToys/Api/Core/Theme/IThemeListener.cs
+++ b/src/dev/impl/DevToys/Api/Core/Theme/IThemeListener.cs
@@ -1,6 +1,7 @@
#nullable enable
using System;
+using Windows.UI.Xaml;
namespace DevToys.Api.Core.Theme
{
@@ -16,6 +17,11 @@ public interface IThemeListener
///
AppTheme CurrentAppTheme { get; }
+ ///
+ /// Gets the actual theme applied in the app.
+ ///
+ ApplicationTheme ActualAppTheme { get; }
+
///
/// Gets or sets a value indicating whether the current theme is high contrast.
///
diff --git a/src/dev/impl/DevToys/Assets/ReleaseNote.txt b/src/dev/impl/DevToys/Assets/ReleaseNote.txt
index 5a3a4229b2..3e5d826b15 100644
--- a/src/dev/impl/DevToys/Assets/ReleaseNote.txt
+++ b/src/dev/impl/DevToys/Assets/ReleaseNote.txt
@@ -5,5 +5,6 @@
• RegEx Tester tool got new options.
• New layout.
• Text editor can now use any font.
+ • Russian translation improved.
🐛 Bug Fixes
• Minor bugs fixed.
\ No newline at end of file
diff --git a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs b/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
index 55ee10e8ea..bffebdb22a 100644
--- a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
+++ b/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
@@ -23,6 +23,8 @@ internal sealed class ThemeListener : IThemeListener
public AppTheme CurrentAppTheme => _settingsProvider.GetSetting(PredefinedSettings.Theme);
+ public ApplicationTheme ActualAppTheme { get; private set; }
+
public bool IsHighContrast { get; private set; }
public event EventHandler? ThemeChanged;
@@ -59,6 +61,7 @@ public void ApplyDesiredColorTheme()
if (Window.Current.Content is FrameworkElement frameworkElement)
{
frameworkElement.RequestedTheme = theme == AppTheme.Light ? ElementTheme.Light : ElementTheme.Dark;
+ ActualAppTheme = theme == AppTheme.Light ? ApplicationTheme.Light : ApplicationTheme.Dark;
}
}
@@ -96,6 +99,7 @@ private void SettingsProvider_SettingChanged(object sender, SettingChangedEventA
if (string.Equals(PredefinedSettings.Theme.Name, e.SettingName, StringComparison.Ordinal))
{
ApplyDesiredColorTheme();
+ ThemeChanged?.Invoke(this, EventArgs.Empty);
}
}
diff --git a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
index 34adeba794..4e6053d1d9 100644
--- a/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
+++ b/src/dev/impl/DevToys/UI/Controls/ExpandableSettingControl.xaml.cs
@@ -1,5 +1,7 @@
#nullable enable
+using DevToys.Api.Core.Theme;
+using DevToys.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
@@ -10,9 +12,13 @@ namespace DevToys.UI.Controls
[ContentProperty(Name = nameof(SettingActionableElement))]
public sealed partial class ExpandableSettingControl : UserControl
{
+ private bool _isAppThemeChanging;
+ private bool _isDefaultHeaderBackgroundValue = true;
+ private bool _isDefaultContentBackgroundValue = true;
+
public FrameworkElement? SettingActionableElement { get; set; }
- public static readonly DependencyProperty TitleProperty
+ public static readonly DependencyProperty TitleProperty
= DependencyProperty.Register(
nameof(Title),
typeof(string),
@@ -51,7 +57,7 @@ public IconElement Icon
set => SetValue(IconProperty, value);
}
- public static readonly DependencyProperty ExpandableContentProperty
+ public static readonly DependencyProperty ExpandableContentProperty
= DependencyProperty.Register(
nameof(ExpandableContent),
typeof(FrameworkElement),
@@ -82,7 +88,14 @@ public static readonly DependencyProperty ContentBackgroundProperty
nameof(ContentBackground),
typeof(Brush),
typeof(ExpandableSettingControl),
- new PropertyMetadata(Application.Current.Resources["ExpanderContentBackground"]));
+ new PropertyMetadata(null, (d, e) =>
+ {
+ var ctrl = (ExpandableSettingControl)d;
+ if (!ctrl._isAppThemeChanging)
+ {
+ ctrl._isDefaultContentBackgroundValue = false;
+ }
+ }));
public Brush ContentBackground
{
@@ -95,7 +108,14 @@ public static readonly DependencyProperty HeaderBackgroundProperty
nameof(HeaderBackground),
typeof(Brush),
typeof(ExpandableSettingControl),
- new PropertyMetadata(Application.Current.Resources["ExpanderHeaderBackground"]));
+ new PropertyMetadata(null, (d, e) =>
+ {
+ var ctrl = (ExpandableSettingControl)d;
+ if (!ctrl._isAppThemeChanging)
+ {
+ ctrl._isDefaultHeaderBackgroundValue = false;
+ }
+ }));
public Brush HeaderBackground
{
@@ -106,6 +126,30 @@ public Brush HeaderBackground
public ExpandableSettingControl()
{
InitializeComponent();
+
+ MefComposer.Provider.Import().ThemeChanged += ExpandableSettingControl_ThemeChanged;
+
+ _isAppThemeChanging = true;
+ ContentBackground = (Brush)Application.Current.Resources["ExpanderContentBackground"];
+ HeaderBackground = (Brush)Application.Current.Resources["ExpanderHeaderBackground"];
+ _isAppThemeChanging = false;
+ }
+
+ private void ExpandableSettingControl_ThemeChanged(object sender, System.EventArgs e)
+ {
+ _isAppThemeChanging = true;
+
+ if (_isDefaultContentBackgroundValue)
+ {
+ ContentBackground = (Brush)Application.Current.Resources["ExpanderContentBackground"];
+ }
+
+ if (_isDefaultHeaderBackgroundValue)
+ {
+ HeaderBackground = (Brush)Application.Current.Resources["ExpanderHeaderBackground"];
+ }
+
+ _isAppThemeChanging = false;
}
}
}
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
index 7ca8f09c21..a51848dc04 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
@@ -1,6 +1,7 @@
#nullable enable
using DevToys.Api.Core.Settings;
+using DevToys.Api.Core.Theme;
using DevToys.Api.Tools;
using DevToys.Core;
using DevToys.Core.Threading;
@@ -23,12 +24,13 @@ public sealed class MarkdownPreviewToolViewModel : ObservableRecipient, IToolVie
{
private static string? _htmlDocument;
- private static readonly SettingDefinition ThemeSetting
+ private static readonly SettingDefinition ThemeSetting
= new(
name: $"{nameof(MarkdownPreviewToolViewModel)}.{nameof(ThemeSetting)}",
isRoaming: true,
- defaultValue: ApplicationTheme.Light);
+ defaultValue: null);
+ private readonly IThemeListener _themeListener;
private readonly Queue _workQueue = new();
private bool _workInProgress;
@@ -53,12 +55,20 @@ internal string? InputValue
internal ApplicationTheme Theme
{
- get => SettingsProvider.GetSetting(ThemeSetting);
+ get
+ {
+ string? theme = SettingsProvider.GetSetting(ThemeSetting);
+ if (string.IsNullOrEmpty(theme))
+ {
+ theme = _themeListener.ActualAppTheme.ToString();
+ }
+ return (ApplicationTheme)Enum.Parse(typeof(ApplicationTheme), theme);
+ }
set
{
- if (SettingsProvider.GetSetting(ThemeSetting) != value)
+ if (!string.Equals(SettingsProvider.GetSetting(ThemeSetting), value.ToString()))
{
- SettingsProvider.SetSetting(ThemeSetting, value);
+ SettingsProvider.SetSetting(ThemeSetting, value.ToString());
OnPropertyChanged();
QueueWork();
}
@@ -68,8 +78,9 @@ internal ApplicationTheme Theme
internal ISettingsProvider SettingsProvider { get; }
[ImportingConstructor]
- public MarkdownPreviewToolViewModel(ISettingsProvider settingsProvider)
+ public MarkdownPreviewToolViewModel(ISettingsProvider settingsProvider, IThemeListener themeListener)
{
+ _themeListener = themeListener;
SettingsProvider = settingsProvider;
// Activate the view model's messenger.
diff --git a/tools/app-version-number.txt b/tools/app-version-number.txt
index 1a09779c6a..c05a067712 100644
--- a/tools/app-version-number.txt
+++ b/tools/app-version-number.txt
@@ -1 +1 @@
-0.6.5.0
\ No newline at end of file
+0.6.5.1
\ No newline at end of file