From fd00dc14ea2ba261665c607e88ca2a8d22f88574 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 30 May 2019 13:43:17 +0000 Subject: [PATCH] B2019-071 If X in PROMS or in Word (attachment) is clicked, prompt user if we should close the current tab or close PROMS B2019-071 Dialog that asks user if s/he wants to close the current tab, exit PROMS, or cancel --- .../DlgCloseTabsOrExit.Designer.cs | 138 ++++++++++++++++++ .../DlgCloseTabsOrExit.cs | 57 ++++++++ .../DlgCloseTabsOrExit.resx | 120 +++++++++++++++ PROMS/VEPROMS User Interface/frmVEPROMS.cs | 27 +++- 4 files changed, 338 insertions(+), 4 deletions(-) create mode 100644 PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.Designer.cs create mode 100644 PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.cs create mode 100644 PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.resx diff --git a/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.Designer.cs b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.Designer.cs new file mode 100644 index 00000000..593c4579 --- /dev/null +++ b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.Designer.cs @@ -0,0 +1,138 @@ +namespace VEPROMS +{ + partial class DlgCloseTabsOrExit + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.BtnClsTab = new DevComponents.DotNetBar.ButtonX(); + this.BtnExitPROMS = new DevComponents.DotNetBar.ButtonX(); + this.btnCancel = new DevComponents.DotNetBar.ButtonX(); + this.labelX1 = new DevComponents.DotNetBar.LabelX(); + this.symbolBox1 = new DevComponents.DotNetBar.Controls.SymbolBox(); + this.SuspendLayout(); + // + // BtnClsTab + // + this.BtnClsTab.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.BtnClsTab.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.BtnClsTab.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.BtnClsTab.Location = new System.Drawing.Point(28, 68); + this.BtnClsTab.Name = "BtnClsTab"; + this.BtnClsTab.Size = new System.Drawing.Size(148, 23); + this.BtnClsTab.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.BtnClsTab.TabIndex = 0; + this.BtnClsTab.Text = "Close the Current Tab"; + this.BtnClsTab.Click += new System.EventHandler(this.BtnClsTab_Click); + // + // BtnExitPROMS + // + this.BtnExitPROMS.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.BtnExitPROMS.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.BtnExitPROMS.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.BtnExitPROMS.Location = new System.Drawing.Point(226, 68); + this.BtnExitPROMS.Name = "BtnExitPROMS"; + this.BtnExitPROMS.Size = new System.Drawing.Size(95, 23); + this.BtnExitPROMS.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.BtnExitPROMS.TabIndex = 1; + this.BtnExitPROMS.Text = "Exit PROMS"; + this.BtnExitPROMS.Click += new System.EventHandler(this.BtnExitPROMS_Click); + // + // btnCancel + // + this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnCancel.Location = new System.Drawing.Point(393, 68); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(77, 23); + this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // labelX1 + // + // + // + // + this.labelX1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this.labelX1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelX1.Location = new System.Drawing.Point(68, 12); + this.labelX1.Name = "labelX1"; + this.labelX1.Size = new System.Drawing.Size(401, 20); + this.labelX1.Style = DevComponents.DotNetBar.eDotNetBarStyle.OfficeXP; + this.labelX1.TabIndex = 3; + this.labelX1.Text = "Do you want to Close the Current Tab or Exit PROMS?"; + // + // symbolBox1 + // + // + // + // + this.symbolBox1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; + this.symbolBox1.Location = new System.Drawing.Point(3, 0); + this.symbolBox1.Name = "symbolBox1"; + this.symbolBox1.Size = new System.Drawing.Size(59, 43); + this.symbolBox1.Symbol = "59645"; + this.symbolBox1.SymbolColor = System.Drawing.Color.Navy; + this.symbolBox1.SymbolSet = DevComponents.DotNetBar.eSymbolSet.Material; + this.symbolBox1.SymbolSize = 24F; + this.symbolBox1.TabIndex = 4; + this.symbolBox1.Text = "symbolBox1"; + // + // DlgCloseTabsOrExit + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(486, 113); + this.Controls.Add(this.symbolBox1); + this.Controls.Add(this.labelX1); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.BtnExitPROMS); + this.Controls.Add(this.BtnClsTab); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "DlgCloseTabsOrExit"; + this.ShowIcon = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "PROMS"; + this.TopMost = true; + this.ResumeLayout(false); + + } + + #endregion + + private DevComponents.DotNetBar.ButtonX BtnClsTab; + private DevComponents.DotNetBar.ButtonX BtnExitPROMS; + private DevComponents.DotNetBar.ButtonX btnCancel; + private DevComponents.DotNetBar.LabelX labelX1; + private DevComponents.DotNetBar.Controls.SymbolBox symbolBox1; + } +} \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.cs b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.cs new file mode 100644 index 00000000..da71609e --- /dev/null +++ b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace VEPROMS +{ + // B2019-071 Dialog will ask user if he wants to close the current tab, exit PROMS, or cancel + // This is displayed when user click on the PROMS X (upper right corner), V button Exit, or the Word X button inside a Word attachment + public partial class DlgCloseTabsOrExit : DevComponents.DotNetBar.Office2007Form + { + private bool _Cancel = true; + + public bool Cancel + { + get { return _Cancel; } + } + + private bool _ExitPROMS; + + public bool ExitPROMS + { + get { return _ExitPROMS; } + set { _ExitPROMS = value; } + } + public DlgCloseTabsOrExit() + { + InitializeComponent(); + } + + private void BtnClsTab_Click(object sender, EventArgs e) + { + _Cancel = false; + _ExitPROMS = false; + this.Hide(); + } + + private void BtnExitPROMS_Click(object sender, EventArgs e) + { + _Cancel = false; + _ExitPROMS = true; + this.Hide(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + _Cancel = true; + _ExitPROMS = false; + this.Hide(); + } + } +} diff --git a/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.resx b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/PROMS/VEPROMS User Interface/DlgCloseTabsOrExit.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 24ac80b7..4a50a970 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -1165,23 +1165,42 @@ namespace VEPROMS // 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 // trap for this and close only the Word tab in PROMS // B2017-214 added a null reference check - if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyDSOTabPanel != null && tc._MyDisplayTabItems.Count > 0) + // 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 (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 + dctoe.ShowDialog(); + 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; + dctoe.Close(); + return; + } string stk = Volian.Base.Library.vlnStackTrace.StackToString(); - if (!stk.Contains("MouseUp") && !stk.Contains("ButtonDown") && !stk.Contains("Exception")) + if (!stk.Contains("Exception")) { // B2018-091 Allow PROMS to close if only MSWord sections have been opened. + // B2019-071 we will now close one or all of the tabs (even step editor ones) int n = tc._MyDisplayTabItems.Count; while (n-- > 0 && tc._MyDisplayTabItems.Count > 0) { tc.CloseTabItem(tc.SelectedDisplayTabItem); + if (!dctoe.ExitPROMS) // B2019-071 close just the current tab and continue working + { + n = 0; + e.Cancel = true; + dctoe.Close(); + return; + } } - if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyDSOTabPanel != null && tc._MyDisplayTabItems.Count > 0) + if (tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0 && dctoe.ExitPROMS) { - _MyLog.WarnFormat(string.Format("Stack Does not contain a MouseUp, a ButtonDown, an Exception\r\n" + + _MyLog.WarnFormat(string.Format("Stack Does not contain an Exception\r\n" + "PROMS will Not Exit. Stack : \r\n{0}", stk)); e.Cancel = true; // If Display Items still exist don't close. } + dctoe.Close(); } } //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