Exemplo n.º 1
0
        /// <summary>
        /// A <see cref="LayoutExecutor"/> that is used during the drag and drop operation.
        /// </summary>
        /// <remarks>
        /// First, all nodes and edges are pushed back into place before the drag started. Then space
        /// is made for the component at its current position. The animation morphs all elements to the
        /// calculated positions.
        /// </remarks>
        private LayoutExecutor CreateDraggingLayoutExecutor()
        {
            var layout = new GivenCoordinatesStage(
                clearAreaLayout = new ClearAreaLayout {
                ComponentAssignmentStrategy = ComponentAssignmentStrategy.Customized,
                ClearAreaStrategy           = ClearAreaStrategy.PreserveShapes
            });

            var layoutData = new CompositeLayoutData(
                resetToOriginalGraphStageData,
                new ClearAreaLayoutData {
                ComponentIds = { Mapper = components }
            });

            var items = new List <IModelItem>();

            items.AddRange(Component.Nodes);
            items.AddRange(Component.Edges);
            clearAreaLayout.ConfigureAreaOutline(items, 10);

            return(new LayoutExecutor(graphControl, layout)
            {
                LayoutData = layoutData,
                RunInThread = true,
                Duration = TimeSpan.FromMilliseconds(150)
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// A <see cref="LayoutExecutor"/> that is used after the drag and drop operation is finished.
        /// </summary>
        /// <remarks>
        /// All nodes and edges are pushed back into place before the drag started. Then space is made
        /// for the component that has been dropped.
        /// </remarks>
        private LayoutExecutor CreateFinishedLayoutExecutor()
        {
            var layout = new GivenCoordinatesStage(
                new ClearAreaLayout {
                ComponentAssignmentStrategy = ComponentAssignmentStrategy.Customized,
                ClearAreaStrategy           = ClearAreaStrategy.PreserveShapes
            });

            var layoutData = new CompositeLayoutData(
                resetToOriginalGraphStageData,
                new ClearAreaLayoutData {
                AreaNodes    = { Source = Component.Nodes },
                ComponentIds = { Mapper = components }
            });

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