示例#1
0
        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;
        }
示例#2
0
        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();
                }
            }
        }
示例#3
0
        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);
        }
示例#4
0
 public bool Equals(DropLocation loc)
 {
     return loc.Parent == this.Parent && loc.Sibling == this.Sibling && loc.InsertAfterSibling == this.InsertAfterSibling;
 }
示例#5
0
        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();
                }

            }
        }
示例#6
0
        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;
        }
示例#7
0
        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;
        }
示例#8
0
 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);
 }