Index: trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs	(revision 1342)
@@ -311,11 +311,23 @@
       IDataRow row3 = new DataRow();
 
+      IDataRow row4 = new DataRow();
+      IDataRow row5 = new DataRow();
+      IDataRow row6 = new DataRow();
+
       row1.Color = Color.Red;
       row2.Color = Color.Green;
       row3.Color = Color.Blue;
 
+      row4.Color = Color.DeepPink;
+      row5.Color = Color.Firebrick;
+      row6.Color = Color.DarkSlateGray;
+
       row1.Thickness = 3;
       row2.Thickness = 4;
       row3.Thickness = 5;
+
+      row4.Thickness = 3;
+      row5.Thickness = 4;
+      row6.Thickness = 5;
 
       row1.Label = "SingleValue";
@@ -323,7 +335,15 @@
       row3.Label = "Maxi";
 
+      row4.Label = "Simon";
+      row5.Label = "klausmuellerwesternhagenunddierasperies";
+      row6.Label = "anyways";
+
       row1.Style = DrawingStyle.Solid;
       row2.Style = DrawingStyle.Solid;
       row3.Style = DrawingStyle.Dashed;
+
+      row4.Style = DrawingStyle.Solid;
+      row5.Style = DrawingStyle.Solid;
+      row6.Style = DrawingStyle.Dashed;
 
       row1.LineType = DataRowType.SingleValue;
@@ -331,10 +351,4 @@
       row1.AddValue(12);
 
-      model.AddDataRow(row1);
-      model.AddDataRow(row2);
-      model.AddDataRow(row3);
-
-      
-     
       row2.AddValue(5);
      
@@ -347,5 +361,14 @@
 
 
-    
+      row4.AddValue(10);
+      row5.AddValue(11);
+      row6.AddValue(11);
+
+      model.AddDataRow(row1);
+      model.AddDataRow(row2);
+      model.AddDataRow(row3);
+      model.AddDataRow(row4);
+      model.AddDataRow(row5);
+      model.AddDataRow(row6);
 
       f.ShowDialog();
