/// <summary> /// Draws a scope graph. /// </summary> private void DrawGraph(RectangleRange rectangleRange, ScopeGraph graph) { var lineType = graph.LineType; using (CreateContextState()) { ClipToRange(rectangleRange); switch (lineType) { case ScopeLineType.Dots: DrawGraph(rectangleRange, graph, ScopeLineType.Dots, _dotsGraphLineWidth); break; case ScopeLineType.LineAndDots: DrawGraph(rectangleRange, graph, ScopeLineType.Line, _reducedGraphLineWidth); DrawGraph(rectangleRange, graph, ScopeLineType.Dots, _dotsGraphLineWidth); break; default: DrawGraph(rectangleRange, graph, lineType, _graphStandardLineWidth); break; } } }
/// <summary> /// Draws a scope graph. /// </summary> private void DrawGraph(RectangleRange rectangleRange, ScopeGraph graph, ScopeLineType lineType, double lineWidth) { var userToDeviceMatrix = rectangleRange.Matrix; var vertices = graph.Vertices ?? new PointD[0]; var referencePoint = graph.ReferencePoint; var referencePointPosition = graph.ReferencePointPosition; var xScaleFactor = graph.XScaleFactor; var yScaleFactor = graph.YScaleFactor; var color = graph.Color; if (vertices.Any()) { using (CreateContextState()) { Context.SetSourceColor(color); // Create a new transformation matrix considering scale factors // and reference point position. var vertexMatrix = (Matrix)userToDeviceMatrix.Clone(); vertexMatrix.Translate(referencePointPosition.X, referencePointPosition.Y); vertexMatrix.Scale(xScaleFactor, yScaleFactor); vertexMatrix.Translate(-referencePoint.X, -referencePoint.Y); using (CreateContextState(vertexMatrix)) { Context.MoveTo(vertices.First()); foreach (var vertex in vertices) { if (lineType == ScopeLineType.Dots) { Context.MoveTo(vertex); } Context.LineTo(vertex); } } Context.LineWidth = lineWidth; if (lineType == ScopeLineType.Dots) { Context.LineCap = LineCap.Round; } Context.Stroke(); } } }