Added new events NodeCopy and ClipboardStatus, changed paste operations to use MyCopyStep property of tab control instead of clipboard and changed method to determine when paste replace menu item is available
This commit is contained in:
parent
a17c27c0a8
commit
37a481db24
@ -18,6 +18,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
#region DelegatesAndEventArgs
|
||||
public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args);
|
||||
public delegate ItemInfo vlnTreeViewClipboardStatusEvent(object sender, vlnTreeEventArgs args);
|
||||
public delegate void vlnTreeViewItemInfoEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||
public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args);
|
||||
public delegate bool vlnTreeViewItemInfoDeleteEvent(object sender, vlnTreeItemInfoEventArgs args);
|
||||
@ -363,6 +364,13 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (NodeMove != null) NodeMove(sender, args);
|
||||
}
|
||||
public event vlnTreeViewClipboardStatusEvent ClipboardStatus;
|
||||
private ItemInfo OnClipboardStatus(object sender, vlnTreeEventArgs args)
|
||||
{
|
||||
ItemInfo rv = null;
|
||||
if (ClipboardStatus != null) rv = ClipboardStatus(sender, args);
|
||||
return rv;
|
||||
}
|
||||
public event vlnTreeViewEvent NodeCopy;
|
||||
private void OnNodeCopy(object sender, vlnTreeEventArgs args)
|
||||
{
|
||||
@ -1048,18 +1056,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
#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)
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this,new vlnTreeEventArgs(tn));
|
||||
if(iiClipboard != 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
|
||||
{
|
||||
@ -1068,12 +1067,13 @@ namespace Volian.Controls.Library
|
||||
else
|
||||
{
|
||||
ItemInfo iiPasteHere = tn.VEObject as ItemInfo;
|
||||
bool okToReplace = iiClipboard.ItemID != iiPasteHere.ItemID;
|
||||
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));
|
||||
if (okToReplace) 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
|
||||
@ -1081,7 +1081,7 @@ namespace Volian.Controls.Library
|
||||
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));
|
||||
if (okToReplace) 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)
|
||||
@ -1089,7 +1089,7 @@ namespace Volian.Controls.Library
|
||||
else if (iiPasteHere.IsStep && iiClipboard.IsStep)
|
||||
{
|
||||
if (AddToInsertMenu(iiPasteHere, 0)) cm.MenuItems.Add("Paste Step Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
if (okToReplace) cm.MenuItems.Add("Replace Existing Step", new EventHandler(mi_Click));
|
||||
if (AddToInsertMenu(iiPasteHere, 1)) cm.MenuItems.Add("Paste Step After", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
@ -1439,11 +1439,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void tv_NodePaste(string p)
|
||||
{
|
||||
object oClip = Clipboard.GetData("PromsClipboard");
|
||||
if (oClip == null) return;
|
||||
|
||||
PromsClipboard iClip = (PromsClipboard) oClip;
|
||||
ItemInfo iiClipboard = ItemInfo.Get(iClip.itemId);
|
||||
ItemInfo iiClipboard = OnClipboardStatus(this, null);
|
||||
if (iiClipboard == null) return;
|
||||
string message = string.Empty;
|
||||
if (iiClipboard.MyContent.MyEntry == null)
|
||||
{
|
||||
@ -1512,20 +1509,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (SelectedNode==null)return;
|
||||
VETreeNode tn = SelectedNode as VETreeNode;
|
||||
ItemInfo ii = tn.VEObject as ItemInfo;
|
||||
if (ii != null)
|
||||
{
|
||||
Clipboard.Clear();
|
||||
PromsClipboard iClip;
|
||||
iClip.itemId = ii.ItemID;
|
||||
iClip.cType = (int)PromsClipboardType.Copy;
|
||||
DataObject myDO = new DataObject();
|
||||
myDO.SetText(ii.DisplayNumber==null||ii.DisplayNumber==""?" ":ii.DisplayNumber);
|
||||
myDO.SetData("PromsClipboard", iClip);
|
||||
Clipboard.SetDataObject(myDO);
|
||||
//Clipboard.SetData("PromsClipboard", iClip);
|
||||
//Clipboard.SetData(DataFormats.Text, ii.DisplayNumber);
|
||||
}
|
||||
OnNodeCopy(this, new vlnTreeEventArgs(tn));
|
||||
}
|
||||
#endregion
|
||||
#region PropertyPagesInterface
|
||||
|
Loading…
x
Reference in New Issue
Block a user