public bool IsCurrentLink(Node currentNode) { if (!IsTwoSided) return ((Node1 == currentNode) && !Node2.Visited); else return (((Node1 == currentNode) && !Node2.Visited) || ((Node2 == currentNode) && !Node1.Visited)); }
public NodeDialog(Action<Node> callback, DialogMode dialogMode, Node node = null) { this.InitializeComponent(); _callback = callback; switch (dialogMode) { case DialogMode.CreationMode: Title = "Add new node"; PrimaryButtonText = "Create"; _node = new Node(); break; case DialogMode.EditMode: Title = "Edit node"; PrimaryButtonText = "Save"; _node = node; break; default: throw new ArgumentException("Not supported", "dialogMode"); } }
private void DrawNode(CanvasDrawingSession ds, Node node) { ds.FillCircle(node.Position, hitTestRadius, backgroundColor); ds.DrawCircle(node.Position, hitTestRadius, foregroundColor, 4); ds.DrawText(node.Name, node.Position, foregroundColor, textFormat); }
private void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (activeDrag != null) { activeDrag = null; Canvas.Invalidate(); } }
private void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e) { if (Nodes.Count == 0) { return; } var pointerPos = e.GetCurrentPoint(Canvas).Position.ToVector2(); var targetDistances = (from node in Nodes select Vector2.Distance(pointerPos, node.Position)).ToList(); int closestTarget = targetDistances.IndexOf(targetDistances.Min()); if (targetDistances[closestTarget] <= hitTestRadius) { activeDrag = Nodes[closestTarget]; dragOffset = pointerPos - Nodes[closestTarget].Position; Canvas.Invalidate(); } }