CreateVisual
(
Point currentMouseLocation,
Color backColor,
VertexDrawer vertexDrawer
)
{
Debug.Assert(vertexDrawer != null);
Debug.Assert(m_bDragIsInProgress);
AssertValid();
// This method redraws the dragged vertices at an offset location, and
// adds the resulting Visuals to a ContainerVisual.
//
// Figure out the offset.
Double dOffsetX = currentMouseLocation.X - m_oMouseDownLocation.X;
Double dOffsetY = currentMouseLocation.Y - m_oMouseDownLocation.Y;
GraphDrawingContext oGraphDrawingContext = new GraphDrawingContext(
m_oGraphRectangle, m_iMargin, backColor);
ContainerVisual oContainerVisual = new ContainerVisual();
foreach (IVertex oVertex in m_aoVertices)
{
System.Drawing.PointF oOriginalLocation =
GetOriginalVertexLocation(oVertex);
oVertex.Location = new System.Drawing.PointF(
oOriginalLocation.X + (Single)dOffsetX,
oOriginalLocation.Y + (Single)dOffsetY
);
VertexDrawingHistory oVertexDrawingHistory;
if ( vertexDrawer.TryDrawVertex(oVertex, oGraphDrawingContext,
out oVertexDrawingHistory) )
{
oContainerVisual.Children.Add(
oVertexDrawingHistory.DrawingVisual);
}
}
m_oVisual = oContainerVisual;
return (m_oVisual);
}