From 7ce40b53a72b6784bf5b754668ae9f0aac0cefbd Mon Sep 17 00:00:00 2001 From: John Date: Tue, 19 Apr 2016 18:56:55 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20paste=20bug=20(B2016-005)=20remove=20pa?= =?UTF-8?q?ste=20options=20from=20tree=20context=20menus=20when=20copied?= =?UTF-8?q?=20step=20is=20deleted.=20Made=20a=20public=20method=20to=20ena?= =?UTF-8?q?ble/disable=20the=20ribbon=E2=80=99s=20paste=20buttons=20so=20i?= =?UTF-8?q?t=20can=20be=20called=20when=20a=20step=20is=20deleted=20from?= =?UTF-8?q?=20the=20tree=20view.=20(B2016-005)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 16 ++++++-- .../Volian.Controls.Library/StepTabRibbon.cs | 40 ++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 14b91dc4..3ea930e5 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -1015,10 +1015,18 @@ namespace VEPROMS { if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.MyProcedure.ItemID == args.MyItemInfo.ItemID) displayHistory.MyEditItem = null; - return tc.DeleteRTBItem(args.MyItemInfo); - //if (si == null) return false; - //si.RemoveItem(); - //return true; + // bug fix B2016-005 - set MyCopyStep to null. This will take the paste options off of the tree node context menus. jsj 4-19-2016 + if (args.MyItemInfo.ItemID == tc.MyCopyStep.ItemID) + tc.MyCopyStep = null; + bool rtval = tc.DeleteRTBItem(args.MyItemInfo); + // Also disable the paste options on the ribbon if it is open. jsj 4-19-2016 + if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyStepTabPanel != null) // MyStepTabPanel will be null if the active tab is a Word Attachment + { + StepPanel pnl = tc.SelectedDisplayTabItem.MyStepTabPanel.MyStepPanel; + if (pnl != null) + pnl.MyStepTabPanel.MyStepTabRibbon.SetPasteButtons(false); + } + return rtval; } private bool tv_PasteItemInfo(object sender, vlnTreeItemInfoPasteEventArgs args) { diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 4486eba4..2b89fb9d 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -1157,36 +1157,36 @@ namespace Volian.Controls.Library btnCASCreate.Enabled = (MyEditItem != null) ? (MyEditItem.MyStepPanel.ApplDisplayMode > 0) : false; } + // Made a public method so that it can be called when a step is deleted from the tree view. + // part of bug fix for B2016-005 - jsj 4-19-2016 + public void SetPasteButtons(bool enable) + { + btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = enable; + btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = enable; + btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = enable; + } private void SetPasteButtonEnabled() { #region new code StepTabPanel tmp = Parent as StepTabPanel; //turn all on - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = true; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = true; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = true; + SetPasteButtons(true); //copy item is null, turn all off and return if (tmp.MyDisplayTabControl.MyCopyStep == null) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } //copy item is procedure, turn all off and return must be done from tree if(tmp.MyDisplayTabControl.MyCopyStep.IsProcedure) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } //copy item is section if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && !MyItemInfo.IsSection) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && MyItemInfo.IsSection && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) @@ -1212,9 +1212,7 @@ namespace Volian.Controls.Library } if ((!MyItemInfo.IsEnhancedSection && !MyItemInfo.IsEnhancedStep && !toSourceHasEnhancedLinks) && fromSourceHasEnhancedLinks) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } // enhanced: if 'from' step is not enhanced, only allow paste before/after @@ -1243,27 +1241,21 @@ namespace Volian.Controls.Library // commenting these lines out allows us to use Copy Step to copy a High Level Step // to a sub-step level. - 05/18/2015 jsj // changed above if so the the high level step cannot be paste to a Table, Figure, Section (on the editor panel), Procedure (on the editor panel) - jsj 09/17/2015 - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } // don't allow a paste of a substep into a table, figure, sectino,or procedure type // this also allows a substep (text) to be copyed to a high level step type C2015-011 if (tmp.MyDisplayTabControl.MyCopyStep.IsSubStep && (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsSection || MyItemInfo.IsProcedure)) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } // copy item is a table of figure - don't allow pasting at High Level Step, Caution or Note level, as well as not at a section or procedure level) // Bug fix B2015-152 if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && !MyItemInfo.IsTable || tmp.MyDisplayTabControl.MyCopyStep.IsFigure && !MyItemInfo.IsFigure) { - btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false; - btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false; - btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; + SetPasteButtons(false); return; } //otherwise everything is ok except for same item prevent replace