/// <summary> /// Called when a change of ActualTarget occurs. Recalculates ActualSource based on the new value. /// </summary> /// <param name="newActualTarget">The new ActualTarget.</param> private void OnActualTargetChanged(NPoint newActualTarget) { // only perform recalculation if no target has been set previously if (TargetNodePos == null) { switch (_sourceType) { case NodeType.Place: ActualSource = CalculatePlaceIntersection(SourceNodePos, newActualTarget); break; case NodeType.Transition: ActualSource = CalculateTransIntersection(SourceNodePos, newActualTarget); break; default: break; } } AdjustPositioning(); }
/// <summary> /// Called when a change of TargetNodePos occurs. Recalculates ActualTarget and ActualSource based /// on the new value. /// </summary> /// <param name="newTargetNodePos">The new TargetNodePos.</param> private void OnTargetNodePosChanged(NPoint newTargetNodePos) { if (IsValid) { switch (_sourceType) { case NodeType.Place: ActualTarget = CalculateTransIntersection(newTargetNodePos, SourceNodePos); ActualSource = CalculatePlaceIntersection(SourceNodePos, newTargetNodePos); break; case NodeType.Transition: ActualTarget = CalculatePlaceIntersection(newTargetNodePos, SourceNodePos); ActualSource = CalculateTransIntersection(SourceNodePos, newTargetNodePos); break; default: break; } // calculate minimum distance between node presentations for the VisualArc to remain visible double minimumDistance = Calculations.GetDistance(SourceNodePos, ActualSource) + Calculations.GetDistance(newTargetNodePos, ActualTarget); double distance = Calculations.GetDistance(SourceNodePos, newTargetNodePos); if (distance < minimumDistance) Visible = false; else Visible = true; } }
/// <summary> /// Performs initialization for a node move operation. /// </summary> /// <param name="dragSourceId">The id of the visual node that requested the operation.</param> /// <param name="coords">The coordinates at which the node move has been initiated.</param> private void InitializeNodeMove(String dragSourceId, Point coords) { IVisualNode node = ElementProvider.GetNode(dragSourceId); DragStart = new NPoint(coords.X, coords.Y); node.IsDragSource = true; DragSourceId = dragSourceId; UndoManager.MoveUndoViewSize = new Point(ViewWidth, ViewHeight); UndoManager.MoveUndoStart = new Point(node.XPos, node.YPos); }