public void CopyNode() { SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; if (CanInto(CNode, CurrentNode)) { if (CNode is ElementNode) { doc.CopyNode(((ElementNode)CNode).Element.Id, ((ElementNode)CurrentNode).Element.Id); } } }
/// <summary> /// 拖拽结束,将要移动节点的预处理。返回值:是否取消拖拽 /// </summary> /// <param name="srcNode"></param> /// <param name="e"></param> /// <returns></returns> void ProcessDragDropedNode(BaseTreeNode srcNode, DragDropNodeEventArgs e) { BaseTreeNode putNode = e.DragDropResult.DropPutNode as BaseTreeNode; SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; SimpleExIndexXmlElement dragEle = ((ElementNode)srcNode).Element; SimpleExIndexXmlElement targetEle = null; if (e.DragDropResult.DropPutNode is DataNode) { targetEle = ((ElementNode)e.DragDropResult.DropPutNode).Element; } ///将要拖放到此节点内 BaseTreeNode parentNode = null; if (e.DragDropResult.DropResultType == DragDropResultType.Into) { parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode; } else { parentNode = (BaseTreeNode)e.DragDropResult.DropPutNode.Parent; } ///收藏夹的处理方式 if (parentNode.NodeType == TreeNodeType.Favorite) { doc.AddFavorite(dragEle); } /// else { ///移动 if ((e.DrgEvent.Effect & DragDropEffects.Move) != 0) { ///处理XmlElement bool result = doc.MoveNode(dragEle, targetEle, e.DragDropResult.DropResultType); if (result) { ///处理树节点 srcNode.Parent.RemoveChildNodeTemp(srcNode); switch (e.DragDropResult.DropResultType) { case DragDropResultType.Before: putNode.Parent.AddChildNodeTemp(putNode.Index, srcNode); break; case DragDropResultType.After: putNode.Parent.AddChildNodeTemp(putNode.Index + 1, srcNode); break; case DragDropResultType.Into: putNode.AddChildNodeTemp(srcNode); break; default: Debug.Assert(false); break; } } } ///拷贝 else if ((e.DrgEvent.Effect & DragDropEffects.Copy) != 0) { doc.CopyNode(dragEle.Id, ((ElementNode)parentNode).Element.Id); } } }