Make slightly better window size saving routine

Related to issue #507
This commit is contained in:
Travis Nickles 2018-12-06 05:26:44 -06:00
parent 145ddb01ba
commit 003dbd627e

View File

@ -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))