public abstract GetEdgeEndpoint ( Point otherEndpoint, Point &edgeEndpoint ) : void | ||
otherEndpoint | Point | |
edgeEndpoint | Point | |
Результат | void |
TryGetVertexInformation ( IVertex oVertex1, IVertex oVertex2, out VertexDrawingHistory oVertex1DrawingHistory, out VertexDrawingHistory oVertex2DrawingHistory, out Point oEdgeEndpoint1, out Point oEdgeEndpoint2 ) { Debug.Assert(oVertex1 != null); Debug.Assert(oVertex2 != null); AssertValid(); oVertex1DrawingHistory = oVertex2DrawingHistory = null; oEdgeEndpoint1 = oEdgeEndpoint2 = new Point(); // Retrieve the information about how the vertices were drawn. if ( !TryGetVertexDrawingHistory(oVertex1, out oVertex1DrawingHistory) || !TryGetVertexDrawingHistory(oVertex2, out oVertex2DrawingHistory) ) { // One of the edge's vertices is hidden. return (false); } // The drawing histories determine the edge endpoints. For example, if // oVertex1 was drawn as a circle, then oVertex1DrawingHistory is a // CircleVertexDrawingHistory that knows to put its endpoint on the // circle itself and not at the circle's center. oVertex1DrawingHistory.GetEdgeEndpoint( oVertex2DrawingHistory.VertexLocation, out oEdgeEndpoint1); oVertex2DrawingHistory.GetEdgeEndpoint( oVertex1DrawingHistory.VertexLocation, out oEdgeEndpoint2); return (true); }
DrawCurveThroughIntermediatePoints ( IEdge oEdge, GraphDrawingContext oGraphDrawingContext, DrawingContext oDrawingContext, VertexDrawingHistory oVertex1DrawingHistory, VertexDrawingHistory oVertex2DrawingHistory, Point oEdgeEndpoint1, Point oEdgeEndpoint2, Pen oPen ) { Debug.Assert(oEdge != null); Debug.Assert(oGraphDrawingContext != null); Debug.Assert(oDrawingContext != null); Debug.Assert(oVertex1DrawingHistory != null); Debug.Assert(oVertex2DrawingHistory != null); Debug.Assert(oPen != null); AssertValid(); // Note: Don't attempt to draw an arrow in this case. // Create a list of intermediate points, excluding those that fall // within the vertex bounds. An edge always terminates on the vertex // bounds, so we don't want it venturing into the vertex itself. List<Point> oCurvePoints = FilterIntermediatePoints(oEdge, oVertex1DrawingHistory, oVertex2DrawingHistory); Int32 iCurvePoints = oCurvePoints.Count; if (iCurvePoints == 0) { // Just draw a straight line. oDrawingContext.DrawLine(oPen, oEdgeEndpoint1, oEdgeEndpoint2); return; } #if false // Draw intermediate points for testing. foreach (Point oPoint in oCurvePoints) { oDrawingContext.DrawEllipse(Brushes.Green, null, oPoint, 2, 2); } #endif // The endpoints were originally calculated as if the edge was a // straight line between the two vertices. Recalculate them so they // connect more smoothly to the adjacent intermediate curve points. oVertex1DrawingHistory.GetEdgeEndpoint(oCurvePoints[0], out oEdgeEndpoint1); oVertex2DrawingHistory.GetEdgeEndpoint(oCurvePoints[iCurvePoints - 1], out oEdgeEndpoint2); oCurvePoints.Insert(0, oEdgeEndpoint1); oCurvePoints.Add(oEdgeEndpoint2); PathGeometry oCurveThroughPoints = WpfPathGeometryUtil.GetCurveThroughPoints(oCurvePoints, 0.5, CurveThroughIntermediatePointsTolerance); oDrawingContext.DrawGeometry(null, oPen, oCurveThroughPoints); // Note: Don't attempt to draw a label in this case. }