/// <summary> /// The subtree is upon to be dragged. /// </summary> public void InitializeDrag(IInputModeContext context) { subtree = new Subtree(context.GetGraph(), node); layoutHelper = new RelocateSubtreeLayoutHelper((GraphControl)context.CanvasControl, subtree); layoutHelper.InitializeLayout(); compositeHandler = CreateCompositeHandler(subtree); compositeHandler.InitializeDrag(context); }
/// <summary> /// Creates a mapping to specify the components which should not be modified by <see cref="ClearAreaLayout"/>. /// </summary> private void UpdateComponents() { components.Clear(); if (subtree.NewParent != null) { foreach (var edge in Graph.OutEdgesAt(subtree.NewParent)) { var siblingSubtree = new Subtree(Graph, edge.GetTargetNode()); foreach (var node in siblingSubtree.Nodes) { components[node] = siblingSubtree; } } } }
/// <summary> /// Creates an <see cref="IPositionHandler"/> that moves the whole subtree. /// </summary> /// <param name="subtree">The nodes and edges of the subtree.</param> /// <returns></returns> private static IPositionHandler CreateCompositeHandler(Subtree subtree) { var positionHandlers = new List <IPositionHandler>(); foreach (var node in subtree.Nodes) { var positionHandler = node.Lookup <IPositionHandler>(); if (positionHandler != null) { var subtreeHandler = positionHandler as SubtreePositionHandler; positionHandlers.Add(subtreeHandler != null ? subtreeHandler.nodePositionHandler : positionHandler); } } foreach (var edge in subtree.Edges) { var positionHandler = edge.Lookup <IPositionHandler>(); if (positionHandler != null) { positionHandlers.Add(positionHandler); } } return(PositionHandlers.Combine(positionHandlers)); }
/// <summary> /// Initializes the helper. /// </summary> /// <param name="graphControl">The control that displays the graph.</param> /// <param name="subtree">The subgraph the is dragged.</param> public RelocateSubtreeLayoutHelper(GraphControl graphControl, Subtree subtree) { this.graphControl = graphControl; this.subtree = subtree; }