示例#1
0
        private void FixNodeAnchor(MouseEventArgs e)
        {
            var(anchor, old_node, old_x, old_y) = (ActionObject.Anchor, ActionObject.Node, ActionObject.X, ActionObject.Y);
            var node = ActiveElement.Node;

            if (node == null && !ActionObject.Link.Links.AllowFreeFloatingLinks)
            {
                // free-floating links are not allowed and this action would not attach the link to a node
                return;
            }
            var(x, y) = (node != null) ? e.RelativeTo(node) : e.RelativeToOrigin(this);
            Changes.NewAndDo(new ChangeAction(() =>
            {
                anchor.Node      = node;
                anchor.RelativeX = x;
                anchor.RelativeY = y;
            }, () =>
            {
                anchor.Node      = old_node;
                anchor.RelativeX = old_x;
                anchor.RelativeY = old_y;
            }));
            Overview?.TriggerUpdate();
            ActionObject.Link.Deselect();
            ActionObject.Link.Links.OnModified?.Invoke(ActionObject.Link);
            ActionObject.Clear();
            ActionType = ActionType.None;
        }
示例#2
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;
        }
示例#3
0
 private void OnMouseWheel(WheelEventArgs e)
 {
     NavigationSettings.OnMouseWheel(e);
     Nodes.ReRenderIfOffCanvasChanged();
     Links.TriggerStateHasChanged();
     Overview?.TriggerUpdate(just_pan_or_zoom: true);
 }
示例#4
0
        private void FollowCursorForLinkTarget(MouseEventArgs e)
        {
            var link = ActionObject.Link;

            link.Target.RelativeX = e.RelativeXToOrigin(this);
            link.Target.RelativeY = e.RelativeYToOrigin(this);
            Overview?.TriggerUpdate();
        }
示例#5
0
 private void ReRender()
 {
     Nodes.TriggerStateHasChanged();
     Links.TriggerStateHasChanged();
     Links.Redraw();
     Overview?.TriggerUpdate();
     StateHasChanged();
 }
示例#6
0
        private void CreateNewLink(MouseEventArgs e)
        {
            var node = ActiveElement.Node;

            Links.AddNewLink(node, e, (generated_link) =>
            {
                ActionObject.Set(generated_link);
                ActionType = ActionType.UpdateLinkTarget;
                generated_link.Select();
                Overview?.TriggerUpdate();
            });
        }
示例#7
0
        private void StopModifyingLink(MouseEventArgs e)
        {
            Overview?.TriggerUpdate();
            // another click means ending the current action and starting a new one
            var link = ActionObject.Link;

            link.Deselect();
            link.TriggerStateHasChanged();
            ActionObject.Clear();
            ActionType = ActionType.None;
            StartAction(e);
        }
示例#8
0
 private void Pan(MouseEventArgs e)
 {
     if (ActionObject.Point != null)
     {
         MoveOrigin(e.ClientX - ActionObject.Point.X, e.ClientY - ActionObject.Point.Y);
         (ActionObject.Point.X, ActionObject.Point.Y) = (e.ClientX, e.ClientY);
         Overview?.TriggerUpdate(just_pan_or_zoom: true);
     }
     else
     {
         ActionObject.SetPoint(new Point(e.ClientX, e.ClientY));
     }
 }
示例#9
0
        private void GoBackToEditingLink()
        {
            var cp = ActionObject.ControlPoint;

            var(new_x, new_y) = (ActionObject.ControlPoint.X, ActionObject.ControlPoint.Y);
            var(old_x, old_y) = (ActionObject.Origin.X, ActionObject.ControlPoint.Y);
            Changes.New(new ChangeAction(() => { (cp.X, cp.Y) = (new_x, new_y); }, () => { (cp.X, cp.Y) = (old_x, old_y); }));
            var link = ActionObject.Link;

            ActionObject.Set(link);
            ActionType = ActionType.ModifyLink;
            Overview?.TriggerUpdate();
        }
示例#10
0
        private void CreateNewNode()
        {
            var node = ActiveElement.Node;

            Nodes.AddNewNode(node, (new_node) =>
            {
                Changes.New(new ChangeAction(() => Nodes.Add(new_node), () => Nodes.Remove(new_node)));
                Group.Clear();
                Group.Add(new_node);
                new_node.Select();
                ActionObject.Set(new_node);
                ActionType = ActionType.Move;
                node_library_wrapper.NewNodeAddingInProgress = true;
                Overview?.TriggerUpdate();
            });
        }
示例#11
0
 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();
 }
示例#12
0
 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));
     }
 }
示例#13
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();
 }
示例#14
0
        private void StopMove()
        {
            if (ActionObject.Origin == null)
            {
                // no move was actually done
                ActionObject.Clear();
                ActionType = ActionType.None;
                return;
            }
            var nodes     = Group.Nodes.ToList();
            var positions = nodes.Select(n => (X: n.X, Y: n.Y)).ToList();

            var(delta_x, delta_y) = (ActionObject.Node.X - ActionObject.Origin.X, ActionObject.Node.Y - ActionObject.Origin.Y);
            var old_positions = nodes.Select(n => (X: n.X - delta_x, Y: n.Y - delta_y)).ToList();

            Changes.New(new ChangeAction(() =>
            {
                foreach (var(node, position) in nodes.Zip(positions, (n, p) => (n, p)))
                {
                    node.MoveTo(position.X, position.Y);
                    node.TriggerStateHasChanged();
                }
            }, () =>
            {
                foreach (var(node, position) in nodes.Zip(old_positions, (n, p) => (n, p)))
                {
                    node.MoveTo(position.X, position.Y);
                    node.TriggerStateHasChanged();
                }
            }));
            ActionObject.Clear();
            ActionType = ActionType.None;
            if (Group.Nodes.Count == 1)
            {
                Group.Clear();
            }
            node_library_wrapper.NewNodeAddingInProgress = false;
            Overview?.TriggerUpdate();
        }
 internal void UpdateOverview(bool just_pan_or_zoom = false)
 {
     Overview?.TriggerUpdate(just_pan_or_zoom);
 }