Index: trunk/sources/HeuristicLab.Visualization/Legend/LegendItem.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/Legend/LegendItem.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/Legend/LegendItem.cs	(revision 1342)
@@ -3,4 +3,7 @@
 namespace HeuristicLab.Visualization.Legend {
   public class LegendItem {
+
+    public static readonly int WIDTH = 100;
+
     public LegendItem(string label, Color color, int thickness) {
       Label = label;
Index: trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs	(revision 1342)
@@ -1,8 +1,20 @@
+using System;
 using System.Collections.Generic;
 using System.Drawing;
 
 namespace HeuristicLab.Visualization.Legend {
+  public enum LegendPosition {
+    Top,
+    Bottom,
+    Left,
+    Right
+  }
+
   public class LegendShape : WorldShape {
     private readonly IList<LegendItem> legendItems = new List<LegendItem>();
+    // legend draw default value: column
+    private bool row;
+    private bool top;
+
 
     private Color color = Color.Blue;
@@ -13,12 +25,67 @@
     }
 
+    public bool Row {
+      set { row = value; }
+      get { return row; }
+    }
+
+    public bool Top {
+      set { top = value; }
+      get { return top; }
+    }
+
     public void CreateLegend() {
       ClearShapes();
+      double x = ClippingArea.X1;
       double y = ClippingArea.Y2;
+      int numberOfItemsPerRow = 0;
+      int rowCounter = 0;
+      int rowsToDraw = 1;
+      if (row) {
+        numberOfItemsPerRow = (int)ClippingArea.Width/LegendItem.WIDTH;
+        int nrOfItems = legendItems.Count;
+        if (nrOfItems > numberOfItemsPerRow) {
+          int rest;
+          int value = Math.DivRem(nrOfItems, numberOfItemsPerRow, out rest);
+          rowsToDraw = value + rest;
+        }
+        if (!top)
+          y = 25*rowsToDraw;
+      }
       foreach (LegendItem item in legendItems) {
-        AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
-        AddShape(new TextShape(35, y, item.Label, font, color));
-        y -= 15;
+        if (!row) {
+          CreateColumn(item, y);
+          y -= 15;
+        } else {
+          if (rowCounter >= numberOfItemsPerRow) {
+            x = ClippingArea.X1;
+            y -= 25;
+          }
+          CreateRow(item, x, y);
+          x += LegendItem.WIDTH;
+          rowCounter++;
+        }
       }
+    }
+
+    /// <summary>
+    /// draws the legend as a row at the top or bottom of the WorldShape
+    /// </summary>
+    /// <param name="item"></param>
+    /// <param name="x"></param>
+    /// <param name="y"></param>
+    private void CreateRow(LegendItem item, double x, double y) {
+      AddShape(new LineShape(x, y - 10, x + 20, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
+      AddShape(new TextShape(x + 25, y, item.Label, Font, Color));
+    }
+
+    /// <summary>
+    /// draws the legend as a column on the right or left side of the WorldShape
+    /// </summary>
+    /// <param name="item"></param>
+    /// <param name="y"></param>
+    private void CreateColumn(LegendItem item, double y) {
+      AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
+      AddShape(new TextShape(35, y, item.Label, Font, Color));
     }
 
Index: trunk/sources/HeuristicLab.Visualization/LineChart.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/LineChart.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/LineChart.cs	(revision 1342)
@@ -52,5 +52,5 @@
       this.model = model;
       viewSettings = model.ViewSettings;
-      viewSettings.OnUpdateSettings += UpdateViewProperties;
+      viewSettings.OnUpdateSettings += UpdateViewSettings;
 
       Item = model;
@@ -62,5 +62,5 @@
     }
 
-    private void UpdateViewProperties() {
+    private void UpdateViewSettings() {
       titleShape.Font = viewSettings.TitleFont;
       titleShape.Color = viewSettings.TitleColor;
@@ -71,4 +71,22 @@
       xAxis.Font = viewSettings.XAxisFont;
       xAxis.Color = viewSettings.XAxisColor;
+
+      switch (viewSettings.LegendPosition) {
+          case LegendPosition.Bottom:
+            setLegendBottom();
+            break;
+
+          case LegendPosition.Top:
+            setLegendTop();
+            break;
+
+          case LegendPosition.Left:
+            setLegendLeft();
+            break;
+
+          case LegendPosition.Right:
+            setLegendRight();
+            break;
+      }
 
       canvasUI.Invalidate();
@@ -138,14 +156,48 @@
                                          linesAreaBoundingBox.Y1);
 
+      setLegendBottom();
+    }
+
+    public void setLegendRight() {
+      // legend right
+      legendShape.BoundingBox = new RectangleD(canvasUI.Width - 110, 10, canvasUI.Width, canvasUI.Height - 50);
+      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
+      legendShape.Row = false;
+      legendShape.CreateLegend();
+    }
+
+    public void setLegendLeft() {
+      // legend left
       legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50);
-      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width,
-                                                legendShape.BoundingBox.Height);
-
-      canvasUI.Invalidate();
+      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
+      legendShape.Row = false;
+      legendShape.CreateLegend();
+
+      canvasUI.Invalidate();
+    }
+
+    public void setLegendTop() {
+      // legend top
+      legendShape.BoundingBox = new RectangleD(100, canvasUI.Height - canvasUI.Height, canvasUI.Width, canvasUI.Height - 10);
+      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
+      legendShape.Row = true;
+      legendShape.Top = true;
+      legendShape.CreateLegend();
+    }
+
+    public void setLegendBottom() {
+      // legend bottom
+      legendShape.BoundingBox = new RectangleD(100, 10, canvasUI.Width, 200);
+      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
+      legendShape.Row = true;
+      legendShape.Top = false;
+      legendShape.CreateLegend();
     }
 
     private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
       OptionsDialog optionsdlg = new OptionsDialog(model);
+      //var optionsdlg = new OptionsDialog(model, this);
       optionsdlg.ShowDialog(this);
+      Invalidate();
     }
 
Index: trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs	(revision 1342)
@@ -32,6 +32,6 @@
       this.tabPage2 = new System.Windows.Forms.TabPage();
       this.btnChangeLegendFont = new System.Windows.Forms.Button();
-      this.labelposition = new System.Windows.Forms.Label();
-      this.cbLabelPosition = new System.Windows.Forms.ComboBox();
+      this.legendposition = new System.Windows.Forms.Label();
+      this.cbLegendPosition = new System.Windows.Forms.ComboBox();
       this.tabPage1 = new System.Windows.Forms.TabPage();
       this.OptionsDialogSelectColorBt = new System.Windows.Forms.Button();
@@ -113,6 +113,6 @@
       // 
       this.tabPage2.Controls.Add(this.btnChangeLegendFont);
-      this.tabPage2.Controls.Add(this.labelposition);
-      this.tabPage2.Controls.Add(this.cbLabelPosition);
+      this.tabPage2.Controls.Add(this.legendposition);
+      this.tabPage2.Controls.Add(this.cbLegendPosition);
       this.tabPage2.Location = new System.Drawing.Point(4, 22);
       this.tabPage2.Name = "tabPage2";
@@ -133,26 +133,27 @@
       this.btnChangeLegendFont.Click += new System.EventHandler(this.btnChangeLegendFont_Click);
       // 
-      // labelposition
-      // 
-      this.labelposition.AutoSize = true;
-      this.labelposition.Location = new System.Drawing.Point(3, 47);
-      this.labelposition.Name = "labelposition";
-      this.labelposition.Size = new System.Drawing.Size(72, 13);
-      this.labelposition.TabIndex = 1;
-      this.labelposition.Text = "Labelposition:";
-      // 
-      // cbLabelPosition
-      // 
-      this.cbLabelPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-      this.cbLabelPosition.FormattingEnabled = true;
-      this.cbLabelPosition.Items.AddRange(new object[] {
+      // legendposition
+      // 
+      this.legendposition.AutoSize = true;
+      this.legendposition.Location = new System.Drawing.Point(8, 38);
+      this.legendposition.Name = "legendposition";
+      this.legendposition.Size = new System.Drawing.Size(82, 13);
+      this.legendposition.TabIndex = 1;
+      this.legendposition.Text = "Legendposition:";
+      // 
+      // cbLegendPosition
+      // 
+      this.cbLegendPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.cbLegendPosition.FormattingEnabled = true;
+      this.cbLegendPosition.Items.AddRange(new object[] {
             "left",
             "right",
             "top",
             "bottom"});
-      this.cbLabelPosition.Location = new System.Drawing.Point(81, 44);
-      this.cbLabelPosition.Name = "cbLabelPosition";
-      this.cbLabelPosition.Size = new System.Drawing.Size(121, 21);
-      this.cbLabelPosition.TabIndex = 0;
+      this.cbLegendPosition.Location = new System.Drawing.Point(96, 35);
+      this.cbLegendPosition.Name = "cbLegendPosition";
+      this.cbLegendPosition.Size = new System.Drawing.Size(121, 21);
+      this.cbLegendPosition.TabIndex = 0;
+      this.cbLegendPosition.SelectedIndexChanged += new System.EventHandler(this.cbLegendPosition_SelectedIndexChanged);
       // 
       // tabPage1
@@ -335,6 +336,4 @@
     private System.Windows.Forms.Button btnChangeTitleFont;
     private System.Windows.Forms.TabPage tabPage2;
-    private System.Windows.Forms.Label labelposition;
-    private System.Windows.Forms.ComboBox cbLabelPosition;
     private System.Windows.Forms.TabPage tabPage1;
     private System.Windows.Forms.Button OptionsDialogSelectColorBt;
@@ -346,4 +345,6 @@
     private System.Windows.Forms.GroupBox groupBox1;
     private System.Windows.Forms.Label label4;
+    private System.Windows.Forms.ComboBox cbLegendPosition;
+    private System.Windows.Forms.Label legendposition;
     private System.Windows.Forms.ComboBox LineThicknessCB;
     private System.Windows.Forms.Label label3;
Index: trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs	(revision 1342)
@@ -2,4 +2,5 @@
 using System.Collections.Generic;
 using System.Windows.Forms;
+using HeuristicLab.Visualization.Legend;
 
 namespace HeuristicLab.Visualization.Options {
@@ -74,4 +75,19 @@
     }
 
+    private void cbLegendPosition_SelectedIndexChanged(object sender, EventArgs e) {
+      string pos = cbLegendPosition.SelectedItem.ToString();
+      if (pos.Equals("left")) {
+        viewSettings.LegendPosition = LegendPosition.Left;
+      } else if (pos.Equals("right")) {
+        viewSettings.LegendPosition = LegendPosition.Right;
+      } else if (pos.Equals("bottom")) {
+        viewSettings.LegendPosition = LegendPosition.Bottom;
+      } else {
+        viewSettings.LegendPosition = LegendPosition.Top;
+      }
+      
+      viewSettings.UpdateView();
+    }
+
     private void btnChangeTitleFont_Click(object sender, EventArgs e) {
       fdFont.Font = viewSettings.TitleFont;
Index: trunk/sources/HeuristicLab.Visualization/Options/ViewSettings.cs
===================================================================
--- trunk/sources/HeuristicLab.Visualization/Options/ViewSettings.cs	(revision 1341)
+++ trunk/sources/HeuristicLab.Visualization/Options/ViewSettings.cs	(revision 1342)
@@ -1,3 +1,4 @@
 using System.Drawing;
+using HeuristicLab.Visualization.Legend;
 
 namespace HeuristicLab.Visualization.Options {
@@ -11,4 +12,5 @@
     private Font xAxisFont;
     private Color xAxisColor;
+    private LegendPosition legendPosition;
 
     public ViewSettings() {
@@ -21,4 +23,6 @@
       xAxisFont = new Font("Arial", 8);
       xAxisColor = Color.Blue;
+
+      legendPosition = LegendPosition.Left;
     }
 
@@ -58,4 +62,9 @@
       set { xAxisColor = value; }
     }
+
+    public LegendPosition LegendPosition {
+      get { return legendPosition; }
+      set { legendPosition = value; }
+    }
   }
 
