/// <summary> /// Called after the layout has been calculated. /// </summary> /// <remarks> /// Applies the layout in an animation and cleans up. Calls OnDone to raise the Done event after the animation has been completed. /// </remarks> /// <param name="graph">The graph to apply the layout to.</param> /// <param name="moduleContext">The module context.</param> /// <param name="compoundEdit">The undo edit which wraps the layout. It was created in <see cref="StartWithIGraph"/> and will be closed here.</param> protected virtual async Task LayoutDone(IGraph graph, ILookup moduleContext, ICompoundEdit compoundEdit) { if (abortDialog != null) { if (abortDialog.IsVisible) { abortDialog.Close(); } abortDialog = null; } GraphControl view = moduleContext.Lookup <GraphControl>(); if (LayoutMorphingEnabled && view != null) { var morphingAnimation = graph.CreateLayoutAnimation(layoutGraph, TimeSpan.FromSeconds(1)); Rectangle2D box = LayoutGraphUtilities.GetBoundingBox(layoutGraph, layoutGraph.GetNodeCursor(), layoutGraph.GetEdgeCursor()); RectD targetBounds = box.ToRectD(); ViewportAnimation vpAnim = new ViewportAnimation(view, targetBounds, TimeSpan.FromSeconds(1)) { MaximumTargetZoom = 1.0d, TargetViewMargins = view.ContentMargins }; var animations = new List <IAnimation>(); animations.Add(morphingAnimation); animations.Add(CreateTableAnimations()); if (ViewPortMorphingEnabled) { animations.Add(vpAnim); } TableLayoutConfigurator.CleanUp(graph); Animator animator = new Animator(view); await animator.Animate(animations.CreateParallelAnimation().CreateEasedAnimation()); try { compoundEdit.Commit(); view.UpdateContentRect(); } finally { OnDone(new LayoutEventArgs()); } } else { layoutGraph.CommitLayoutToOriginalGraph(); RestoreTableLayout(); compoundEdit.Commit(); if (view != null) { view.UpdateContentRect(); } OnDone(new LayoutEventArgs()); } }
/// <summary> /// Modifies <see cref="InUpdate"/> if applicable. /// </summary> public void EndValueUpdate() { if (currentEdit != null) { currentEdit.Commit(); currentEdit = null; } inUpdateCounter--; }
/// <summary> /// Called after the a layout run finished. /// </summary> private void OnExecutorFinished() { if (canceled) { layoutEdit.Cancel(); } else if (stopped) { layoutEdit.Commit(); } }
/// <summary> /// Finishes the drag and updates the angle of the rotated node. /// </summary> public void DragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation) { var vector = (newLocation - rotationCenter).Normalized; var angle = CalculateAngle(vector); if (ShouldSnap(context)) { angle = SnapAngle(context, angle); } SetAngle(context, angle); // Switch width / height for 'vertical' rotations // Note that other parts of the application need support for this feature, too. var graph = context.GetGraph(); if (graph == null) { return; } var portContext = new DelegatingContext(context); foreach (var portHandle in portHandles) { portHandle.DragFinished(portContext, originalLocation, newLocation); } portHandles.Clear(); // Workaround: if the OrthogonalEdgeEditingContext is used to keep the edges orthogonal, it is not allowed // to change that edges manually. Therefore, we explicitly finish the OrthogonalEdgeEditingContext here and // then call the edge router. var edgeEditingContext = context.Lookup <OrthogonalEdgeEditingContext>(); if (edgeEditingContext != null && edgeEditingContext.IsInitialized) { edgeEditingContext.DragFinished(); } if (reshapeHandler != null) { reshapeHandler.ReshapeFinished(context, node.Layout.ToRectD(), node.Layout.ToRectD()); } if (compoundEdit != null) { compoundEdit.Commit(); } nodeAngles = null; ClearSameAngleHighlights(context); }
public virtual void ReshapeFinished(IInputModeContext context, RectD originalBounds, RectD newBounds) { foreach (var pair in reshapeHandlers) { pair.Value.ReshapeFinished(context, originalNodeLayouts[pair.Key], pair.Value.Bounds.ToRectD()); } foreach (var pair in orthogonalEdgeDragHandlers) { pair.Value.FinishDrag(); } compoundEdit.Commit(); Clear(context); }
/// <summary> /// Called after the a layout run finished. /// </summary> private void OnExecutorFinished() { if (canceled) { layoutEdit.Cancel(); } else if (stopped) { // finish undo/redo // save the layout of the rectangular area before and after the gesture var newRect = clearRect.ToRectD(); var oldRect = oldClearRect; graphControl.Graph.AddUndoUnit("Rectangle changed", "Rectangle changed", () => clearRect.Reshape(oldRect), () => clearRect.Reshape(newRect)); // add all changes of the complete gesture as one undo/redo unit layoutEdit.Commit(); } }