This commit is contained in:
parent
fefc5f3ec2
commit
badc98c07d
@ -19,9 +19,11 @@ namespace Volian.Controls.Library
|
||||
public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
|
||||
public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||
public delegate bool vlnTreeViewItemInfoInsertEvent(object sender, vlnTreeItemInfoInsertEventArgs args);
|
||||
public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args);
|
||||
public delegate DialogResult vlnTreeViewPropertyEvent(object sender, vlnTreePropertyEventArgs args);
|
||||
public delegate void vlnTreeViewSectionInfoEvent(object sender, vlnTreeSectionInfoEventArgs args);
|
||||
public delegate void WordSectionDeletedEvent(object sender, WordSectionEventArgs args);
|
||||
public partial class vlnTreeSectionInfoEventArgs
|
||||
{
|
||||
private SectionInfo _MySectionInfo;
|
||||
@ -89,6 +91,59 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public enum E_InsertType {Before, After, Child};
|
||||
public partial class vlnTreeItemInfoInsertEventArgs
|
||||
{
|
||||
#region Business Methods
|
||||
private ItemInfo _MyItemInfo;
|
||||
public ItemInfo MyItemInfo
|
||||
{
|
||||
get { return _MyItemInfo; }
|
||||
set { _MyItemInfo = value; }
|
||||
}
|
||||
private E_InsertType _InsertType;
|
||||
public E_InsertType InsertType
|
||||
{
|
||||
get { return _InsertType; }
|
||||
set { _InsertType = value; }
|
||||
}
|
||||
private int _Type;
|
||||
public int Type
|
||||
{
|
||||
get { return _Type; }
|
||||
set { _Type = value; }
|
||||
}
|
||||
private E_FromType _FromType;
|
||||
public E_FromType FromType
|
||||
{
|
||||
get { return _FromType; }
|
||||
set { _FromType = value; }
|
||||
}
|
||||
private string _StepText;
|
||||
public string StepText
|
||||
{
|
||||
get { return _StepText; }
|
||||
set { _StepText = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Factory Methods
|
||||
private vlnTreeItemInfoInsertEventArgs() { ;}
|
||||
public vlnTreeItemInfoInsertEventArgs(ItemInfo myItemInfo, E_InsertType insertType, string stepText)
|
||||
{
|
||||
_MyItemInfo = myItemInfo;
|
||||
_InsertType = insertType;
|
||||
_StepText = stepText;
|
||||
}
|
||||
public vlnTreeItemInfoInsertEventArgs(ItemInfo myItemInfo, E_InsertType insertType, string stepText, int type, E_FromType fromType)
|
||||
{
|
||||
_MyItemInfo = myItemInfo;
|
||||
_InsertType = insertType;
|
||||
_StepText = stepText;
|
||||
_Type = type;
|
||||
_FromType = fromType;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public partial class vlnTreePropertyEventArgs : EventArgs
|
||||
{
|
||||
private string _Title;
|
||||
@ -171,6 +226,12 @@ namespace Volian.Controls.Library
|
||||
if (DeleteItemInfo != null) return DeleteItemInfo(sender, args);
|
||||
return false;
|
||||
}
|
||||
public event vlnTreeViewItemInfoInsertEvent InsertItemInfo;
|
||||
private bool OnInsertItemInfo(object sender, vlnTreeItemInfoInsertEventArgs args)
|
||||
{
|
||||
if (InsertItemInfo != null) return InsertItemInfo(sender, args);
|
||||
return false;
|
||||
}
|
||||
public event vlnTreeViewEvent NodeMove;
|
||||
private void OnNodeMove(object sender, vlnTreeEventArgs args)
|
||||
{
|
||||
@ -202,6 +263,11 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (SectionShouldClose != null) SectionShouldClose(sender, args);
|
||||
}
|
||||
public event WordSectionDeletedEvent WordSectionDeleted;
|
||||
internal void OnWordSectionDeleted(object sender, WordSectionEventArgs args)
|
||||
{
|
||||
WordSectionDeleted(sender, args);
|
||||
}
|
||||
public event vlnTreeViewItemInfoEvent OpenItem;
|
||||
private void OnOpenItem(object sender, vlnTreeItemInfoEventArgs args)
|
||||
{
|
||||
@ -314,49 +380,7 @@ namespace Volian.Controls.Library
|
||||
cm.MenuItems.Add("Copy", new EventHandler(mi_Click));
|
||||
}
|
||||
#endregion
|
||||
#region MenuPaste
|
||||
// Find what's in paste buffer & determine whether the paste can occur for the selected node.
|
||||
object tmpClip = Clipboard.GetData("PromsClipboard");
|
||||
if (tmpClip != null)
|
||||
{
|
||||
PromsClipboard tstClip = (PromsClipboard)tmpClip;
|
||||
ItemInfo iiClipboard = ItemInfo.Get(tstClip.itemId);
|
||||
// can it be pasted at current node.
|
||||
if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc
|
||||
{
|
||||
if (iiClipboard.IsProcedure) cm.MenuItems.Add("Paste Procedure", new EventHandler(mi_Click));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo iiPasteHere = tn.VEObject as ItemInfo;
|
||||
if (iiPasteHere != null)
|
||||
{
|
||||
if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after
|
||||
{
|
||||
cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Procedure After", new EventHandler(mi_Click));
|
||||
}
|
||||
else if (iiPasteHere.IsProcedure && iiClipboard.IsSection) // procedure must have sections only
|
||||
cm.MenuItems.Add("Paste Section", new EventHandler(mi_Click));
|
||||
else if (iiPasteHere.IsSection && iiClipboard.IsSection)
|
||||
{
|
||||
cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Section After", new EventHandler(mi_Click));
|
||||
}
|
||||
else if (iiPasteHere.IsStepSection && iiClipboard.IsStep)
|
||||
cm.MenuItems.Add("Paste Step", new EventHandler(mi_Click));
|
||||
else if (iiPasteHere.IsStep && iiClipboard.IsStep)
|
||||
{
|
||||
cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Section Step", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
Menu_Paste(tn, cm);
|
||||
#region Menu_Delete
|
||||
// Add delete to the menu unless at the very 'top' node or on a grouping (partinfo)
|
||||
// node (RNOs, Steps, Cautions, Notes)
|
||||
@ -374,6 +398,60 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
|
||||
private void Menu_Paste(VETreeNode tn, ContextMenu cm)
|
||||
{
|
||||
#region MenuPaste
|
||||
// Find what's in paste buffer & determine whether the paste can occur for the selected node.
|
||||
object tmpClip = Clipboard.GetData("PromsClipboard");
|
||||
if (tmpClip != null)
|
||||
{
|
||||
PromsClipboard tstClip = (PromsClipboard)tmpClip;
|
||||
ItemInfo iiClipboard = ItemInfo.Get(tstClip.itemId);
|
||||
// if the item doesn't exist anymore, don't allow the paste, by not adding
|
||||
// paste menu items to context menu.
|
||||
if (iiClipboard == null)
|
||||
{
|
||||
Clipboard.Clear();
|
||||
return;
|
||||
}
|
||||
// can it be pasted at current node.
|
||||
if (tn.VEObject as DocVersionInfo != null) // paste item must be a proc
|
||||
{
|
||||
if (iiClipboard.IsProcedure) cm.MenuItems.Add("Paste Procedure", new EventHandler(mi_Click));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemInfo iiPasteHere = tn.VEObject as ItemInfo;
|
||||
if (iiPasteHere != null)
|
||||
{
|
||||
if (iiPasteHere.IsProcedure && iiClipboard.IsProcedure) // procedure can be pasted before/replace/after
|
||||
{
|
||||
cm.MenuItems.Add("Paste Procedure Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Procedure", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Procedure After", new EventHandler(mi_Click));
|
||||
}
|
||||
else if (iiPasteHere.IsProcedure && iiClipboard.IsSection) // procedure must have sections only
|
||||
cm.MenuItems.Add("Paste Section", new EventHandler(mi_Click));
|
||||
else if (iiPasteHere.IsSection && iiClipboard.IsSection)
|
||||
{
|
||||
cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Section After", new EventHandler(mi_Click));
|
||||
}
|
||||
else if (iiPasteHere.IsStepSection && iiClipboard.IsStep)
|
||||
cm.MenuItems.Add("Paste Step", new EventHandler(mi_Click));
|
||||
else if (iiPasteHere.IsStep && iiClipboard.IsStep)
|
||||
{
|
||||
cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Paste Section Step", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
void mi_Click(object sender, EventArgs e)
|
||||
{
|
||||
MenuItem mi = (MenuItem)sender;
|
||||
@ -593,6 +671,7 @@ namespace Volian.Controls.Library
|
||||
title = string.Format("{0} Properties", sectInfo.SectionConfig.Title);
|
||||
|
||||
OnNodeOpenProperty(this, new vlnTreePropertyEventArgs(title, sect.SectionConfig));
|
||||
FinishSectionSave(sect);
|
||||
}
|
||||
}
|
||||
private void OpenProperties(StepInfo stpinfo)
|
||||
@ -761,33 +840,62 @@ namespace Volian.Controls.Library
|
||||
#region InsertStep
|
||||
else if (newtype == MenuSelections.Step) // insert step from section - no substeps from tree.
|
||||
{
|
||||
using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20001, E_FromType.Step))
|
||||
{
|
||||
ShowBrokenRules(step.BrokenRulesCollection);
|
||||
SetLastValues(StepInfo.Get(step.ItemID));
|
||||
tn = new VETreeNode(_LastStepInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
}
|
||||
tn = InsertChildStep((VETreeNode)SelectedNode);
|
||||
}
|
||||
else if (newtype == MenuSelections.StepAfter || newtype == MenuSelections.StepBefore && _LastStepInfo != null)
|
||||
{
|
||||
int tvindex = SelectedNode.Index;
|
||||
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
|
||||
ItemInfo parent = (newtype == MenuSelections.StepAfter) ? null : _LastStepInfo.MyParent;
|
||||
using (Step step = Step.MakeStep(parent, (newtype == MenuSelections.StepAfter) ? _LastStepInfo : _LastStepInfo.MyPrevious, null, "New Step", 20001, E_FromType.Step))
|
||||
{
|
||||
ShowBrokenRules(step.BrokenRulesCollection);
|
||||
SetLastValues(StepInfo.Get(step.ItemID));
|
||||
tn = new VETreeNode(_LastStepInfo);
|
||||
TreeNode par = SelectedNode.Parent;
|
||||
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
|
||||
}
|
||||
tn = InsertBeforeOrAfter(newtype, (VETreeNode)SelectedNode);
|
||||
}
|
||||
#endregion
|
||||
|
||||
SelectedNode = tn;
|
||||
OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode));
|
||||
Refresh();
|
||||
if (tn != null)
|
||||
{
|
||||
SelectedNode = tn;
|
||||
OnNodeSelect(this, new vlnTreeEventArgs(SelectedNode));
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private VETreeNode InsertChildStep(VETreeNode tn)
|
||||
{
|
||||
// If parent step is open in editor, use the OnInsertItemInfo to insert step & add stepitems to step editor panel
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii, E_InsertType.Child, "New Step", 20002, E_FromType.Step)))
|
||||
{
|
||||
return null; // should we try to get to the child?
|
||||
}
|
||||
// The parent step was not open in the step editor, just create new step and add treenode.
|
||||
using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step))
|
||||
{
|
||||
ShowBrokenRules(step.BrokenRulesCollection);
|
||||
SetLastValues(StepInfo.Get(step.ItemID));
|
||||
tn = new VETreeNode(_LastStepInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
}
|
||||
return tn;
|
||||
}
|
||||
|
||||
private VETreeNode InsertBeforeOrAfter(MenuSelections newtype, VETreeNode tn)
|
||||
{
|
||||
// If parent step is open in editor, use the OnInsertItemInfo to insert step & add stepitems to step editor panel
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (OnInsertItemInfo(this, new vlnTreeItemInfoInsertEventArgs(ii,(newtype == MenuSelections.StepAfter) ? E_InsertType.After:E_InsertType.Before, "New Step")))
|
||||
{
|
||||
return (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
|
||||
}
|
||||
// The parent step was not open in the step editor, just create new step and add treenode.
|
||||
int tvindex = SelectedNode.Index;
|
||||
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
|
||||
ItemInfo parent = (newtype == MenuSelections.StepAfter) ? null : _LastStepInfo.MyParent;
|
||||
using (Step step = Step.MakeStep(parent, (newtype == MenuSelections.StepAfter) ? _LastStepInfo : _LastStepInfo.MyPrevious, null, "New Step", (int)_LastStepInfo.MyContent.Type, (E_FromType)_LastStepInfo.FirstSibling.ItemParts[0].FromType))
|
||||
{
|
||||
ShowBrokenRules(step.BrokenRulesCollection);
|
||||
SetLastValues(StepInfo.Get(step.ItemID));
|
||||
tn = new VETreeNode(_LastStepInfo);
|
||||
TreeNode par = SelectedNode.Parent;
|
||||
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
|
||||
}
|
||||
return tn;
|
||||
}
|
||||
/// <summary>
|
||||
/// NewName will check the existing children to assure that the name is not a duplicate name.
|
||||
@ -888,7 +996,12 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
OnSectionShouldClose(this, new vlnTreeSectionInfoEventArgs(_LastSectionInfo));
|
||||
// always return false because an event gets fired to delete tree nodes.
|
||||
if (!DeleteItemInfoAndChildren(_LastSectionInfo)) return false;
|
||||
if (!DeleteItemInfoAndChildren(_LastSectionInfo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
WordSectionEventArgs args = new WordSectionEventArgs(_LastSectionInfo);
|
||||
OnWordSectionDeleted(this, args);
|
||||
_LastSectionInfo = null;
|
||||
return false;
|
||||
}
|
||||
@ -906,8 +1019,10 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
// if the procedure is open & you're deleting procedure, you want to close open
|
||||
// window.
|
||||
// send an event to frmVeproms that sends an event to the stepeditor to
|
||||
// do delete using stepitem - this manages windowing from the step editor.
|
||||
// If the procedure is open & you're deleting procedure, you want to close open
|
||||
// window - this is done in DisplayTabControl-DeleteStepTabItem.
|
||||
if (!OnDeleteItemInfo(this, new vlnTreeItemInfoEventArgs(ii)))
|
||||
Item.DeleteItemAndChildren(ii);
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user