From 76136c71a90f2e491602324731d1e202abe83bbd Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 22 Nov 2017 02:00:51 -0600 Subject: [PATCH] Correct window location saving to take window state into account (negative values) Related to issue #157. --- DS4Windows/DS4Control/ScpUtil.cs | 13 +++++++++++-- DS4Windows/DS4Forms/DS4Form.cs | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 054573f..b16d409 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2752,9 +2752,18 @@ namespace DS4Windows catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/formHeight"); Int32.TryParse(Item.InnerText, out formHeight); } catch { missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/Profile/formLocationX"); Int32.TryParse(Item.InnerText, out formLocationX); } + try { + int temp = 0; + Item = m_Xdoc.SelectSingleNode("/Profile/formLocationX"); Int32.TryParse(Item.InnerText, out temp); + formLocationX = Math.Max(temp, 0); + } catch { missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/Profile/formLocationY"); Int32.TryParse(Item.InnerText, out formLocationY); } + + try { + int temp = 0; + Item = m_Xdoc.SelectSingleNode("/Profile/formLocationY"); Int32.TryParse(Item.InnerText, out temp); + formLocationY = Math.Max(temp, 0); + } catch { missingSetting = true; } try { diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 0bea96e..1021bef 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -2179,8 +2179,8 @@ namespace DS4Windows FormHeight = oldsize.Height; } - FormLocationX = Location.X; - FormLocationY = Location.Y; + FormLocationX = Location.X > 0 ? Location.X : 0; + FormLocationY = Location.Y > 0 ? Location.Y : 0; if (!string.IsNullOrEmpty(appdatapath)) {