Ejemplo n.º 1
0
        TryDrawSelfLoop
        (
            IVertex oVertex,
            DrawingContext oDrawingContext,
            GraphDrawingContext oGraphDrawingContext,
            Color oColor,
            Double dWidth,
            Boolean bDrawArrow
        )
        {
            Debug.Assert(oVertex != null);
            Debug.Assert(oDrawingContext != null);
            Debug.Assert(oGraphDrawingContext != null);
            Debug.Assert(dWidth >= 0);
            AssertValid();

            // Retrieve the information about how the vertex was drawn.

            VertexDrawingHistory oVertexDrawingHistory;

            if (!oGraphDrawingContext.VertexDrawingHistories.TryGetValue(
                    oVertex.ID, out oVertexDrawingHistory))
            {
                // The edge's vertex is hidden, so the edge should be hidden also.

                return(false);
            }

            // Determine the edge of the graph rectangle that is farthest from the
            // vertex.

            Point oVertexLocation = oVertexDrawingHistory.VertexLocation;

            RectangleEdge eFarthestGraphRectangleEdge =
                WpfGraphicsUtil.GetFarthestRectangleEdge(oVertexLocation,
                                                         oGraphDrawingContext.GraphRectangle);

            // Get the point on the vertex at which to draw the self-loop.

            Point oSelfLoopEndpoint = oVertexDrawingHistory.GetSelfLoopEndpoint(
                eFarthestGraphRectangleEdge);

            DrawSelfLoopAt(oDrawingContext, oGraphDrawingContext, oColor, dWidth,
                           oSelfLoopEndpoint, eFarthestGraphRectangleEdge, bDrawArrow);

            return(true);
        }