/// <summary>
        /// Prepares the <see cref="LayoutExecutor"/> that is called after the selection is deleted.
        /// </summary>
        private void OnDeletingSelection(object sender, SelectionEventArgs <IModelItem> e)
        {
            // determine the bounds of the selection
            var rect = GetBounds(e.Selection);

            // configure the layout that will fill free space
            var layout = new FillAreaLayout {
                ComponentAssignmentStrategy = ComponentAssignmentStrategy,
                Area = rect.ToYRectangle()
            };

            // configure the LayoutExecutor that will perform the layout and morph the result
            executor = new LayoutExecutor(GraphControl, layout)
            {
                Duration = TimeSpan.FromMilliseconds(100)
            };
        }
        /// <summary>
        /// Creates a layout algorithm suiting the <paramref name="resizeState"/>.
        /// </summary>
        /// <param name="resizeState">The current state of the gesture</param>
        /// <returns>A layout algorithm suiting the <paramref name="resizeState"/>.</returns>
        private ILayoutAlgorithm CreateLayout(ResizeState resizeState)
        {
            var sequentialLayout = new SequentialLayout();

            if (resizeState == ResizeState.Shrinking)
            {
                // fill the free space of the shrunken node
                fillLayout = new FillAreaLayout {
                    ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single
                };
                sequentialLayout.AppendLayout(fillLayout);
                if (this.state == GestureState.Finishing)
                {
                    // only route edges for the final layout
                    sequentialLayout.AppendLayout(new EdgeRouter {
                        Scope = Scope.RouteEdgesAtAffectedNodes
                    });
                }
            }
            else
            {
                if (resizeState == ResizeState.Both)
                {
                    // fill the free space of the resized node
                    fillLayout = new FillAreaLayout {
                        ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single
                    };
                    sequentialLayout.AppendLayout(fillLayout);
                }
                // clear the space of the moved/enlarged node
                sequentialLayout.AppendLayout(new ClearAreaLayout {
                    ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single,
                    ClearAreaStrategy           = ClearAreaStrategy.Local,
                    ConsiderEdges = true
                });
            }
            return(new GivenCoordinatesStage(sequentialLayout));
        }
Beispiel #3
0
        /// <summary>
        /// A <see cref="LayoutExecutor"/> that is used when dragging the subtree starts.
        /// </summary>
        /// <remarks>
        /// When the drag begins, the <see cref="FillAreaLayout"/> fills up the space that was covered by the subtree.
        /// This state is the initial layout for the <see cref="ClearAreaLayout"/> during the drag.
        /// </remarks>
        private LayoutExecutor CreateInitializingLayoutExecutor()
        {
            var layout = new FillAreaLayout {
                LayoutOrientation           = LayoutOrientation.TopToBottom,
                ComponentAssignmentStrategy = ComponentAssignmentStrategy.Customized,
                Spacing = 50
            };

            layout.ConfigureAreaOutline(subtree.Nodes);

            var layoutData = new FillAreaLayoutData {
                ComponentIds = { Mapper = components },
            };

            // the FillAreaLayout is only applied to the part of the tree that does not belong to the subtree
            IGraph filteredGraph = new FilteredGraphWrapper(graphControl.Graph, n => !subtree.Nodes.Contains(n));

            return(new LayoutExecutor(graphControl, filteredGraph, layout)
            {
                LayoutData = layoutData,
                RunInThread = true,
                Duration = TimeSpan.FromMilliseconds(150)
            });
        }