internal void OnMouseDrop(MouseEventArgs e) { if (IsNodeDragging) { RefreshNodeDropLocation(e.Location); if (!NodeDropLocation.IsEmpty && NodeDragDrop != null) { NodeDragDrop(MapView.Tree, NodeDropLocation); } MapView.Canvas.KeyDown -= Canvas_KeyDown; } dragObject = null; NodeDropLocation = new DropLocation(); MapView.Canvas.Cursor = Cursors.Default; }
private void RefreshNodeDropLocation(Point p) { DropLocation location = CalculateDropLocation(p); if (!location.Equals(NodeDropLocation)) { if (IsValidDropLocation(location)) { NodeDropLocation = location; MapView.Canvas.Invalidate(); } else if (!NodeDropLocation.IsEmpty) { NodeDropLocation = new DropLocation(); MapView.Canvas.Invalidate(); } } }
private bool IsValidDropLocation(DropLocation location) { if (location.IsEmpty) { return(false); } foreach (MapNode n in MapView.Tree.SelectedNodes) { if (n == location.Parent) { return(false); } //drop location is included in moved nodes if (n.Parent == location.Parent) { if (n.Next != null && n.Next == location.Sibling && !location.InsertAfterSibling) //same location as present { return(false); } if (n.Previous != null && n.Previous == location.Sibling && location.InsertAfterSibling) //same location as present { return(false); } } if (n.Pos == NodePosition.Root) { return(false); } //can't move root if (location.Parent.IsDescendent(n)) { return(false); } //can't move ancentor to child } return(true); }
public bool Equals(DropLocation loc) { return loc.Parent == this.Parent && loc.Sibling == this.Sibling && loc.InsertAfterSibling == this.InsertAfterSibling; }
private void RefreshNodeDropLocation(Point p) { DropLocation location = CalculateDropLocation(p); if(!location.Equals(NodeDropLocation)) { if(IsValidDropLocation(location)) { NodeDropLocation = location; MapView.Canvas.Invalidate(); } else if(!NodeDropLocation.IsEmpty) { NodeDropLocation = new DropLocation(); MapView.Canvas.Invalidate(); } } }
private bool IsValidDropLocation(DropLocation location) { if (location.IsEmpty) { return false; } foreach(MapNode n in MapView.Tree.SelectedNodes) { if(n == location.Parent) { return false; } //drop location is included in moved nodes if (n.Parent == location.Parent) { if(n.Next != null && n.Next == location.Sibling && !location.InsertAfterSibling) //same location as present { return false; } if(n.Previous != null && n.Previous == location.Sibling && location.InsertAfterSibling) //same location as present { return false; } } if (n.Pos == NodePosition.Root) { return false; } //can't move root if (location.Parent.IsDescendent(n)) { return false; } //can't move ancentor to child } return true; }
public bool Equals(DropLocation loc) { return(loc.Parent == this.Parent && loc.Sibling == this.Sibling && loc.InsertAfterSibling == this.InsertAfterSibling); }
internal void NodeDragDrop(MapTree tree, DropLocation location) { mapCtrl.MoveNodes(location); }