Added EditItem_Enter event to better handle the enable/disable of ribbon button used to insert step types and for copy/paste step

Don’t allow a table to be copied into a non-table step type. Allow copy step from a sub-step to a high level step.
This commit is contained in:
John Jenko 2015-09-17 15:09:42 +00:00
parent 8e39a307f2
commit 07fc46d11d
2 changed files with 55 additions and 26 deletions

View File

@ -49,12 +49,24 @@ namespace Volian.Controls.Library
public EditItem()
{
InitializeComponent();
this.Enter += EditItem_Enter;
}
// This event was added to better control enabling or disabling of the Insert and Copy Step buttons on the ribbon
void EditItem_Enter(object sender, EventArgs e)
{
Console.WriteLine("EditItem Enter {0}", MyItemInfo);
bool allow = (MyStepPanel.VwMode == E_ViewMode.Edit);
StepTabRibbon str = MyStepPanel.MyStepTabPanel.MyStepTabRibbon;
str.SiblingsButtonsEnabled = allow;
str.InsertButtonsEnabled = allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection);
}
public EditItem(IContainer container)
{
container.Add(this);
InitializeComponent();
this.Enter += EditItem_Enter;
}
#endregion
#region Properties

View File

@ -556,16 +556,16 @@ namespace Volian.Controls.Library
// page breaks, copy step, nor creating a pdf
bool allow = (_MyStepRTB.TextLength > 0 && (MyEditItem == null || MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit));
// turn ribbon items on/off base on whether there is text in the edit window
rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled = allow;
// only turn on the Insert Before/After and the CopyStep buttons if on a step part
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
//// turn ribbon items on/off base on whether there is text in the edit window
//rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled = allow;
//// only turn on the Insert Before/After and the CopyStep buttons if on a step part
////btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled =
//// allow && !(MyItemInfo.IsProcedure || MyItemInfo.IsSection || MyItemInfo.IsFigure || MyItemInfo.IsTable || MyItemInfo.IsRNOPart);
rbPdf.Enabled = allow;
// toggle context menus used with the shortcut key
btnCMInsHLS.Enabled = btnCMInsRNO.Enabled = btnCMInsSubStps.Enabled = btnCMInsCaution.Enabled =
btnCMInsNote.Enabled = btnCMInsTable.Enabled = btnCMInsFigure.Enabled = allow;
//// toggle context menus used with the shortcut key
//btnCMInsHLS.Enabled = btnCMInsRNO.Enabled = btnCMInsSubStps.Enabled = btnCMInsCaution.Enabled =
// btnCMInsNote.Enabled = btnCMInsTable.Enabled = btnCMInsFigure.Enabled = allow;
// if in Calvert Alarms Condition/Response, disable insert of Cautions and Notes
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvertAlarm)
btnInsCaut.Enabled = btnInsNote.Enabled = btnCMInsCaution.Enabled = btnCMInsNote.Enabled = allow && !MyItemInfo.IsInCalvertConditionResponse;
@ -607,6 +607,22 @@ namespace Volian.Controls.Library
MyFlexGrid.SelChange -= new EventHandler(MyFlexGrid_SelChange);
}
}
public bool SiblingsButtonsEnabled
{
set
{
// turn ribbon items on/off base on whether there is text in the edit window
rbnSiblings.Enabled = rbnParagraph.Enabled = rbnStepParts.Enabled =value;
}
}
public bool InsertButtonsEnabled
{
set
{
// only turn on the Insert Before/After and the CopyStep buttons if on a step part
btnInsAftH.Enabled = btnInsBefH.Enabled = btnInsAfter.Enabled = btnInsBefore.Enabled = btnCpyStp.Enabled = value;
}
}
void _MyEditItem_Enter(object sender, EventArgs e)
{
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
@ -630,7 +646,7 @@ namespace Volian.Controls.Library
MyFlexGrid.SelChange += new EventHandler(MyFlexGrid_SelChange);
//Console.WriteLine("Turn on SelChange");
}
}
}
void MyFlexGrid_CopyOptionChanged(object sender, EventArgs args)
{
btnTblDgnPaste.Enabled = true;
@ -1117,41 +1133,43 @@ namespace Volian.Controls.Library
}
if (tmp.MyDisplayTabControl.MyCopyStep.IsSection && MyItemInfo.IsSection && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
{
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; // don't replace itself
return;
}
//copy item is high level step
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && !MyItemInfo.IsHigh)
// Allow a High Level step to be pasted to a sub-step, but not to a table, figure, section or procedure type
if (tmp.MyDisplayTabControl.MyCopyStep.IsHigh && (MyItemInfo.IsTable || MyItemInfo.IsFigure || MyItemInfo.IsSection || MyItemInfo.IsProcedure))
{
// 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
//btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
//btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
//btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
// 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;
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)
// 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;
return;
}
if (tmp.MyDisplayTabControl.MyCopyStep.IsStep && MyItemInfo.IsStep && tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID)
// 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)
{
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false;
btnPasteBefore.Enabled = btnCMPasteBefore.Enabled = false;
btnPasteAfter.Enabled = btnCMPasteAfter.Enabled = false;
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;
btnPasteReplace.Enabled = btnCMPasteReplace.Enabled = false; // don't replace itself
return;
}
#endregion
@ -1236,7 +1254,6 @@ namespace Volian.Controls.Library
btnEditMode.Checked = btnCMEditMode1.Checked = MyEditItem.MyStepPanel.VwMode == E_ViewMode.View;
// if on procedure, 'Delete' buttons should be disabled.
btnDelelete.Enabled = btnDelStep.Enabled = !MyItemInfo.IsProcedure;
btnCpyStp.Enabled = !MyItemInfo.IsProcedure;
// Only display the table edit tools if in a grid (table) and that grid (table) is not an RO Table.
GridItem tmpGridItm = MyEditItem as GridItem;
if (btnTblDgnAdjustSize.Checked)