MoveVertexIfNecessary
(
IVertex oVertex,
GraphDrawingContext oGraphDrawingContext,
CollapsedGroupDrawingManager oCollapsedGroupDrawingManager,
ref Rect oVertexBounds
)
{
Debug.Assert(oVertex != null);
Debug.Assert(oGraphDrawingContext != null);
Debug.Assert(oCollapsedGroupDrawingManager != null);
AssertValid();
if (!m_bLimitVerticesToBounds ||
oGraphDrawingContext.GraphRectangleMinusMarginIsEmpty)
{
// The vertex shouldn't be moved.
return;
}
// First, assume that this is a normal vertex and not a vertex that
// represents a collapsed group. Move the vertex bounds within the
// bounds of the graph rectangle's margin.
Rect oMovedVertexBounds = WpfGraphicsUtil.MoveRectangleWithinBounds(
oVertexBounds, oGraphDrawingContext.GraphRectangleMinusMargin,
false);
// If the vertex actually represents a collapsed group, move it further
// if necessary to accomodate the additional elements that
// CollapsedGroupmanager.PostDrawVertex() may draw on top of the
// vertex.
oCollapsedGroupDrawingManager.MoveVertexBoundsIfNecessary(
oGraphDrawingContext, m_dGraphScale, ref oMovedVertexBounds);
oVertex.Location = System.Drawing.PointF.Add( oVertex.Location,
new System.Drawing.SizeF(
(Single)(oMovedVertexBounds.X - oVertexBounds.X),
(Single)(oMovedVertexBounds.Y - oVertexBounds.Y)
) );
oVertexBounds = oMovedVertexBounds;
}