Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/RectangleShape.cs @ 984

Last change on this file since 984 was 984, checked in by bspisic, 16 years ago

#424
Implemented zooming

File size: 1.1 KB
Line 
1using System.Drawing;
2
3namespace HeuristicLab.Visualization {
4  public class RectangleShape : IShape {
5    private RectangleD rectangle;
6    private double z;
7    private Color color;
8    private int opacity = 100;
9
10    public RectangleShape(double x1, double y1, double x2, double y2, double z, Color color) {
11      rectangle = new RectangleD(x1, y1, x2, y2);
12      this.z = z;
13      this.color = color;
14    }
15
16    public RectangleD BoundingBox {
17      get { return rectangle; }
18    }
19
20    public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
21      Color brushColor = Color.FromArgb(50, color);
22
23      using (Pen pen = new Pen(color, 1))
24      using (Brush brush = new SolidBrush(brushColor)) {
25        Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea);
26
27        graphics.DrawRectangle(pen, screenRect);
28        graphics.FillRectangle(brush, screenRect);
29      }
30    }
31
32    public double Z {
33      get { return z; }
34      set { z = value; }
35    }
36
37    public RectangleD Rectangle {
38      get { return rectangle; }
39      set { rectangle = value; }
40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.