A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Fixed minor bugs
Etienne Baudouxe438da153934
diff --git a/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs b/src/dev/impl/DevToys/Core/Navigation/WindowManager.csindex 4b432f895..7d19ef7e6 100644--- a/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs+++ b/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs@@ -12,6 +12,7 @@ using Windows.UI.Xaml.Controls;namespace DevToys.Core.Navigation{[Export(typeof(IWindowManager))]+ [Shared]internal sealed class WindowManager : IWindowManager{public Task<bool> ShowContentDialogAsync(object content, string primaryButtonText, string? secondaryButtonText = null, string? title = null)diff --git a/src/dev/impl/DevToys/Core/TitleBar.cs b/src/dev/impl/DevToys/Core/TitleBar.csindex 9f7f1f8a2..a0572e6d7 100644--- a/src/dev/impl/DevToys/Core/TitleBar.cs+++ b/src/dev/impl/DevToys/Core/TitleBar.cs@@ -25,6 +25,7 @@ namespace DevToys.Coreprivate readonly IThemeListener _themeListener;private double _systemOverlayRightInset;+ private bool _coreTitleBarEventAttached;public double SystemOverlayRightInset{@@ -76,7 +77,13 @@ namespace DevToys.Core// Register a handler for when the size of the overlaid caption control changes.// For example, when the app moves to a screen with a different DPI.- coreTitleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;+ if (!_coreTitleBarEventAttached)+ {+ coreTitleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;++ // Doing this allows us to avoid registering the event each time we switch from Overlay Mode to normal mode.+ _coreTitleBarEventAttached = true;+ }SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex b41016a92..50ac4a401 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -341,6 +341,11 @@ namespace DevToys/// </summary>public string Megabytes => _resources.GetString("Megabytes");+ /// <summary>+ /// Gets the resource Ok.+ /// </summary>+ public string Ok => _resources.GetString("Ok");+/// <summary>/// Gets the resource OpenFile./// </summary>@@ -376,6 +381,24 @@ namespace DevToys/// </summary>public string ToggleSwitchOn => _resources.GetString("ToggleSwitchOn");+ /// <summary>+ /// Gets the resource UnableOpenFile.+ /// </summary>+ public string UnableOpenFile => _resources.GetString("UnableOpenFile");++ /// <summary>+ /// Gets the resource UnableOpenFileDescription.+ /// </summary>+ public string UnableOpenFileDescription => _resources.GetString("UnableOpenFileDescription");++ /// <summary>+ /// Gets the resource UnableOpenFileDescription with format.+ /// </summary>+ public string GetFormattedUnableOpenFileDescription(string? param0)+ {+ return string.Format(UnableOpenFileDescription, param0);+ }+/// <summary>/// Gets the resource Undo./// </summary>diff --git a/src/dev/impl/DevToys/Strings/en-US/Common.resw b/src/dev/impl/DevToys/Strings/en-US/Common.reswindex d82823e8b..2a0ea05fe 100644--- a/src/dev/impl/DevToys/Strings/en-US/Common.resw+++ b/src/dev/impl/DevToys/Strings/en-US/Common.resw@@ -141,6 +141,9 @@<data name="Megabytes" xml:space="preserve"><value>MB</value></data>+ <data name="Ok" xml:space="preserve">+ <value>OK</value>+ </data><data name="OpenFile" xml:space="preserve"><value>Load a file</value></data>@@ -162,6 +165,12 @@<data name="ToggleSwitchOn" xml:space="preserve"><value>On</value></data>+ <data name="UnableOpenFile" xml:space="preserve">+ <value>Unable to open this file</value>+ </data>+ <data name="UnableOpenFileDescription" xml:space="preserve">+ <value>Unable to load the file '{0}'. For more details, please check the log.</value>+ </data><data name="Undo" xml:space="preserve"><value>Undo</value></data>diff --git a/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs b/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.csindex ae74b038b..c7e0af688 100644--- a/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs+++ b/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs@@ -4,6 +4,7 @@ using System;using DevToys.Api.Core.Settings;using DevToys.Core;using DevToys.Core.Settings;+using DevToys.Core.Threading;using DevToys.MonacoEditor.CodeEditorControl;using DevToys.MonacoEditor.Monaco.Editor;using Windows.ApplicationModel.DataTransfer;@@ -196,7 +197,13 @@ namespace DevToys.UI.Controls}else{- ReloadCodeEditorCore();+ try+ {+ ReloadCodeEditorCore();+ }+ catch+ {+ }}_codeEditorCodeReloadTentative++;@@ -494,7 +501,23 @@ namespace DevToys.UI.Controlscatch (Exception ex){Logger.LogFault("Failed to load a file into a code editor", ex);- // TODO: Show a modal explaining the user that we can't read the file. Maybe it's not a text file.++ await ThreadHelper.RunOnUIThreadAsync(async () =>+ {+ var confirmationDialog = new ContentDialog+ {+ Title = LanguageManager.Instance.Common.UnableOpenFile,+ Content = LanguageManager.Instance.Common.GetFormattedUnableOpenFileDescription(file.Name),+ CloseButtonText = LanguageManager.Instance.Common.Ok,+ PrimaryButtonText = LanguageManager.Instance.Settings.OpenLogs,+ DefaultButton = ContentDialogButton.Close+ };++ if (await confirmationDialog.ShowAsync() == ContentDialogResult.Primary)+ {+ await Logger.OpenLogsAsync();+ }+ });}}}diff --git a/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs b/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.csindex acb8f6baa..59467d723 100644--- a/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs+++ b/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs@@ -4,6 +4,7 @@ using System;using System.Collections.Generic;using System.Linq;using DevToys.Core;+using DevToys.Core.Threading;using Microsoft.Toolkit.Mvvm.Input;using Windows.ApplicationModel.DataTransfer;using Windows.Storage;@@ -545,9 +546,26 @@ namespace DevToys.UI.ControlsText = text;});}- catch+ catch (Exception ex){- // TODO: Show a modal explaining the user that we can't read the file. Maybe it's not a text file.+ Logger.LogFault("Failed to load a file into a code editor", ex);++ await ThreadHelper.RunOnUIThreadAsync(async () =>+ {+ var confirmationDialog = new ContentDialog+ {+ Title = LanguageManager.Instance.Common.UnableOpenFile,+ Content = LanguageManager.Instance.Common.GetFormattedUnableOpenFileDescription(file.Name),+ CloseButtonText = LanguageManager.Instance.Common.Ok,+ PrimaryButtonText = LanguageManager.Instance.Settings.OpenLogs,+ DefaultButton = ContentDialogButton.Close+ };++ if (await confirmationDialog.ShowAsync() == ContentDialogResult.Primary)+ {+ await Logger.OpenLogsAsync();+ }+ });}}}diff --git a/src/dev/impl/DevToys/Views/MainPage.xaml b/src/dev/impl/DevToys/Views/MainPage.xamlindex cb0db11be..78d9e16e3 100644--- a/src/dev/impl/DevToys/Views/MainPage.xaml+++ b/src/dev/impl/DevToys/Views/MainPage.xaml@@ -257,7 +257,7 @@Command="{Binding PinToolToStartCommand}"CommandParameter="{x:Bind Metadata}"><MenuFlyoutItem.Icon>- <FontIcon Glyph="" />+ <FontIcon Glyph="" /></MenuFlyoutItem.Icon></MenuFlyoutItem></MenuFlyout>