From c379cca2e56faac3c9e428c9a5cc39fa9c5abb89 Mon Sep 17 00:00:00 2001 From: ColdTune <44409675+ColdTune@users.noreply.github.com> Date: Thu, 23 Jul 2020 03:53:19 -0500 Subject: [PATCH] [FancyZones Editor] Prevent new zones from being unreachable (#4457) * stack new zones * Changed startup location of window editor * Zones start in upper left * Changed Focus Zone Initialization * Zones.Add * Reset zone position when it goes off screen --- .../FancyZonesEditor/CanvasEditorWindow.xaml.cs | 14 ++++++++++++-- .../editor/FancyZonesEditor/Models/Settings.cs | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs index 94aedb369a..b486e52636 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs @@ -21,8 +21,18 @@ namespace FancyZonesEditor private void OnAddZone(object sender, RoutedEventArgs e) { - _model.AddZone(new Int32Rect(_offset, _offset, (int)(Settings.WorkArea.Width * 0.6), (int)(Settings.WorkArea.Height * 0.6))); - _offset += 100; + if (_offset + (int)(Settings.WorkArea.Width * 0.4) < (int)Settings.WorkArea.Width + && _offset + (int)(Settings.WorkArea.Height * 0.4) < (int)Settings.WorkArea.Height) + { + _model.AddZone(new Int32Rect(_offset, _offset, (int)(Settings.WorkArea.Width * 0.4), (int)(Settings.WorkArea.Height * 0.4))); + } + else + { + _offset = 100; + _model.AddZone(new Int32Rect(_offset, _offset, (int)(Settings.WorkArea.Width * 0.4), (int)(Settings.WorkArea.Height * 0.4))); + } + + _offset += 50; } protected new void OnCancel(object sender, RoutedEventArgs e) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs index 1d73e01770..b996a7994e 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs @@ -292,9 +292,9 @@ namespace FancyZonesEditor ZoneCount = 3; } - Int32Rect focusZoneRect = new Int32Rect((int)(WorkArea.Width * 0.1), (int)(WorkArea.Height * 0.1), (int)(WorkArea.Width * 0.6), (int)(WorkArea.Height * 0.6)); - int focusRectXIncrement = (ZoneCount <= 1) ? 0 : (int)(WorkArea.Width * 0.2) / (ZoneCount - 1); - int focusRectYIncrement = (ZoneCount <= 1) ? 0 : (int)(WorkArea.Height * 0.2) / (ZoneCount - 1); + Int32Rect focusZoneRect = new Int32Rect(100, 100, (int)(WorkArea.Width * 0.4), (int)(WorkArea.Height * 0.4)); + int focusRectXIncrement = (ZoneCount <= 1) ? 0 : 50; + int focusRectYIncrement = (ZoneCount <= 1) ? 0 : 50; for (int i = 0; i < ZoneCount; i++) {