From 09e92ba163997724a16d0f52a24739aa3f9a9e38 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 2 Aug 2019 14:48:24 +0000 Subject: [PATCH] B2019-101 added logic to prevent the exit dialog from appearing for each child window when the user decides to exit PROMS --- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 30862a48..961fe6e2 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -1169,6 +1169,7 @@ namespace VEPROMS } private bool _RemoveFromPROMSWindowForms = true; 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) { // 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 // 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 - 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(); + _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 { 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 - 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); if (dr == System.Windows.Forms.DialogResult.No) @@ -1247,6 +1250,7 @@ namespace VEPROMS frmVEPROMS child = PROMSWindowForms[k]; _RemoveFromPROMSWindowForms = false; child._RemoveFromPROMSWindowForms = false; + child._WeAreExitingPROMS = _WeAreExitingPROMS; child.Close(); child.MySessionInfo.EndSession(); }