Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <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;
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
 /// <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;
 }