protected virtual void CreateVertexControl(TVertex vertex)
        {
            VertexControl presenter;
            var           compoundGraph = Graph as ICompoundGraph <TVertex, TEdge>;

            if (IsCompoundMode && compoundGraph != null && compoundGraph.IsCompoundVertex(vertex))
            {
                var compoundPresenter = new CompoundVertexControl
                {
                    Vertex = vertex
                };
                compoundPresenter.Expanded  += CompoundVertexControl_ExpandedOrCollapsed;
                compoundPresenter.Collapsed += CompoundVertexControl_ExpandedOrCollapsed;
                presenter = compoundPresenter;
            }
            else
            {
                // Create the Control of the vertex
                presenter = new VertexControl
                {
                    Vertex = vertex
                };
            }

            //var presenter = _vertexPool.GetObject();
            //presenter.Vertex = vertex;
            _vertexControls[vertex] = presenter;
            presenter.RootCanvas    = this;

            if (IsCompoundMode && compoundGraph != null && compoundGraph.IsChildVertex(vertex))
            {
                var parent        = compoundGraph.GetParent(vertex);
                var parentControl = GetOrCreateVertexControl(parent) as CompoundVertexControl;

                Debug.Assert(parentControl != null);

                parentControl.Vertices.Add(presenter);
            }
            else
            {
                //add the presenter to the GraphLayout
                Children.Add(presenter);
            }

            presenter.ApplyTemplate();
            VisualStateManager.GoToState(presenter, "BeforeAdded", false);
            VisualStateManager.GoToState(presenter, "AfterAdded", true);

            //Measuring & Arrange
            presenter.InvalidateMeasure();
            //SetHighlightProperties(vertex, presenter);
        }
Esempio n. 2
0
        protected virtual void CreateVertexControl(TVertex vertex)
        {
            VertexControl presenter;
            var           compoundGraph = Graph as ICompoundGraph <TVertex, TEdge>;

            if (IsCompoundMode && compoundGraph != null && compoundGraph.IsCompoundVertex(vertex))
            {
                var compoundPresenter = new CompoundVertexControl
                {
                    Vertex      = vertex,
                    DataContext = vertex,
                };
                compoundPresenter.Expanded  += CompoundVertexControl_ExpandedOrCollapsed;
                compoundPresenter.Collapsed += CompoundVertexControl_ExpandedOrCollapsed;
                presenter = compoundPresenter;
            }
            else
            {
                // Create the Control of the vertex
                presenter = new VertexControl
                {
                    Vertex      = vertex,
                    DataContext = vertex,
                };
            }

            //var presenter = _vertexPool.GetObject();
            //presenter.Vertex = vertex;
            VertexControls[vertex] = presenter;
            presenter.RootCanvas   = this;

            if (IsCompoundMode && compoundGraph != null && compoundGraph.IsChildVertex(vertex))
            {
                var parent        = compoundGraph.GetParent(vertex);
                var parentControl = GetOrCreateVertexControl(parent) as CompoundVertexControl;

                Debug.Assert(parentControl != null);

                parentControl.Vertices.Add(presenter);
            }
            else
            {
                //add the presenter to the GraphLayout
                Children.Add(presenter);
            }

            //Measuring & Arrange
            presenter.InvalidateMeasure();
            SetHighlightProperties(vertex, presenter);
            RunCreationTransition(presenter);
        }