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; }
private void MoveGroup(MouseEventArgs e) { if (ActionObject.Point != null) { var delta_x = e.RelativeXTo(ActionObject.Point) / NavigationSettings.Zoom; var delta_y = e.RelativeYTo(ActionObject.Point) / NavigationSettings.Zoom; foreach (var node in Group.Nodes) { node.MoveTo(node.X + delta_x, node.Y + delta_y); } (ActionObject.Point.X, ActionObject.Point.Y) = (e.ClientX, e.ClientY); } else { ActionObject.SetPoint(new Point(e.ClientX, e.ClientY)); ActionObject.RememberOrigin(new Point(ActionObject.Node.X, ActionObject.Node.Y)); } Overview?.TriggerUpdate(); }
private void MoveControlPoint(MouseEventArgs e) { if (ActionObject.Point != null) { var point = ActionObject.ControlPoint; var delta_x = e.RelativeXTo(ActionObject.Point) / NavigationSettings.Zoom; var delta_y = e.RelativeYTo(ActionObject.Point) / NavigationSettings.Zoom; point.X += delta_x; point.Y += delta_y; (ActionObject.Point.X, ActionObject.Point.Y) = (e.ClientX, e.ClientY); Overview?.TriggerUpdate(); ActionObject.Link.TriggerStateHasChanged(); } else { ActionObject.SetPoint(new Point(e.ClientX, e.ClientY)); ActionObject.RememberOrigin(new Point(ActionObject.ControlPoint.X, ActionObject.ControlPoint.Y)); } }
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 RelativeXToOrigin(this MouseEventArgs e, Diagram diagram) => e.RelativeXTo(diagram) + diagram.NavigationSettings.Origin.X;