GetEdgeDrawingVisuals ( EdgeDrawingHistory oEdgeDrawingHistory ) { Debug.Assert(oEdgeDrawingHistory != null); AssertValid(); return(oEdgeDrawingHistory.DrawnAsSelected ? m_oSelectedEdgeDrawingVisuals : m_oUnselectedEdgeDrawingVisuals); }
//************************************************************************* // Method: GetEdgeDrawingVisuals() // /// <summary> /// Gets a DrawingVisual that contains all the visuals for either /// unselected edges or selected edges. /// </summary> /// /// <param name="oEdgeDrawingHistory"> /// Determines which DrawingVisual gets returned. /// </param> /// /// <returns> /// If <paramref name="oEdgeDrawingHistory" /> indicates that the edge was /// drawn as unselected, then the DrawingVisual that contains all the /// visuals for unselected edges is returned. Otherwise, the DrawingVisual /// that contains all the visuals for selected edges is returned. /// </returns> //************************************************************************* protected DrawingVisual GetEdgeDrawingVisuals( EdgeDrawingHistory oEdgeDrawingHistory ) { Debug.Assert(oEdgeDrawingHistory != null); AssertValid(); return (oEdgeDrawingHistory.DrawnAsSelected ? m_oSelectedEdgeDrawingVisuals : m_oUnselectedEdgeDrawingVisuals); }
TryDrawEdge ( IEdge edge, GraphDrawingContext graphDrawingContext, out EdgeDrawingHistory edgeDrawingHistory ) { Debug.Assert(edge != null); Debug.Assert(graphDrawingContext != null); AssertValid(); edgeDrawingHistory = null; // If the edge is hidden, do nothing. VisibilityKeyValue eVisibility = GetVisibility(edge); if (eVisibility == VisibilityKeyValue.Hidden) { return(false); } Boolean bDrawAsSelected = GetDrawAsSelected(edge); Color oColor = GetColor(edge, eVisibility, bDrawAsSelected); Double dWidth = GetWidth(edge, bDrawAsSelected); DashStyle oDashStyle = GetDashStyle(edge, dWidth, bDrawAsSelected); Boolean bDrawArrow = (m_bDrawArrowOnDirectedEdge && edge.IsDirected); IVertex [] aoVertices = edge.Vertices; DrawingVisual oDrawingVisual = new DrawingVisual(); using (DrawingContext oDrawingContext = oDrawingVisual.RenderOpen()) { if (edge.IsSelfLoop) { if (!TryDrawSelfLoop(aoVertices[0], oDrawingContext, graphDrawingContext, oColor, dWidth, bDrawArrow)) { // The edge's vertex is hidden, so the edge should be // hidden also. return(false); } } else { Point oEdgeEndpoint1, oEdgeEndpoint2; if (!TryGetEdgeEndpoints(aoVertices[0], aoVertices[1], graphDrawingContext, out oEdgeEndpoint1, out oEdgeEndpoint2)) { // One of the edge's vertices is hidden, so the edge should // be hidden also. return(false); } if (bDrawArrow) { // Draw the arrow and set the second endpoint to the center // of the flat end of the arrow. Double dArrowAngle = WpfGraphicsUtil.GetAngleBetweenPoints( oEdgeEndpoint1, oEdgeEndpoint2); oEdgeEndpoint2 = DrawArrow(oDrawingContext, oEdgeEndpoint2, dArrowAngle, oColor, dWidth); } // Draw the edge. oDrawingContext.DrawLine(GetPen(oColor, dWidth, oDashStyle), oEdgeEndpoint1, oEdgeEndpoint2); // Draw the edge's label, if there is one. Object oLabelAsObject; if (edge.TryGetValue(ReservedMetadataKeys.PerEdgeLabel, typeof(String), out oLabelAsObject) && oLabelAsObject != null) { DrawLabel(oDrawingContext, graphDrawingContext, oEdgeEndpoint1, oEdgeEndpoint2, (String)oLabelAsObject, oColor); } } // Retain information about the edge that was drawn. edgeDrawingHistory = new EdgeDrawingHistory( edge, oDrawingVisual, bDrawAsSelected); return(true); } }