Free cookie consent management tool by TermsFeed Policy Generator

Changeset 982


Ignore:
Timestamp:
12/12/08 17:55:03 (16 years ago)
Author:
shofstad
Message:

Legend implemented (#407)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.Test/LegendForm.cs

    r872 r982  
    1616      LegendShape ls = new LegendShape(0, 0, 100, 100, 0, Color.White);
    1717      ls.AddLegendItem(new LegendItem("test", Color.Black));
     18      ls.AddLegendItem(new LegendItem("test2", Color.Red));
    1819
    1920      mainShape.AddShape(ls);
  • trunk/sources/HeuristicLab.Visualization/LegendShape.cs

    r873 r982  
    3535
    3636    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);
     37      int startY = 10;
     38      foreach (LegendItem i in legendItems) {
     39        using (Pen pen = new Pen(i.Color, 5)) {
     40          graphics.DrawLine(pen, 10, startY+10, 30, startY+10);
     41        }
     42        using (Brush brush = new SolidBrush(Color.Black)) {
     43          graphics.DrawString(i.Label, new Font("Arial", 12), brush, 35, startY);
     44        }
     45        startY += 15;
    4346      }
    4447    }
Note: See TracChangeset for help on using the changeset viewer.