Changeset 1233 for trunk/sources/HeuristicLab.Visualization/LineShape.cs
- Timestamp:
- 02/28/09 21:21:59 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LineShape.cs
r1187 r1233 5 5 public class LineShape : IShape { 6 6 private RectangleD boundingBox; 7 private double z; 7 8 8 private Color color; 9 9 private int thickness; 10 private DashStyle dashStyle; 10 private DrawingStyle drawingStyle; 11 12 private Pen pen; 11 13 12 14 /// <summary> … … 18 20 /// <param name="y2">y coordinate of right lineEndPoind</param> 19 21 /// <param name="color">color for the LineShape</param> 20 public LineShape(double x1, double y1, double x2, double y2, double z, Color color, int thickness, DrawingStyle style) { 22 /// <param name="thickness">tickness of the line in pixels</param> 23 /// <param name="drawingStyle">drawing style of the line (solid, dashed, dotted,...)</param> 24 public LineShape(double x1, double y1, double x2, double y2, Color color, int thickness, DrawingStyle drawingStyle) { 21 25 this.boundingBox = new RectangleD(x1, y1, x2, y2); 22 this.z = z;23 26 this.LSColor = color; 24 27 this.LSThickness = thickness; 25 if (style==DrawingStyle.Dashed) { 26 this.LSDashStyle = DashStyle.Dash; 27 } 28 else { 29 this.LSDashStyle = DashStyle.Solid; //default 30 } 28 this.LSDrawingStyle = drawingStyle; 31 29 } 32 30 … … 62 60 /// <param name="clippingArea">rectangle in screen-coordinates to draw</param> 63 61 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 64 using (Pen pen = new Pen(LSColor, LSThickness)){ 65 pen.DashStyle = this.LSDashStyle; 66 Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); 67 graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); 68 } 62 Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); 63 64 graphics.DrawLine(GetPen(), screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); 69 65 } 70 66 71 public double Z { 72 get { return z; } 73 set { z = value; } 67 private Pen GetPen() { 68 if (pen == null) { 69 pen = new Pen(LSColor, LSThickness); 70 71 switch (LSDrawingStyle) { 72 case DrawingStyle.Dashed: 73 pen.DashStyle = DashStyle.Dash; 74 break; 75 default: 76 pen.DashStyle = DashStyle.Solid; 77 break; 78 } 79 } 80 81 return pen; 82 } 83 84 private void DisposePen() { 85 if (pen != null) { 86 pen.Dispose(); 87 pen = null; 88 } 74 89 } 75 90 76 91 public Color LSColor { 77 92 get { return color; } 78 set { color = value; } 93 set { 94 color = value; 95 DisposePen(); 96 } 79 97 } 80 98 81 99 public int LSThickness { 82 100 get { return thickness; } 83 set { thickness = value; } 101 set { 102 thickness = value; 103 DisposePen(); 104 } 84 105 } 85 106 86 public DashStyle LSDashStyle { 87 get { return dashStyle; } 88 set { dashStyle = value; } 107 public DrawingStyle LSDrawingStyle { 108 get { return drawingStyle; } 109 set { 110 drawingStyle = value; 111 DisposePen(); 112 } 89 113 } 90 114 }
Note: See TracChangeset
for help on using the changeset viewer.