A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
fix #46 (#49)
Etienne Baudouxe880a8c0d683
diff --git a/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.ts b/src/dev/impl/DevToys.MonacoEditor/ts-helpermethods/otherScriptsToBeOrganized.tsindex 47f5a9b01..365bd6e8a 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.csindex 28b04bcfe..a6ea87e98 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 enableusing System;+using Windows.UI.Xaml;namespace DevToys.Api.Core.Theme{@@ -16,6 +17,11 @@ namespace DevToys.Api.Core.Theme/// </summary>AppTheme CurrentAppTheme { get; }+ /// <summary>+ /// Gets the actual theme applied in the app.+ /// </summary>+ ApplicationTheme ActualAppTheme { get; }+/// <summary>/// Gets or sets a value indicating whether the current theme is high contrast./// </summary>diff --git a/src/dev/impl/DevToys/Assets/ReleaseNote.txt b/src/dev/impl/DevToys/Assets/ReleaseNote.txtindex 5a3a4229b..3e5d826b1 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 filediff --git a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs b/src/dev/impl/DevToys/Core/Theme/ThemeListener.csindex 55ee10e8e..bffebdb22 100644--- a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs+++ b/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs@@ -23,6 +23,8 @@ namespace DevToys.Core.Themepublic 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 @@ namespace DevToys.Core.Themeif (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 @@ namespace DevToys.Core.Themeif (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.csindex 34adeba79..4e6053d1d 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 @@ namespace DevToys.UI.Controlsset => SetValue(IconProperty, value);}- public static readonly DependencyProperty ExpandableContentProperty+ public static readonly DependencyProperty ExpandableContentProperty= DependencyProperty.Register(nameof(ExpandableContent),typeof(FrameworkElement),@@ -82,7 +88,14 @@ namespace DevToys.UI.Controlsnameof(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 @@ namespace DevToys.UI.Controlsnameof(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 @@ namespace DevToys.UI.Controlspublic ExpandableSettingControl(){InitializeComponent();++ MefComposer.Provider.Import<IThemeListener>().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.csindex 7ca8f09c2..a51848dc0 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 enableusing DevToys.Api.Core.Settings;+using DevToys.Api.Core.Theme;using DevToys.Api.Tools;using DevToys.Core;using DevToys.Core.Threading;@@ -23,12 +24,13 @@ namespace DevToys.ViewModels.Tools.MarkdownPreview{private static string? _htmlDocument;- private static readonly SettingDefinition<ApplicationTheme> ThemeSetting+ private static readonly SettingDefinition<string?> ThemeSetting= new(name: $"{nameof(MarkdownPreviewToolViewModel)}.{nameof(ThemeSetting)}",isRoaming: true,- defaultValue: ApplicationTheme.Light);+ defaultValue: null);+ private readonly IThemeListener _themeListener;private readonly Queue<string> _workQueue = new();private bool _workInProgress;@@ -53,12 +55,20 @@ namespace DevToys.ViewModels.Tools.MarkdownPreviewinternal 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 @@ namespace DevToys.ViewModels.Tools.MarkdownPreviewinternal 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.txtindex 1a09779c6..c05a06771 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