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 tvNodes_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (SceneManager.Current.Models.Count > 0) { if (e.Node.Parent == null) { SceneManager.Current.SetSelectedBone(-1, -1); } else if (e.Node.Tag != null) { int mI = ModelBone.GetModelIndexFromKey((int)e.Node.Tag); int bI = ModelBone.GetBoneIndexFromKey((int)e.Node.Tag); SceneManager.Current.SetSelectedBone(mI, bI); ModelBone bone = SceneManager.Current.Models[mI].Bones[bI]; if (bone.Type == BoneType.Mesh) { SceneManager.Current.Entities.Add(new Bounds { LinkedBox = bone.Mesh.BoundingBox }); } else { SceneManager.Current.Entities.Add(new Node { LinkedBone = bone }); } } } }
private void tvNodes_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag != null && SceneManager.Current.Models.Count > 0) { int mI = ModelBone.GetModelIndexFromKey((int)e.Node.Tag); int bI = ModelBone.GetBoneIndexFromKey((int)e.Node.Tag); SceneManager.Current.SetSelectedBone(mI, bI); var bone = SceneManager.Current.Models[mI].Bones[bI]; if (bone.Type == BoneType.Mesh) { SceneManager.Current.SetBoundingBox(bone.Mesh.BoundingBox); } else { SceneManager.Current.SetNodePosition(bone); } } }