public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != 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); if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null) { AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annIntersectionPointObject.Stroke.StrokeThickness); stroke.StrokeDashArray = new double[] { 3, 1, 1, 1, 1, 1 }; // DashDotDot IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity); try { if (leadPoints.Length > 2) { LeadPointD intersectionPoint = annIntersectionPointObject.IntersectionPoint; intersectionPoint = mapper.PointFromContainerCoordinates(intersectionPoint, annIntersectionPointObject.FixedStateOperations); double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations); DrawPoint(annIntersectionPointObject, engine, intersectionPoint, radius); if (leadPoints.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer) { engine.DrawLine(pen, leadPoints[3], intersectionPoint); } } } finally { engine.Destroy(pen); } } } } }
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); } } } } } } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != 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); IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity); try { for (int i = 0; i < linesCount; ++i) { LeadPointD firstPoint = leadPoints[2 * i]; LeadPointD secondPoint = leadPoints[2 * i + 1]; engine.DrawLine(pen, firstPoint, secondPoint); } } finally { engine.Destroy(pen); } } } } }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != null) { int count = annObject.Points.Count / 2; if (count > 1) { LeadPointD[] tmpPoints = mapper.PointsFromContainerCoordinates(annObject.Points.ToArray(), annObject.FixedStateOperations); if (annObject.SupportsStroke && annObject.Stroke != null) { IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity); try { for (int i = 0; i < count; i++) { int index = 2 * i; engine.DrawLine(pen, tmpPoints[index], tmpPoints[index + 1]); } } finally { engine.Destroy(pen); } } } } }
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"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != null) { base.Render(mapper, annObject); AnnCobbAngleObject annCobbAngleObject = annObject as AnnCobbAngleObject; if (annCobbAngleObject != null) { int count = annCobbAngleObject.Points.Count; if (count < 2) { return; } LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annCobbAngleObject.Points.ToArray(), annCobbAngleObject.FixedStateOperations); if (annCobbAngleObject.SupportsStroke && annCobbAngleObject.Stroke != null) { AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annCobbAngleObject.Stroke.StrokeThickness); stroke.StrokeDashArray = new double[] { 4, 2, 2, 2, 2, 2 }; IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annCobbAngleObject.Stroke, annCobbAngleObject.FixedStateOperations), annCobbAngleObject.Opacity); try { if (leadPoints.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); engine.DrawLine(pen, firstPoint, intersectionPoint); engine.DrawLine(pen, secondPoint, intersectionPoint); //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); label.Text = angle; label.Foreground = AnnSolidColorBrush.Create("Blue"); label.OriginalPosition = cobbAngleData.IntersectionPoint; } } } } finally { engine.Destroy(pen); } } } } }
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; } } } } } } } }