From ead0a0d5b22933c899dd183112f6e0a378369029 Mon Sep 17 00:00:00 2001 From: BlueFinBima Date: Wed, 16 Oct 2024 12:08:48 +0100 Subject: [PATCH] Fix for empty rectangle being passed to ConvertToDCS in MonitorSetupGenerator when simulate monitor in profile tool is selected. #584 Tighten up the profile monitor checking against the physical displays in HeliosProfile because it was returning a match when the profile only contained a subset of the real monitors. Now the number of Monitors in the profile must match the number of displays. --- Helios/HeliosProfile.cs | 2 +- Patching/DCS/MonitorSetupGenerator.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Helios/HeliosProfile.cs b/Helios/HeliosProfile.cs index 2b951fa9..0d2bc937 100644 --- a/Helios/HeliosProfile.cs +++ b/Helios/HeliosProfile.cs @@ -205,7 +205,7 @@ public bool IsValidMonitorLayout } CheckedDisplays = ConfigManager.DisplayManager.Displays; - _validLayout = true; + _validLayout = CheckedDisplays.Count == Monitors.Count; foreach (Monitor display in Monitors) { if (CheckedDisplays.Any(systemDisplay => diff --git a/Patching/DCS/MonitorSetupGenerator.cs b/Patching/DCS/MonitorSetupGenerator.cs index 460bf6e5..a96d7eab 100644 --- a/Patching/DCS/MonitorSetupGenerator.cs +++ b/Patching/DCS/MonitorSetupGenerator.cs @@ -301,8 +301,14 @@ private IEnumerable UpdateMonitorSetup(MonitorSetupTemplate te internal void ConvertToDCS(ref Rect windowsRect) { - windowsRect.Offset(-_parent.Rendered.TopLeft.X, -_parent.Rendered.TopLeft.Y); - windowsRect.Scale(ConfigManager.DisplayManager.PixelsPerDip, ConfigManager.DisplayManager.PixelsPerDip); + if (!windowsRect.IsEmpty) + { + windowsRect.Offset(-_parent.Rendered.TopLeft.X, -_parent.Rendered.TopLeft.Y); + windowsRect.Scale(ConfigManager.DisplayManager.PixelsPerDip, ConfigManager.DisplayManager.PixelsPerDip); + } else + { + windowsRect = _parent.Rendered; + } } private bool TryCreateViewport(ICollection lines, KeyValuePair viewport, string indent, out FormattableString code)