This commit is contained in:
2010-03-25 11:28:09 +00:00
parent 06f23219cd
commit 56d5c40f8a
9 changed files with 402 additions and 58 deletions

View File

@@ -20,6 +20,7 @@ namespace Volian.Controls.Library
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 bool vlnTreeViewItemInfoPasteEvent(object sender, vlnTreeItemInfoPasteEventArgs 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);
@@ -144,6 +145,48 @@ namespace Volian.Controls.Library
}
#endregion
}
#region PasteEventArgs
public partial class vlnTreeItemInfoPasteEventArgs
{
#region Business Methods
private ItemInfo _MyItemInfo;
public ItemInfo MyItemInfo
{
get { return _MyItemInfo; }
set { _MyItemInfo = value; }
}
private int _CopyStartID;
public int CopyStartID
{
get { return _CopyStartID; }
set { _CopyStartID = value; }
}
private ItemInfo.EAddpingPart _PasteType;
public ItemInfo.EAddpingPart PasteType
{
get { return _PasteType; }
set { _PasteType = value; }
}
private int? _Type;
public int? Type
{
get { return _Type; }
set { _Type = value; }
}
#endregion
#region Factory Methods
private vlnTreeItemInfoPasteEventArgs() { ;}
public vlnTreeItemInfoPasteEventArgs(ItemInfo myItemInfo, int copyStartId, ItemInfo.EAddpingPart pasteType, int? type)
{
_MyItemInfo = myItemInfo;
_CopyStartID = copyStartId;
_PasteType = pasteType;
_Type = type;
}
#endregion
}
#endregion
public partial class vlnTreePropertyEventArgs : EventArgs
{
private string _Title;
@@ -232,6 +275,12 @@ namespace Volian.Controls.Library
if (InsertItemInfo != null) return InsertItemInfo(sender, args);
return false;
}
public event vlnTreeViewItemInfoPasteEvent PasteItemInfo;
private bool OnPasteItemInfo(object sender, vlnTreeItemInfoPasteEventArgs args)
{
if (PasteItemInfo != null) return PasteItemInfo(sender, args);
return false;
}
public event vlnTreeViewEvent NodeMove;
private void OnNodeMove(object sender, vlnTreeEventArgs args)
{
@@ -300,7 +349,7 @@ namespace Volian.Controls.Library
// that allow more than one type of operation associated with their selection.
public enum MenuSelections : int
{
Folder = 1, FolderBefore = 2, FolderAfter = 3, DocVersion = 4, Procedure = 5, ProcedureBefore = 6, ProcedureAfter = 7, Section = 8, SectionBefore = 9, SectionAfter = 10, Step = 11, StepBefore = 12, StepAfter = 13
Folder = 1, FolderBefore = 2, FolderAfter = 3, DocVersion = 4, Procedure = 5, ProcedureBefore = 6, ProcedureAfter = 7, Section = 8, SectionBefore = 9, SectionAfter = 10, Step = 11, StepBefore = 12, StepAfter = 13, StepReplace = 14
}
void tv_MouseDown(object sender, MouseEventArgs e)
{
@@ -373,11 +422,9 @@ namespace Volian.Controls.Library
cm.MenuItems.Add("Open", new EventHandler(mi_Click));
#endregion
#region Menu_CutCopy
// For initial release, no cut operations will be coded.
// For initial release, copy is not available for folders or docversions
if (tn.VEObject as ItemInfo != null)
{
//cm.MenuItems.Add("Cut", new EventHandler(mi_Click));
cm.MenuItems.Add("Copy", new EventHandler(mi_Click));
}
#endregion
@@ -445,7 +492,7 @@ namespace Volian.Controls.Library
{
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));
cm.MenuItems.Add("Paste Step After", new EventHandler(mi_Click));
}
}
}
@@ -564,47 +611,50 @@ namespace Volian.Controls.Library
DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
if (dvi != null)
{
// TODO: KBR Adjust database.
VETreeNode tnnew = new VETreeNode(iiClipboard);
SelectedNode.Nodes.Add(tnnew);
return;
}
ItemInfo iiPaste = tn.VEObject as ItemInfo;
if (iiPaste == null) return;
if (p.IndexOf("Before") > -1)
{
// TODO: KBR Adjust database.
VETreeNode tnnew = new VETreeNode(iiClipboard);
int indx = SelectedNode.Index;
SelectedNode.Parent.Nodes.Insert(indx, tnnew);
return;
}
if (p.IndexOf("After") > -1)
{
// TODO: KBR Adjust database.
VETreeNode tnnew = new VETreeNode(iiClipboard);
int indx = SelectedNode.Index;
SelectedNode.Parent.Nodes.Insert(indx+1, tnnew);
return;
}
if (p.IndexOf("Replace") > -1)
{
// TODO: KBR Adjust database.
VETreeNode tnnew = new VETreeNode(iiClipboard);
int indx = SelectedNode.Index;
TreeNode tmptn = SelectedNode;
SelectedNode = SelectedNode.Parent.Nodes[indx];
SelectedNode.Remove();
SelectedNode.Parent.Nodes.Insert(indx, tnnew);
return;
}
// if it got to here, just add as a child.
// TODO: KBR Adjust database.
VETreeNode tnnewc = new VETreeNode(iiClipboard);
SelectedNode.Nodes.Add(tnnewc);
PasteBeforeOrAfter(MenuSelections.StepBefore, tn, iiClipboard.ItemID);
else if (p.IndexOf("After") > -1)
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
else if (p.IndexOf("Replace") > -1)
PasteReplace(tn, iiClipboard.ItemID);
}
private void PasteBeforeOrAfter(MenuSelections newtype, VETreeNode tn, int copyStartID)
{
// If paste-from step is open in the editor, use the OnPasteItemInfo to paste the step and add stepitems
// to the step editor panel.
ItemInfo ii = tn.VEObject as ItemInfo;
ItemInfo.EAddpingPart pasteOpt = newtype == MenuSelections.StepBefore ? ItemInfo.EAddpingPart.Before : ItemInfo.EAddpingPart.After;
// If parent step is open in step editor, the 'OnPasteItemInfo' event will cause
// the item to be pasted in the step editor and the tree.
if (OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, pasteOpt, ii.MyContent.Type))==null)
{
//return;
// The parent step was not open in the step editor, just paste step (in data) and add treenode.
ItemInfo newItemInfo = null;
if (newtype == MenuSelections.StepBefore)
newItemInfo = ii.PasteSiblingBefore(copyStartID);
else
newItemInfo = ii.PasteSiblingAfter(copyStartID);
}
SelectedNode = (VETreeNode)((newtype == MenuSelections.StepAfter) ? tn.NextNode : tn.PrevNode);
}
private void PasteReplace(VETreeNode tn, int copyStartID)
{
VETreeNode prevtn = (VETreeNode) tn.PrevNode;
VETreeNode partn = (VETreeNode) tn.Parent;
ItemInfo ii = tn.VEObject as ItemInfo;
if (OnPasteItemInfo(this, new vlnTreeItemInfoPasteEventArgs(ii, copyStartID, ItemInfo.EAddpingPart.Replace, ii.MyContent.Type))==null)
{
//return;
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID);
}
SelectedNode = (VETreeNode)((prevtn != null) ? prevtn.NextNode : partn.FirstNode);
}
private void tv_NodeCopy()
{
if (SelectedNode==null)return;
@@ -616,7 +666,12 @@ namespace Volian.Controls.Library
PromsClipboard iClip;
iClip.itemId = ii.ItemID;
iClip.cType = (int)PromsClipboardType.Copy;
Clipboard.SetData("PromsClipboard", iClip);
DataObject myDO = new DataObject();
myDO.SetText(ii.DisplayNumber);
myDO.SetData("PromsClipboard", iClip);
Clipboard.SetDataObject(myDO);
//Clipboard.SetData("PromsClipboard", iClip);
//Clipboard.SetData(DataFormats.Text, ii.DisplayNumber);
}
}
#endregion