Only pop up confirm window when user explicitly closes application. Related to issue #82.

This commit is contained in:
Travis Nickles 2017-07-03 17:33:45 -05:00
parent 9bf937d7b9
commit 25be090c89

View File

@ -2168,10 +2168,11 @@ namespace DS4Windows
} }
bool closeMini = tempBool = cBCloseMini.Checked; bool closeMini = tempBool = cBCloseMini.Checked;
bool userClosing = e.CloseReason == CloseReason.UserClosing;
DS4Device d = null; DS4Device d = null;
tempBool = true; bool nocontrollers = tempBool = true;
//in case user accidentally clicks on the close button whilst "Close Minimizes" checkbox is unchecked //in case user accidentally clicks on the close button whilst "Close Minimizes" checkbox is unchecked
if (!closeMini && !contextclose) if (userClosing && !closeMini && !contextclose)
{ {
for (int i = 0, PadsLen = Pads.Length; tempBool && i < PadsLen; i++) for (int i = 0, PadsLen = Pads.Length; tempBool && i < PadsLen; i++)
{ {
@ -2179,7 +2180,7 @@ namespace DS4Windows
tempBool = (d != null) ? false : tempBool; tempBool = (d != null) ? false : tempBool;
} }
bool nocontrollers = tempBool; nocontrollers = tempBool;
if (!nocontrollers) if (!nocontrollers)
{ {
if (MessageBox.Show(Properties.Resources.CloseConfirm, Properties.Resources.Confirm, if (MessageBox.Show(Properties.Resources.CloseConfirm, Properties.Resources.Confirm,
@ -2190,7 +2191,7 @@ namespace DS4Windows
} }
} }
} }
else if (closeMini && !contextclose) else if (userClosing && closeMini && !contextclose)
{ {
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Minimized;
e.Cancel = true; e.Cancel = true;