Example #1
0
        private void EndLink(MouseEventArgs e)
        {
            var link = ActionObject.Link;
            var node = ActiveElement.Node;

            if (node == null && !link.Links.AllowFreeFloatingLinks)
            {
                // free-floating links are not allowed and this action would not attach the link to a node
                return;
            }
            if (node != null)
            {
                link.Target.Node      = node;
                link.Target.RelativeX = e.RelativeXTo(node);
                link.Target.RelativeY = e.RelativeYTo(node);
            }
            else
            {
                link.Target.RelativeX = e.RelativeXToOrigin(this);
                link.Target.RelativeY = e.RelativeYToOrigin(this);
            }
            link.Deselect();
            link.Links.OnModified?.Invoke(link);
            Overview?.TriggerUpdate();
            Changes.New(new ChangeAction(() => { Links.Add(link); }, () => { Links.Remove(link); }));
            ActionObject.Clear();
            ActionType = ActionType.None;
        }
Example #2
0
        private void FollowCursorForLinkTarget(MouseEventArgs e)
        {
            var link = ActionObject.Link;

            link.Target.RelativeX = e.RelativeXToOrigin(this);
            link.Target.RelativeY = e.RelativeYToOrigin(this);
            Overview?.TriggerUpdate();
        }
Example #3
0
 private void MoveNodeAnchor(MouseEventArgs e)
 {
     if (ActionObject.Point != null)
     {
         var anchor = ActionObject.Anchor;
         anchor.RelativeX = e.RelativeXToOrigin(this);
         anchor.RelativeY = e.RelativeYToOrigin(this);
     }
     else
     {
         ActionObject.SetPoint(new Point(e.ClientX, e.ClientY));
         var anchor = ActionObject.Anchor;
         ActionObject.Remember(anchor.Node, anchor.RelativeX, anchor.RelativeY);
         anchor.Node      = null;
         anchor.NodeId    = null;
         anchor.RelativeX = e.RelativeXToOrigin(this);
         anchor.RelativeY = e.RelativeYToOrigin(this);
     }
     Overview?.TriggerUpdate();
 }
Example #4
0
        internal void AddNewLink(NodeBase node, MouseEventArgs e, Action <LinkBase> on_link_create)
        {
            var source_point = new NodeAnchor
            {
                Node      = node,
                RelativeX = e.RelativeXTo(node),
                RelativeY = e.RelativeYTo(node)
            };
            var target_point = new NodeAnchor
            {
                RelativeX = e.RelativeXToOrigin(Diagram),
                RelativeY = e.RelativeYToOrigin(Diagram)
            };

            internally_generated_links.Add(new LinkData {
                Source = source_point, Target = target_point, LinkType = DefaultType, Arrow = DefaultArrow, OnCreate = on_link_create
            });
            generated_links_ref.TriggerStateHasChanged();
        }
 public static double RelativeXTo(this MouseEventArgs e, NodeBase node) => e.RelativeXToOrigin(node.Diagram) - node.X;