protected virtual VertexControl CreateVertexControl([NotNull] TVertex vertex) { var compoundGraph = Graph as ICompoundGraph <TVertex, TEdge>; VertexControl vertexControl; if (IsCompoundMode && compoundGraph != null && compoundGraph.IsCompoundVertex(vertex)) { var compoundVertexControl = new CompoundVertexControl { Vertex = vertex, DataContext = vertex, }; vertexControl = compoundVertexControl; } else { // Create the Control of the vertex vertexControl = new VertexControl { Vertex = vertex, DataContext = vertex, }; } VerticesControls[vertex] = vertexControl; vertexControl.RootCanvas = this; if (IsCompoundMode && compoundGraph != null && compoundGraph.IsChildVertex(vertex)) { TVertex parent = compoundGraph.GetParent(vertex); Debug.Assert(parent != null, "Vertex considered as child one has no parent."); var parentControl = GetOrCreateVertexControl(parent) as CompoundVertexControl; Debug.Assert(parentControl != null); parentControl.Vertices.Add(vertexControl); } else { // Add the presenter to the GraphLayout Children.Add(vertexControl); } // Measure & Arrange vertexControl.InvalidateMeasure(); SetHighlightProperties(vertex, vertexControl); RunCreationTransition(vertexControl); return(vertexControl); }
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); }