private void tvwItems_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode != NewNode.Parent) { if (DestinationNode != null && DestinationNode.Tag != null) { DestinationNode = DestinationNode.Parent; } if (DestinationNode != null) { DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); } else { ((TreeView)sender).Nodes.Add((TreeNode)NewNode.Clone()); } NewNode.Remove(); } } }
// The following TreeView events allow to move the TreeView items around, and for the control // to remember the new order of items. private void TvContent_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; try { if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode == null && tvContent.Bounds.Contains(pt)) { ((TreeView)sender).Nodes.Add((TreeNode)NewNode.Clone()); } else { DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); } //Remove Original Node NewNode.Remove(); ProjectInfo.Dirty = true; } } catch (NullReferenceException) { } }
private void tvNodes_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); int srcModel = ModelBone.GetModelIndexFromKey((int)NewNode.Tag); int srcBone = ModelBone.GetBoneIndexFromKey((int)NewNode.Tag); int dstModel = ModelBone.GetModelIndexFromKey((int)DestinationNode.Tag); int dstBone = ModelBone.GetBoneIndexFromKey((int)DestinationNode.Tag); DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); NewNode.Remove(); if (srcModel == dstModel) { if (SceneManager.Current.Models[srcModel].MoveBone(srcBone, dstBone)) { SceneManager.Current.Change(ChangeType.Move, srcBone, dstBone); } } else { SceneManager.Current.Models[dstModel].ImportBone(SceneManager.Current.Models[srcModel].Bones[srcBone], dstBone); SceneManager.Current.Models[srcModel].RemoveBone(srcBone); ReindexTree(); } } }
private void layersTreeView_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode PreviousNode = layersTreeView.GetNodeAt(pt); int index = -1; if (PreviousNode == null) { index = layersTreeView.Nodes.Count; } else { index = layersTreeView.Nodes.IndexOf(PreviousNode) + 1; } NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); layersTreeView.Nodes.Insert(index, (TreeNode)NewNode.Clone()); NewNode.Remove(); renderActiveLayers(); } }
void tree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { System.Windows.Forms.TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((System.Windows.Forms.TreeView)sender).PointToClient(new Point(e.X, e.Y)); if (sender != tree) { return; } TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); if (DestinationNode != null) { NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); TreeNode parent = DestinationNode; while ((parent = parent.Parent) != null) { if (parent == NewNode) { return; } } if (DestinationNode != NewNode) { NewNode.Remove(); DestinationNode.Nodes.Add(NewNode); NewNode.EnsureVisible(); this.tree.SelectedNode = NewNode; } } } }
//TreeView AthletesTreeView = null; private void treeView_DragDropAthletes(object sender, System.Windows.Forms.DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); if (DestinationNode != null) return; NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); TreeNode parentNode = NewNode.Parent; if (NewNode.Tag is Group) return; //if (DestinationNode.TreeView != NewNode.TreeView) //{ treeView2.Nodes.Add((TreeNode)NewNode.Clone()); //AthletesTreeView.Nodes.Expand(); //Remove Original Node NewNode.Remove(); //Group g = (Group)DestinationNode.Tag; Group g = (Group)parentNode.Tag; Participant p = (Participant)NewNode.Tag; Utils.RemoveUserFromGroup(g.id, p.id, g.level); // } } }
private void treeView_DragDropGroups(object sender, System.Windows.Forms.DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); if (DestinationNode == null) return; if (!(DestinationNode.Tag is Group)) return; NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (NewNode.Tag is Group) return; //if (DestinationNode.TreeView != NewNode.TreeView) //{ DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //Remove Original Node NewNode.Remove(); Group g = (Group)DestinationNode.Tag; Participant p = (Participant)NewNode.Tag; //String ii = (String)SelectSubgroupListBox.SelectedItem; int si = SelectGroupComboBox.SelectedIndex; Group mainGroup = (Group)allGroups[si]; Utils.AddUserToGroup(g.id, mainGroup.id, p.id, g.level); // } } }
private void tvFormel_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent(typeof(TreeNode))) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode != NewNode) { int parentGoodsID = 0; int selfGoodsID = 0; string parentFrockNumber = ""; string selfFrockNumber = ""; S_FrockStandingBook selfFrock = new S_FrockStandingBook(); SeparateString(DestinationNode.Tag.ToString(), out parentGoodsID, out parentFrockNumber); SeparateString(NewNode.Tag.ToString(), out selfGoodsID, out selfFrockNumber); selfFrock.GoodsID = selfGoodsID; selfFrock.FrockNumber = selfFrockNumber; if (parentGoodsID != 0 && parentFrockNumber != "") { selfFrock.ParentGoodsID = parentGoodsID; selfFrock.ParentFrockNumber = parentFrockNumber; } if (!m_serverFrockStandingBook.ChangeParentChildRelationships(selfFrock, out m_strErr)) { MessageDialog.ShowPromptMessage(m_strErr); return; } else { DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //删除已经移动的节点 NewNode.Remove(); RefrshData(); } } } }
private void treeView1_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode.TreeView == NewNode.TreeView) { //DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Parent.Nodes.Insert(DestinationNode.Index + 1, (TreeNode)NewNode.Clone()); DestinationNode.ExpandAll(); //Remove Original Node NewNode.Remove(); } } }
private void EntityView_DragDrop(object sender, DragEventArgs e) { EntityTreeNode NewNode; if (e.Data.GetDataPresent(typeof(EntityTreeNode).FullName, false)) { System.Drawing.Point pt = ((TreeView)sender).PointToClient(new System.Drawing.Point(e.X, e.Y)); EntityTreeNode DestinationNode = (EntityTreeNode)((TreeView)sender).GetNodeAt(pt); NewNode = (EntityTreeNode)e.Data.GetData(typeof(EntityTreeNode).FullName); if (DestinationNode == null) { if (NewNode.Entity.Parent != null) { NewNode.Entity.Parent.RemoveEntity(NewNode.Entity, true); NewNode.Remove(); EntityView.Nodes.Add(NewNode); } } else if (DestinationNode.TreeView == EntityView) { Entity ent = DestinationNode.Entity; do { if (NewNode.Entity == ent) { return; } ent = ent.Parent; } while (ent != null); EntityView.BeginUpdate(); NewNode.Remove(); DestinationNode.Entity.AddEntity(NewNode.Entity); DestinationNode.Nodes.Add(NewNode); DestinationNode.Expand(); EntityView.EndUpdate(); } } }
private void treeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); if (DestinationNode == null) return; NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); //if (DestinationNode.TreeView != NewNode.TreeView) //{ DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //Remove Original Node NewNode.Remove(); // } } }
private void tvWebElements_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode.TreeView == NewNode.TreeView) { if (presenter.IsWebElementNode(NewNode)) { var copiedNode = (TreeNode)NewNode.Clone(); DestinationNode.Parent.Nodes.Insert(DestinationNode.Index, copiedNode); DestinationNode.Expand(); tvWebElements.SelectedNode = copiedNode; //Remove Original Node NewNode.Remove(); } } } }
protected void tvEmployee_DragDrop(object sender, DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent(typeof(TreeNode))) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (DestinationNode.Text == "操作用户") { //新建一个用户名=当前拖动用户,并且EmployeeID=当前拖动用户的操作用户 if (DoOperatorAdding(NewNode)) { DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //删除已经移动的节点 NewNode.Remove(); } } if (DestinationNode.Text == "员工") { //删除当前拖动用户在SysUser表的记录 if (DoOperatorDeleting(NewNode)) { DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //删除已经移动的节点 NewNode.Remove(); } } } }