void HierarchyTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { Point p = this.PointToClient(new Point(e.X, e.Y)); HitRecord hit = Pick(p); if (hit.Node != null) { Node dest = hit.Node; Node data = e.Data.GetData(typeof(Node)) as Node; EditorCore.DragDrop.DragMatcher matcher = EditorCore.DragDrop.DragMatchCollection.GetMaster().GetBestFor(data.Tag.GetType(), dest.Tag.GetType()); if (matcher != null) { if (matcher.CanDoDrop(data.Tag, dest.Tag)) { matcher.DoDrop(data.Tag, dest.Tag, data, dest); Node newNode = dest.Add(data.Tag); data.Parent.Remove(data.Tag); UpdateNode(newNode); } } } }
void HierarchyTree_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { HitRecord hit = Pick(PointToClient(new Point(e.X, e.Y))); if (hit.Node != null) { Node dest = hit.Node; Node data = e.Data.GetData(typeof(Node)) as Node; if (dest == null || data == null) { e.Effect = DragDropEffects.None; return; } EditorCore.DragDrop.DragMatcher matcher = EditorCore.DragDrop.DragMatchCollection.GetMaster().GetBestFor(data.Tag.GetType(), dest.Tag.GetType()); if (matcher != null && matcher.CanDoDrop(data.Tag, dest.Tag)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } } }