using System.Drawing; using System.Drawing.Drawing2D; namespace HeuristicLab.Visualization { public class LineShape : IShape { private RectangleD boundingBox; private double z; private Color color; private int thickness; private DashStyle dashStyle; /// /// Initializes the LineShape. /// /// x coordinate of left lineEndPoind /// y coordinate of left lineEndPoind /// x coordinate of right lineEndPoind /// y coordinate of right lineEndPoind /// color for the LineShape public LineShape(double x1, double y1, double x2, double y2, double z, Color color, int thickness, DrawingStyle style) { this.boundingBox = new RectangleD(x1, y1, x2, y2); this.z = z; this.LSColor = color; this.LSThickness = thickness; if (style==DrawingStyle.Dashed) { this.LSDashStyle = DashStyle.Dash; } else { this.LSDashStyle = DashStyle.Solid; //default } } public RectangleD BoundingBox { get { return boundingBox; } } public double Y1 { get { return boundingBox.Y1; } set { boundingBox.Y1 = value; } } public double Y2 { get { return boundingBox.Y2; } set { boundingBox.Y2 = value; } } public double X1 { get { return boundingBox.X1; } set { boundingBox.X1 = value; } } public double X2 { get { return boundingBox.X2; } set { boundingBox.X2 = value; } } /// /// Draws the LineShape. /// /// graphics handle to draw to /// rectangle in value-coordinates to display /// rectangle in screen-coordinates to draw public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { using (Pen pen = new Pen(LSColor, LSThickness)){ pen.DashStyle = this.LSDashStyle; Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); } } public double Z { get { return z; } set { z = value; } } public Color LSColor { get { return color; } set { color = value; } } public int LSThickness { get { return thickness; } set { thickness = value; } } public DashStyle LSDashStyle { get { return dashStyle; } set { dashStyle = value; } } } }