From 518f8d6ddaa5a58efc228e4d3882561961250d91 Mon Sep 17 00:00:00 2001 From: Randy Date: Mon, 10 Apr 2023 00:25:47 -0700 Subject: [PATCH] Clamps window size and position (#25267) Adds a floor value for size (320x240) and position (0x0) --- .../RegistryPreviewUI/MainWindow.xaml.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.xaml.cs b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.xaml.cs index ebfa0d624b..af20f106dd 100644 --- a/src/modules/registrypreview/RegistryPreviewUI/MainWindow.xaml.cs +++ b/src/modules/registrypreview/RegistryPreviewUI/MainWindow.xaml.cs @@ -62,7 +62,12 @@ namespace RegistryPreview SizeInt32 size; size.Width = (int)jsonSettings.GetNamedNumber("appWindow.Size.Width"); size.Height = (int)jsonSettings.GetNamedNumber("appWindow.Size.Height"); - appWindow.Resize(size); + + // check to make sure the size values are reasonable before attempting to restore the last saved size + if (size.Width >= 320 && size.Height >= 240) + { + appWindow.Resize(size); + } } // reposition the window @@ -71,7 +76,12 @@ namespace RegistryPreview PointInt32 point; point.X = (int)jsonSettings.GetNamedNumber("appWindow.Position.X"); point.Y = (int)jsonSettings.GetNamedNumber("appWindow.Position.Y"); - appWindow.Move(point); + + // check to make sure the move values are reasonable before attempting to restore the last saved location + if (point.X >= 0 && point.Y >= 0) + { + appWindow.Move(point); + } } }