public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { base.Render(mapper, annObject); AnnMidlineObject annMidlineObject = annObject as AnnMidlineObject; if (annMidlineObject != null) { LeadPointD[] leadPoints = annMidlineObject.Points.ToArray(); int linesCount = leadPoints.Length / 2; if (linesCount > 0) { PointF[] linesCenters = new PointF[linesCount]; leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annMidlineObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); if (annMidlineObject.SupportsStroke && annMidlineObject.Stroke != null) { double radius = mapper.LengthFromContainerCoordinates(annMidlineObject.CenterPointRadius, annMidlineObject.FixedStateOperations); using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annMidlineObject.Stroke, annMidlineObject.FixedStateOperations), annMidlineObject.Opacity)) { for (int i = 0; i < linesCount; ++i) { PointF firstPoint = points[2 * i]; PointF secondPoint = points[2 * i + 1]; PointF center = new PointF((firstPoint.X + secondPoint.X) / 2, (firstPoint.Y + secondPoint.Y) / 2); DrawPoint(annMidlineObject, engine.Context, center, radius); linesCenters[i] = center; } if (linesCount > 1) { int count = linesCount - 1; for (int i = 0; i < count; ++i) { engine.Context.DrawLine(pen, linesCenters[i], linesCenters[i + 1]); // draw midline } } } } } } } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { LeadPointD[] leadPoints = annObject.Points.ToArray(); int linesCount = leadPoints.Length / 2; if (linesCount > 0) { if (annObject.SupportsStroke && annObject.Stroke != null) { leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity)) { for (int i = 0; i < linesCount; ++i) { if (_linesAsRulers) { AnnPolyRulerObject ruler = new AnnPolyRulerObject(); ruler.Stroke = annObject.Stroke.Clone(); ruler.TickMarksStroke = ruler.Stroke; ruler.Opacity = annObject.Opacity; ruler.FixedStateOperations = annObject.FixedStateOperations; ruler.Points.Clear(); ruler.Points.Add(annObject.Points[2 * i]); ruler.Points.Add(annObject.Points[2 * i + 1]); annObject.Labels["angle" + i.ToString()] = ruler.Labels["RulerLength"]; AnnPolyRulerObjectRenderer renderer = new AnnPolyRulerObjectRenderer(); renderer.Initialize(engine); renderer.Render(mapper, ruler); } else { engine.Context.DrawLine(pen, points[2 * i], points[2 * i + 1]); } } } } } } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { base.Render(mapper, annObject); AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject; if (annIntersectionPointObject != null) { int count = annIntersectionPointObject.Points.Count; if (count < 2) { return; } LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null) { using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annIntersectionPointObject.Stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity)) { if (points.Length > 2) { LeadPointD LeadIntersectionPoint = annIntersectionPointObject.IntersectionPoint; LeadIntersectionPoint = mapper.PointFromContainerCoordinates(LeadIntersectionPoint, annIntersectionPointObject.FixedStateOperations); PointF intersectionPoint = new PointF((float)LeadIntersectionPoint.X, (float)LeadIntersectionPoint.Y); double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations); DrawPoint(annIntersectionPointObject, engine.Context, intersectionPoint, radius); if (points.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer) { pen.Brush = Brushes.Blue; pen.DashStyle = DashStyle.DashDotDot; engine.Context.DrawLine(pen, points[3], intersectionPoint); } } } } } } }
private void DrawPoint(AnnMidlineObject annObject, Graphics context, PointF point, double radius) { LeadRectD pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2); LeadPointD topLeft = pointBounds.TopLeft; LeadPointD topRight = pointBounds.TopRight; LeadPointD bottomLeft = pointBounds.BottomLeft; LeadPointD bottomRight = pointBounds.BottomRight; using (Pen pen = AnnWinFormsRenderingEngine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity)) { context.DrawLine(pen, new PointF((float)topLeft.X, (float)topLeft.Y), new PointF((float)bottomRight.X, (float)bottomRight.Y)); context.DrawLine(pen, new PointF((float)bottomLeft.X, (float)bottomLeft.Y), new PointF((float)topRight.X, (float)topRight.Y)); context.DrawLine(pen, new PointF((float)point.X, (float)(point.Y - pointBounds.Width / 2)), new PointF((float)point.X, (float)(point.Y + pointBounds.Width / 2))); context.DrawLine(pen, new PointF((float)point.X - (float)pointBounds.Width / 2, (float)(point.Y)), new PointF((float)point.X + (float)pointBounds.Width / 2, (float)(point.Y))); } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { Graphics context = engine.Context; int count = annObject.Points.Count / 2; if (count > 1) { LeadPointD[] tmpPoints = mapper.PointsFromContainerCoordinates(annObject.Points.ToArray(), annObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(tmpPoints); if (annObject.SupportsStroke && annObject.Stroke != null) { using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity)) { for (int i = 0; i < count; i++) { int index = 2 * i; context.DrawLine(pen, points[index], points[index + 1]); } } } } } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { base.Render(mapper, annObject); AnnCobbAngleObject annCobbAngleObject = annObject as AnnCobbAngleObject; if (annCobbAngleObject != null) { base.LinesAsRulers = annCobbAngleObject.LinesAsRulers; int count = annCobbAngleObject.Points.Count; if (count < 2) { return; } LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annCobbAngleObject.Points.ToArray(), annCobbAngleObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); if (annCobbAngleObject.SupportsStroke && annCobbAngleObject.Stroke != null) { using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annCobbAngleObject.Stroke, annCobbAngleObject.FixedStateOperations), annCobbAngleObject.Opacity)) { if (points.Length > 3) { AnnCobbAngleData cobbAngleData = annCobbAngleObject.CobbAngleData; LeadPointD firstPoint = mapper.PointFromContainerCoordinates(cobbAngleData.FirstPoint, annCobbAngleObject.FixedStateOperations); LeadPointD secondPoint = mapper.PointFromContainerCoordinates(cobbAngleData.SecondPoint, annCobbAngleObject.FixedStateOperations); LeadPointD intersectionPoint = mapper.PointFromContainerCoordinates(cobbAngleData.IntersectionPoint, annCobbAngleObject.FixedStateOperations); pen.Brush = Brushes.Blue; pen.DashPattern = new float[] { 4, 2, 2, 2, 2, 2 }; engine.Context.DrawLine(pen, new PointF((float)firstPoint.X, (float)firstPoint.Y), new PointF((float)intersectionPoint.X, (float)intersectionPoint.Y)); engine.Context.DrawLine(pen, new PointF((float)secondPoint.X, (float)secondPoint.Y), new PointF((float)intersectionPoint.X, (float)intersectionPoint.Y)); //Draw angle label if (annCobbAngleObject.Labels.ContainsKey("CobbAngle")) { AnnLabel label = annCobbAngleObject.Labels["CobbAngle"]; if (label != null) { string precisionFormat = string.Format("XXX:F{0}", annCobbAngleObject.AnglePrecision); precisionFormat = precisionFormat.Replace("XXX", "{0"); precisionFormat = string.Format("{0}{1}", precisionFormat, "}"); string angle = string.Format(precisionFormat, cobbAngleData.Angle); angle = string.Format("{0} {1}", angle, "\u00B0"); label.Text = angle; label.Foreground = AnnSolidColorBrush.Create("White"); label.Background = AnnSolidColorBrush.Create("Blue"); label.OriginalPosition = cobbAngleData.IntersectionPoint; } } } } } } } }