Line | |
---|
1 | using System.Drawing;
|
---|
2 |
|
---|
3 | namespace 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.