Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/13/09 19:07:53 (15 years ago)
Author:
shofstad
Message:

Legend implementation updated with position setting (#407)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1341 r1342  
    5252      this.model = model;
    5353      viewSettings = model.ViewSettings;
    54       viewSettings.OnUpdateSettings += UpdateViewProperties;
     54      viewSettings.OnUpdateSettings += UpdateViewSettings;
    5555
    5656      Item = model;
     
    6262    }
    6363
    64     private void UpdateViewProperties() {
     64    private void UpdateViewSettings() {
    6565      titleShape.Font = viewSettings.TitleFont;
    6666      titleShape.Color = viewSettings.TitleColor;
     
    7171      xAxis.Font = viewSettings.XAxisFont;
    7272      xAxis.Color = viewSettings.XAxisColor;
     73
     74      switch (viewSettings.LegendPosition) {
     75          case LegendPosition.Bottom:
     76            setLegendBottom();
     77            break;
     78
     79          case LegendPosition.Top:
     80            setLegendTop();
     81            break;
     82
     83          case LegendPosition.Left:
     84            setLegendLeft();
     85            break;
     86
     87          case LegendPosition.Right:
     88            setLegendRight();
     89            break;
     90      }
    7391
    7492      canvasUI.Invalidate();
     
    138156                                         linesAreaBoundingBox.Y1);
    139157
     158      setLegendBottom();
     159    }
     160
     161    public void setLegendRight() {
     162      // legend right
     163      legendShape.BoundingBox = new RectangleD(canvasUI.Width - 110, 10, canvasUI.Width, canvasUI.Height - 50);
     164      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
     165      legendShape.Row = false;
     166      legendShape.CreateLegend();
     167    }
     168
     169    public void setLegendLeft() {
     170      // legend left
    140171      legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50);
    141       legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width,
    142                                                 legendShape.BoundingBox.Height);
    143 
    144       canvasUI.Invalidate();
     172      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
     173      legendShape.Row = false;
     174      legendShape.CreateLegend();
     175
     176      canvasUI.Invalidate();
     177    }
     178
     179    public void setLegendTop() {
     180      // legend top
     181      legendShape.BoundingBox = new RectangleD(100, canvasUI.Height - canvasUI.Height, canvasUI.Width, canvasUI.Height - 10);
     182      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
     183      legendShape.Row = true;
     184      legendShape.Top = true;
     185      legendShape.CreateLegend();
     186    }
     187
     188    public void setLegendBottom() {
     189      // legend bottom
     190      legendShape.BoundingBox = new RectangleD(100, 10, canvasUI.Width, 200);
     191      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
     192      legendShape.Row = true;
     193      legendShape.Top = false;
     194      legendShape.CreateLegend();
    145195    }
    146196
    147197    private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
    148198      OptionsDialog optionsdlg = new OptionsDialog(model);
     199      //var optionsdlg = new OptionsDialog(model, this);
    149200      optionsdlg.ShowDialog(this);
     201      Invalidate();
    150202    }
    151203
Note: See TracChangeset for help on using the changeset viewer.