Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/LegendShape.cs @ 1232

Last change on this file since 1232 was 1232, checked in by mstoeger, 16 years ago

Fixed a major blocking problem in LegendShape. (#407)

File size: 1.2 KB
RevLine 
[873]1using System.Collections.Generic;
[866]2using System.Drawing;
3
4namespace HeuristicLab.Visualization {
[873]5  public class LegendItem {
[1049]6    public LegendItem(string label, Color color, int thickness) {
[873]7      Label = label;
8      Color = color;
[1049]9      Thickness = thickness;
[873]10    }
11
12    public string Label { get; set; }
13    public Color Color { get; set; }
[1049]14    public int Thickness { get; set; }
[873]15  }
16
17
[1195]18  public class LegendShape : WorldShape {
[873]19    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
[1195]20   
21    public LegendShape() {
[1049]22      CreateLegend();
[866]23    }
24
[1049]25    public void CreateLegend() {
[1195]26      shapes.Clear();
[1232]27      double y = ClippingArea.Y2;
[1049]28      foreach (LegendItem item in legendItems) {
29        AddShape(new LineShape(10, y - 10, 30, y - 10, 0, item.Color, item.Thickness, DrawingStyle.Solid));
30        AddShape(new TextShape(35, y, item.Label));
31        y -= 15;
[866]32      }
33    }
34
[873]35    public void AddLegendItem(LegendItem item) {
36      legendItems.Add(item);
37    }
38
39    public void RemoveLegendItem(LegendItem item) {
40      legendItems.Remove(item);
41    }
42
43    public void ClearLegendItems() {
44      legendItems.Clear();
45    }
[866]46  }
47}
Note: See TracBrowser for help on using the repository browser.