public override void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double pixelScale) { Point startPoint = convertToDestination(StartPoint); Point endPoint = convertToDestination(EndPoint); double lenght = (int)Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2)); string text = string.Format("{0} mm", Math.Round(lenght / pixelScale, 0)); int width = 2; Pen pen = new Pen(this.Color, width); pen.Alignment = PenAlignment.Inset; pen.StartCap = LineCap.DiamondAnchor; pen.EndCap = LineCap.DiamondAnchor; g.DrawLine(pen, startPoint, endPoint); path = new GraphicsPath(); path.StartFigure(); path.AddLine(startPoint.X, startPoint.Y - width, startPoint.X + (int)lenght, startPoint.Y - width); path.AddLine(startPoint.X + (int)lenght, startPoint.Y - width, startPoint.X + (int)lenght, startPoint.Y + width); path.AddLine(startPoint.X + (int)lenght, startPoint.Y + width, startPoint.X, startPoint.Y + width); float cos = (float)(endPoint.X - startPoint.X) / (float)lenght; float arc = (float)(Math.Acos(cos) * (float)180 / Math.PI); if (endPoint.Y - startPoint.Y < 0) { arc = 360 - arc; } System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(); matrix.RotateAt(arc, startPoint); path.Transform(matrix); path.CloseFigure(); GraphicsPath pathString = new GraphicsPath(); pathString.StartFigure(); pathString.AddString(text, new FontFamily("Arial"), (int)FontStyle.Regular , 16, new PointF(startPoint.X + (int)lenght / 2 - 20, startPoint.Y - 30), StringFormat.GenericDefault); pathString.Transform(matrix); pathString.CloseFigure(); g.FillPath(new SolidBrush(this.Color), pathString); }
public override void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale) { Point point = convertToDestination(StartPoint); TextRenderer.DrawText(g, text, font, point, Color); path = new GraphicsPath(); path.StartFigure(); path.AddRectangle(new Rectangle(point, TextRenderer.MeasureText(text, font))); path.CloseFigure(); }
public void Repaint(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale) { if (this.Selected) { this.Color = CommonModule.colorSelectedElement; } Draw(g, convertToDestination, PixelScale); if (CommonModule.TEST_MODE) { g.DrawPath(new Pen(Brushes.Yellow), path); } }
public override void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale) { Point startPoint = convertToDestination(StartPoint); Point endPoint = convertToDestination(EndPoint); Pen pen = new Pen(this.Color, 2); pen.EndCap = LineCap.ArrowAnchor; Rectangle rect = new Rectangle(startPoint.X, startPoint.Y, endPoint.X - startPoint.X, endPoint.Y - startPoint.Y); g.DrawRectangle(pen, rect); path = new GraphicsPath(); path.StartFigure(); path.AddRectangle(rect); path.CloseFigure(); }
public override void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale) { Point startPoint = convertToDestination(StartPoint); Point endPoint = convertToDestination(EndPoint); int lenght = (int)Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2)); Width = 5; if (lenght > 50 && lenght < 150) { Width = lenght / 10; } else if (lenght > 100) { Width = 15; } Pen pen = new Pen(this.Color, Width); pen.EndCap = LineCap.ArrowAnchor; g.DrawLine(pen, startPoint, endPoint); path = new GraphicsPath(); path.StartFigure(); path.AddLine(startPoint.X, startPoint.Y - Width, startPoint.X + lenght, startPoint.Y - Width); path.AddLine(startPoint.X + lenght, startPoint.Y - Width, startPoint.X + lenght, startPoint.Y + Width); path.AddLine(startPoint.X + lenght, startPoint.Y + Width, startPoint.X, startPoint.Y + Width); float cos = (float)(endPoint.X - startPoint.X) / (float)lenght; float arc = (float)(Math.Acos(cos) * (float)180 / Math.PI); if (endPoint.Y - startPoint.Y < 0) { arc = 360 - arc; } System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(); matrix.RotateAt(arc, startPoint); path.Transform(matrix); path.CloseFigure(); }
public override void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale) { path = new GraphicsPath(); path.StartFigure(); if (points.Count > 2) { this.StartPoint = points[0]; for (int i = 0; i < points.Count - 1; i++) { path.AddLine(convertToDestination(points[i]), convertToDestination(points[i + 1])); } } if (closed) { path.CloseFigure(); } g.DrawPath(new Pen(new SolidBrush(this.Color), this.Width), path); }
public AnnotationManager(convertToDestinationDelegate ConvertToDestination, convertToOriginDelegate ConvertToOrigin) { this.ConvertToDestination = ConvertToDestination; this.ConvertToOrigin = ConvertToOrigin; }
public abstract void Draw(Graphics g, convertToDestinationDelegate convertToDestination, double PixelScale);