Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Operator Architecture Refactoring/HeuristicLab.Visualization/LegendShape.cs @ 1554

Last change on this file since 1554 was 873, checked in by shofstad, 16 years ago

changes on LegendForm (#407)

File size: 1.5 KB
Line 
1using System.Collections.Generic;
2using System.Drawing;
3
4namespace HeuristicLab.Visualization {
5  public class LegendItem {
6    public LegendItem(string label, Color color) {
7      Label = label;
8      Color = color;
9    }
10
11    public string Label { get; set; }
12    public Color Color { get; set; }
13  }
14
15
16  public class LegendShape : IShape {
17    private readonly Color color;
18
19    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
20    private readonly RectangleD rect;
21
22    public LegendShape(double x1, double y1, double x2, double y2, double z, Color color) {
23      rect = new RectangleD(x1, y1, x2, y2);
24      Z = z;
25      this.color = color;
26    }
27
28    public double Z { get; set; }
29
30    #region IShape Members
31
32    public RectangleD BoundingBox {
33      get { return rect; }
34    }
35
36    public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
37      using (var pen = new Pen(color, 1))
38      using (Brush brush = new SolidBrush(color)) {
39        Rectangle screenRect = Transform.ToScreen(rect, viewport, clippingArea);
40
41        graphics.DrawRectangle(pen, screenRect);
42        graphics.FillRectangle(brush, screenRect);
43      }
44    }
45
46    #endregion
47
48    public void AddLegendItem(LegendItem item) {
49      legendItems.Add(item);
50    }
51
52    public void RemoveLegendItem(LegendItem item) {
53      legendItems.Remove(item);
54    }
55
56    public void ClearLegendItems() {
57      legendItems.Clear();
58    }
59  }
60}
Note: See TracBrowser for help on using the repository browser.