Added code to handle collection was modified error when copying items
Added code to make F5 and Shift-F5 keystrokes in the editor work identical to the right mouse button context menu of the tree view with regards to copy and paste of items Added code to assure only items of similar type (eg: procedure, section, high level step, etc) can be copied and pasted at similar locations within a procedure or working draft
This commit is contained in:
parent
1baf690bc6
commit
f9de5305f2
@ -465,6 +465,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
private bool HandleSqlExceptionOnCopy(Exception ex)
|
||||
{
|
||||
if (ex.Message.Contains("Collection was modified;"))
|
||||
{
|
||||
_MyLog.WarnFormat(ex.Message);
|
||||
return true;
|
||||
}
|
||||
if (ex.Message.Contains("This step has been deleted"))
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show("The step being pasted has been deleted!", "Cannot Paste Deleted Step"
|
||||
|
@ -2033,8 +2033,19 @@ namespace Volian.Controls.Library
|
||||
if (e.Shift)
|
||||
{
|
||||
e.Handled = true;
|
||||
if (!OnCheckClipboard(this, new EventArgs())) return; // check if 'clipboard' contains a step.
|
||||
OnSetMenu(this, new StepRTBMenuEventArgs("StepPaste"));
|
||||
ItemInfo myCopyStep = (this.Parent.Parent.Parent as StepTabPanel).MyDisplayTabControl.MyCopyStep;
|
||||
if (myCopyStep != null)
|
||||
{
|
||||
if (this.MyItemInfo.IsSection && myCopyStep.IsSection)
|
||||
OnSetMenu(this, new StepRTBMenuEventArgs("StepPaste"));
|
||||
if (this.MyItemInfo.IsStep && myCopyStep.IsStep)
|
||||
{
|
||||
if ((this.MyItemInfo.IsHigh && myCopyStep.IsHigh) || (!this.MyItemInfo.IsHigh && !myCopyStep.IsHigh))
|
||||
OnSetMenu(this, new StepRTBMenuEventArgs("StepPaste"));
|
||||
}
|
||||
}
|
||||
//if (!OnCheckClipboard(this, new EventArgs())) return; // check if 'clipboard' contains a step.
|
||||
//OnSetMenu(this, new StepRTBMenuEventArgs("StepPaste"));
|
||||
}
|
||||
else if (!e.Control && !e.Alt)
|
||||
{
|
||||
|
@ -940,44 +940,112 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
|
||||
private void SetPasteButtonEnabled()
|
||||
{
|
||||
// if there is no 'copied' step, or if a procedure is copied, just turn all buttons off, this can only
|
||||
// be done from the tree.
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep == null || tmp.MyDisplayTabControl.MyCopyStep.IsProcedurePart)
|
||||
{
|
||||
btnPasteReplace.Enabled = btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnStepPaste.Enabled = false;
|
||||
return;
|
||||
}
|
||||
// If a section is copied, it can be pasted as a section (before/after/replace). If can also
|
||||
// be pasted as a subsection if the format allows it.
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsSectionPart)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = MyItemInfo.IsSectionPart;
|
||||
// when doing 'substep' part of paste, need to check if format allows subsection.
|
||||
}
|
||||
else if (tmp.MyDisplayTabControl.MyCopyStep.IsCautionPart || tmp.MyDisplayTabControl.MyCopyStep.IsNotePart)
|
||||
// Part type of copied step must be same as Part type of destination, with exceptions of caution/note and step/rno
|
||||
// can be pasted into each other.
|
||||
// Part types are procedure - 1, section = 2, step = 6, caution = 3, note = 4, RNO (IsRNO), = 5 table/figure = 7.
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart);
|
||||
else if (tmp.MyDisplayTabControl.MyCopyStep.IsRNOPart || tmp.MyDisplayTabControl.MyCopyStep.IsStepPart)
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsRNOPart || MyItemInfo.IsStepPart);
|
||||
else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && MyItemInfo.IsTable)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = true;
|
||||
}
|
||||
else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && !MyItemInfo.IsTable)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
// Can't replace step with same step
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) btnPasteReplace.Enabled = false;
|
||||
}
|
||||
{
|
||||
#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;
|
||||
//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;
|
||||
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;
|
||||
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;
|
||||
return;
|
||||
}
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && MyItemInfo.IsSection && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
|
||||
{
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
//copy item is high level step
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && !MyItemInfo.IsHigh)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
|
||||
btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && MyItemInfo.IsHigh && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
|
||||
{
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
//copy item is step that is not high is not a table and is not a figure
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsSubStep && !MyItemInfo.IsSubStep)
|
||||
{
|
||||
btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
|
||||
btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.IsStep && MyItemInfo.IsStep && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
|
||||
{
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
//otherwise everything is ok except for same item prevent replace
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
|
||||
{
|
||||
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
#region original code
|
||||
//// if there is no 'copied' step, or if a procedure is copied, just turn all buttons off, this can only
|
||||
//// be done from the tree.
|
||||
//StepTabPanel tmp = Parent as StepTabPanel;
|
||||
//if (tmp.MyDisplayTabControl.MyCopyStep == null || tmp.MyDisplayTabControl.MyCopyStep.IsProcedurePart)
|
||||
//{
|
||||
// btnPasteReplace.Enabled = btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnStepPaste.Enabled = false;
|
||||
// return;
|
||||
//}
|
||||
//// If a section is copied, it can be pasted as a section (before/after/replace). If can also
|
||||
//// be pasted as a subsection if the format allows it.
|
||||
//if (tmp.MyDisplayTabControl.MyCopyStep.IsSectionPart)
|
||||
//{
|
||||
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = MyItemInfo.IsSectionPart;
|
||||
// // when doing 'substep' part of paste, need to check if format allows subsection.
|
||||
//}
|
||||
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsCautionPart || tmp.MyDisplayTabControl.MyCopyStep.IsNotePart)
|
||||
// // Part type of copied step must be same as Part type of destination, with exceptions of caution/note and step/rno
|
||||
// // can be pasted into each other.
|
||||
// // Part types are procedure - 1, section = 2, step = 6, caution = 3, note = 4, RNO (IsRNO), = 5 table/figure = 7.
|
||||
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsCautionPart || MyItemInfo.IsNotePart);
|
||||
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsRNOPart || tmp.MyDisplayTabControl.MyCopyStep.IsStepPart)
|
||||
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = (MyItemInfo.IsRNOPart || MyItemInfo.IsStepPart);
|
||||
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && MyItemInfo.IsTable)
|
||||
//{
|
||||
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
// btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = true;
|
||||
//}
|
||||
//else if (tmp.MyDisplayTabControl.MyCopyStep.IsTable && !MyItemInfo.IsTable)
|
||||
//{
|
||||
// btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnCMPasteBefore.Enabled = btnCMPasteAfter.Enabled = false;
|
||||
// btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
|
||||
//}
|
||||
//// Can't replace step with same step
|
||||
//if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) btnPasteReplace.Enabled = false;
|
||||
#endregion
|
||||
}
|
||||
private void SetChangeIdRibbon()
|
||||
{
|
||||
if (MyItemInfo == null)
|
||||
@ -1669,7 +1737,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkText lt = new LinkText(_MyStepRTB.MyLinkText);
|
||||
LinkText lt = new LinkText(_MyStepRTB.MyLinkText);
|
||||
myROID = lt.MyRoUsageInfo.ROID.ToLower();
|
||||
myRODB = lt.MyRoUsageInfo.MyRODb;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user