B2019-101 added logic to prevent the exit dialog from appearing for each child window when the user decides to exit PROMS

This commit is contained in:
John Jenko 2019-08-02 14:48:24 +00:00
parent 5923641a41
commit 09e92ba163

View File

@ -1169,6 +1169,7 @@ namespace VEPROMS
} }
private bool _RemoveFromPROMSWindowForms = true; private bool _RemoveFromPROMSWindowForms = true;
public bool ClosingWithError = false; // B2019-098: prevent looping between error & exit dialog public bool ClosingWithError = false; // B2019-098: prevent looping between error & exit dialog
private bool _WeAreExitingPROMS = false; // B2019-101 if exiting PROMS from main window don't prompt on each child window (separate windows)
private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e) private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e)
{ {
// B2017-212 If the user uses the X button in Word to close the word attachment, PROMS thinks that the user wants to close out of PROMS as well // B2017-212 If the user uses the X button in Word to close the word attachment, PROMS thinks that the user wants to close out of PROMS as well
@ -1176,10 +1177,11 @@ namespace VEPROMS
// B2017-214 added a null reference check // B2017-214 added a null reference check
// B2010-071 Since we cannot tell if the user click on the X in Word or the X in PROMS, ask if the current tab // B2010-071 Since we cannot tell if the user click on the X in Word or the X in PROMS, ask if the current tab
// should be closed or if we should exit PROMS or just Cancel to continue working // should be closed or if we should exit PROMS or just Cancel to continue working
if (!ClosingWithError && tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0) if (!_WeAreExitingPROMS && !ClosingWithError && tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0)
{ {
DlgCloseTabsOrExit dctoe = new DlgCloseTabsOrExit(); // B2019-071 dialog to ask user if we are to close one tab or exit DlgCloseTabsOrExit dctoe = new DlgCloseTabsOrExit(MyParent == null, PROMSWindowForms.Count > 0); // B2019-071 dialog to ask user if we are to close one tab or exit
dctoe.ShowDialog(); dctoe.ShowDialog();
_WeAreExitingPROMS = MyParent == null && dctoe.ExitPROMS; // B2019-101 flag that we are exiting from PROMS main window (separate windows)
if (dctoe.Cancel) // B2019-071 user decided to not close any tab and not exit PROMS - so do nothing and continue working if (dctoe.Cancel) // B2019-071 user decided to not close any tab and not exit PROMS - so do nothing and continue working
{ {
e.Cancel = true; e.Cancel = true;
@ -1213,7 +1215,8 @@ namespace VEPROMS
} }
} }
//C2015-022 Separate Windows - if child windows are open and we are closing the main PROMS window, give user a chance to not close PROMS and that child windows //C2015-022 Separate Windows - if child windows are open and we are closing the main PROMS window, give user a chance to not close PROMS and that child windows
if (MyParent == null && PROMSWindowForms.Count > 0) // B2019-101 if we are exiting from PROMS main window no need to prompt user about child windows.
if (MyParent == null && PROMSWindowForms.Count > 0 && !_WeAreExitingPROMS)
{ {
DialogResult dr = MessageBox.Show("Close all of the child windows and exit PROMS?", "Exit PROMS", MessageBoxButtons.YesNo); DialogResult dr = MessageBox.Show("Close all of the child windows and exit PROMS?", "Exit PROMS", MessageBoxButtons.YesNo);
if (dr == System.Windows.Forms.DialogResult.No) if (dr == System.Windows.Forms.DialogResult.No)
@ -1247,6 +1250,7 @@ namespace VEPROMS
frmVEPROMS child = PROMSWindowForms[k]; frmVEPROMS child = PROMSWindowForms[k];
_RemoveFromPROMSWindowForms = false; _RemoveFromPROMSWindowForms = false;
child._RemoveFromPROMSWindowForms = false; child._RemoveFromPROMSWindowForms = false;
child._WeAreExitingPROMS = _WeAreExitingPROMS;
child.Close(); child.Close();
child.MySessionInfo.EndSession(); child.MySessionInfo.EndSession();
} }