This commit is contained in:
@@ -277,6 +277,7 @@ namespace Volian.Controls.Library
|
||||
btnCMRedo.Enabled = btnRedo.Enabled = setting;
|
||||
btnCMPaste.Enabled = btnPaste.Enabled = setting;
|
||||
btnCMCopy.Enabled = btnCopy.Enabled = setting;
|
||||
btnPasteAfter.Enabled = btnPasteBefore.Enabled = btnStepPaste.Enabled = btnPasteReplace.Enabled = setting;
|
||||
}
|
||||
private void SetButtonMenuEnabledDisabledOnStepType(bool setting)
|
||||
{
|
||||
@@ -328,6 +329,9 @@ namespace Volian.Controls.Library
|
||||
// all selected copy while in either Edit or View mode
|
||||
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0;
|
||||
|
||||
// paste step only available if a step was copied. Also, check for valid types:
|
||||
SetPasteButtonEnabled();
|
||||
|
||||
// do all Transition and ReferencedObject menu items/buttons based on whether a 'link is selected' and the link type.
|
||||
btnCMGoTo.Enabled = btnGoTo.Enabled = _MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength); //(_MyStepRTB.MyLinkText != null);
|
||||
if (btnCMGoTo.Enabled == true && _MyStepRTB.MyLinkText != null) // must have some link test, use it to set edit of transition or ro...
|
||||
@@ -342,6 +346,37 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
// OLD: SetStepButtonAndMenuEnabling(docontextmenus);
|
||||
}
|
||||
|
||||
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
|
||||
btnPasteBefore.Enabled = btnPasteAfter.Enabled = btnPasteReplace.Enabled = tmp.MyDisplayTabControl.MyCopyStep.IsTablePart == MyItemInfo.IsTablePart;
|
||||
|
||||
// Can't replace step with same step
|
||||
if (tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyItemInfo.ItemID) btnPasteReplace.Enabled = false;
|
||||
}
|
||||
private void SetStepButtonAndMenuEnabling(bool docontextmenus)
|
||||
{
|
||||
if (MyStepItem == null) return;
|
||||
@@ -365,6 +400,7 @@ namespace Volian.Controls.Library
|
||||
btnEditMode.Checked = btnCMEditMode1.Checked = MyStepItem.MyStepPanel.PanelViewEditMode != E_ViewMode.View;
|
||||
// if on procedure, 'Delete' buttons should be disabled.
|
||||
btnDelelete.Enabled = btnDelStep.Enabled = ! MyItemInfo.IsProcedure;
|
||||
btnCpyStp.Enabled = !MyItemInfo.IsProcedure;
|
||||
// if on procedure or section, 'change type' & 'insert' buttons should be disabled.
|
||||
if (MyItemInfo.IsProcedure || MyItemInfo.IsSection)
|
||||
{
|
||||
@@ -569,6 +605,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
Clipboard.Clear();
|
||||
DataObject myDO = new DataObject("Rich Text Format", _MyStepRTB.SelectedRtf);
|
||||
myDO.SetText(_MyStepRTB.SelectedText);
|
||||
Clipboard.SetDataObject(myDO);
|
||||
_MyStepRTB.SelectedText = "";
|
||||
}
|
||||
@@ -576,6 +613,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
Clipboard.Clear();
|
||||
DataObject myDO = new DataObject("Rich Text Format", _MyStepRTB.SelectedRtf);
|
||||
myDO.SetText(_MyStepRTB.SelectedText);
|
||||
Clipboard.SetDataObject(myDO);
|
||||
}
|
||||
private void btnBold_Click(object sender, EventArgs e)
|
||||
@@ -878,8 +916,11 @@ namespace Volian.Controls.Library
|
||||
bool displayMenu = false;
|
||||
E_AccStep? actable = 0;
|
||||
StepData sd = MyItemInfo.FormatStepData;
|
||||
actable = sd.StepEditData.AcTable;
|
||||
if (actable == null) actable = 0;
|
||||
if (sd != null) // will be null if section
|
||||
{
|
||||
actable = sd.StepEditData.AcTable;
|
||||
if (actable == null) actable = 0;
|
||||
}
|
||||
//btnInsCaut.Enabled = (actable & E_AccStep.AddingCaution) > 0;
|
||||
switch (menuName)
|
||||
{
|
||||
@@ -911,6 +952,10 @@ namespace Volian.Controls.Library
|
||||
displayMenu = (actable & E_AccStep.AddingTable) > 0;
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMInsFigure);
|
||||
break;
|
||||
case "StepPaste":
|
||||
displayMenu = true;
|
||||
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMStepPaste);
|
||||
break;
|
||||
}
|
||||
if (displayMenu)
|
||||
{
|
||||
@@ -960,8 +1005,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
deletedEmpty = true;
|
||||
deletedHLS = MyItemInfo.IsHigh;
|
||||
deletedSubStep = MyItemInfo.IsSubStep;
|
||||
deletedRNO = MyItemInfo.IsRNO;
|
||||
deletedSubStep = MyItemInfo.IsStepPart;
|
||||
deletedRNO = MyItemInfo.IsRNOPart;
|
||||
deletedNote = MyItemInfo.IsNote;
|
||||
deletedCaution = MyItemInfo.IsCaution;
|
||||
|
||||
@@ -990,7 +1035,7 @@ namespace Volian.Controls.Library
|
||||
CreateNewRNO();
|
||||
}
|
||||
}
|
||||
else if (MyItemInfo.IsRNO)
|
||||
else if (MyItemInfo.IsRNOPart)
|
||||
{
|
||||
MyStepRTB.StepRTB_ArrowPressed(E_ArrowKeys.CtrlLeft);
|
||||
if (MyItemInfo.IsHigh)
|
||||
@@ -1006,7 +1051,7 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
InsertSiblingBeforeOrAfter("after");
|
||||
}
|
||||
else if (MyItemInfo.IsInRNO && MyItemInfo.IsSubStep)
|
||||
else if (MyItemInfo.IsInRNO && MyItemInfo.IsStepPart)
|
||||
{
|
||||
if (deletedEmpty)
|
||||
{
|
||||
@@ -1016,7 +1061,7 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
InsertSiblingBeforeOrAfter("after");
|
||||
}
|
||||
else if (MyItemInfo.IsSubStep)
|
||||
else if (MyItemInfo.IsStepPart)
|
||||
{
|
||||
if (deletedSubStep)
|
||||
{
|
||||
@@ -1073,6 +1118,48 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
btnInsNote.RaiseClick();
|
||||
}
|
||||
private void btnPasteAfter_Click(object sender, EventArgs e)
|
||||
{
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
MyStepItem.PasteSiblingAfter(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
||||
}
|
||||
private void btnPasteBefore_Click(object sender, EventArgs e)
|
||||
{
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
MyStepItem.PasteSiblingBefore(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
||||
}
|
||||
private void btnStepPaste_Click(object sender, EventArgs e)
|
||||
{
|
||||
// just return
|
||||
}
|
||||
|
||||
private void btnCpyStp_Click(object sender, EventArgs e)
|
||||
{
|
||||
DoCopyStep();
|
||||
}
|
||||
|
||||
public void DoCopyStep()
|
||||
{
|
||||
// highlight selected step(s) and prompt to see if selection is what user wants:
|
||||
MyStepItem.HighlightBackColor();
|
||||
DialogResult dr = MessageBox.Show("Step as Marked?", "Identify Step To Be Copied", MessageBoxButtons.YesNo);
|
||||
if (dr == DialogResult.Yes)
|
||||
{
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
tmp.MyDisplayTabControl.MyCopyStep = MyItemInfo;
|
||||
btnStepPaste.Enabled = true;
|
||||
SetPasteButtonEnabled();
|
||||
}
|
||||
MyStepItem.SetBackColor();
|
||||
}
|
||||
|
||||
private void btnPasteReplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
StepTabPanel tmp = Parent as StepTabPanel;
|
||||
StepItem oldStepItem = MyStepItem;
|
||||
MyStepItem = MyStepItem.PasteReplace(tmp.MyDisplayTabControl.MyCopyStep.ItemID);
|
||||
if (MyStepItem.MyItemInfo.ItemID != oldStepItem.MyItemInfo.ItemID) oldStepItem.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
public enum E_FieldToEdit { StepText, Text, Number };
|
||||
|
Reference in New Issue
Block a user