diff --git a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Events.cs b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Events.cs index 62845d5bae..e8bd42563c 100644 --- a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Events.cs +++ b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Events.cs @@ -55,6 +55,12 @@ namespace RegistryPreview resourceLoader.GetString("YesNoCancelDialogCloseButtonText")); } + // Check to see if the textbox's context menu is open + if (textBox.ContextFlyout != null && textBox.ContextFlyout.IsOpen) + { + textBox.ContextFlyout.Hide(); + } + // Save window placement SaveWindowPlacementFile(settingsFolder, windowPlacementFile); } diff --git a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs index f3da13a340..0941943639 100644 --- a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs +++ b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.Utilities.cs @@ -292,13 +292,20 @@ namespace RegistryPreview // set the name and the value string name = registryLine.Substring(0, equal); + + // trim the whitespace and quotes from the name + name = name.Trim(); name = StripFirstAndLast(name); // Clean out any escaped characters in the value, only for the preview name = StripEscapedCharacters(name); + // set the value string value = registryLine.Substring(equal + 1); + // trim the whitespace from the value + value = value.Trim(); + // Create a new listview item that will be used to display the value registryValue = new RegistryValue(name, "REG_SZ", string.Empty); @@ -1028,8 +1035,11 @@ namespace RegistryPreview try { - fileContents = jsonWindowPlacement.Stringify(); - await Windows.Storage.FileIO.WriteTextAsync(storageFile, fileContents); + if (jsonWindowPlacement != null) + { + fileContents = jsonWindowPlacement.Stringify(); + await Windows.Storage.FileIO.WriteTextAsync(storageFile, fileContents); + } } catch (Exception ex) { diff --git a/src/modules/registrypreview/RegistryPreviewUI/RegistryPreviewXAML/App.xaml.cs b/src/modules/registrypreview/RegistryPreviewUI/RegistryPreviewXAML/App.xaml.cs index d66e8d0ded..71b3eadd72 100644 --- a/src/modules/registrypreview/RegistryPreviewUI/RegistryPreviewXAML/App.xaml.cs +++ b/src/modules/registrypreview/RegistryPreviewUI/RegistryPreviewXAML/App.xaml.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Web; using Microsoft.UI.Xaml; using Microsoft.Windows.AppLifecycle; using Windows.ApplicationModel.Activation; @@ -52,6 +53,20 @@ namespace RegistryPreview } } } + else if (activatedArgs.Kind == ExtendedActivationKind.Protocol) + { + // When the app is the default handler for REG files and the filename has non-ASCII characters, the app gets activated by Protocol + AppFilename = string.Empty; + if (activatedArgs.Data != null) + { + IProtocolActivatedEventArgs eventArgs = (IProtocolActivatedEventArgs)activatedArgs.Data; + if (eventArgs.Uri.AbsoluteUri.Length > 0) + { + AppFilename = eventArgs.Uri.Query.Replace("?ContractId=Windows.File&Verb=open&File=", string.Empty); + AppFilename = HttpUtility.UrlDecode(AppFilename); + } + } + } else { // Right click on a REG file and selected Preview