Free cookie consent management tool by TermsFeed Policy Generator

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

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

#424
RectangleShape -> Opacity property added

File size: 1.2 KB
RevLine 
[635]1using System.Drawing;
2
3namespace HeuristicLab.Visualization {
4  public class RectangleShape : IShape {
[984]5    private RectangleD rectangle;
[635]6    private double z;
7    private Color color;
[996]8    private int opacity = 255;
[635]9
10    public RectangleShape(double x1, double y1, double x2, double y2, double z, Color color) {
[984]11      rectangle = new RectangleD(x1, y1, x2, y2);
[635]12      this.z = z;
13      this.color = color;
14    }
15
16    public RectangleD BoundingBox {
[984]17      get { return rectangle; }
[635]18    }
19
20    public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
[996]21      Color brushColor = Color.FromArgb(opacity, color);
[984]22
[635]23      using (Pen pen = new Pen(color, 1))
[984]24      using (Brush brush = new SolidBrush(brushColor)) {
25        Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea);
[635]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    }
[984]36
[996]37    public int Opacity {
38      get { return opacity; }
39      set { opacity = value; }
40    }
41
[984]42    public RectangleD Rectangle {
43      get { return rectangle; }
44      set { rectangle = value; }
45    }
[635]46  }
[984]47}
Note: See TracBrowser for help on using the repository browser.