From 003dbd627e56aca5a6161a22bc4095c682f5a3ec Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 6 Dec 2018 05:26:44 -0600 Subject: [PATCH] Make slightly better window size saving routine Related to issue #507 --- DS4Windows/DS4Forms/DS4Form.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 0c830c0..8229016 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -397,6 +397,7 @@ namespace DS4Windows instance = this; this.Resize += Form_Resize; + this.LocationChanged += TrackLocationChanged; Form_Resize(null, null); if (btnStartStop.Enabled && start) TaskRunner.Delay(50).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); @@ -942,9 +943,24 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question FormBorderStyle = FormBorderStyle.Sizable; } + if (WindowState != FormWindowState.Minimized) + { + FormWidth = Width; + FormHeight = Height; + } + chData.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); } + private void TrackLocationChanged(object sender, EventArgs e) + { + if (WindowState != FormWindowState.Minimized) + { + FormLocationX = Location.X; + FormLocationY = Location.Y; + } + } + private void BtnStartStop_Click(object sender, EventArgs e) { BtnStartStop_Clicked(); @@ -2179,19 +2195,6 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question DS4LightBar.shuttingdown = true; } - if (oldsize == new Size(0, 0)) - { - FormWidth = this.Width; - FormHeight = this.Height; - } - else - { - FormWidth = oldsize.Width; - FormHeight = oldsize.Height; - } - - FormLocationX = Location.X > 0 ? Location.X : 0; - FormLocationY = Location.Y > 0 ? Location.Y : 0; Global.ControllerRemoved -= ControllerRemovedChange; if (!string.IsNullOrEmpty(appdatapath))