Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs @ 1380

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

Implemented multiple Y-Axes. A LineChart has several Y-Axes and each Y-Axis has several data rows. The same clipping area is set for all data rows belonging to a Y-Axis. (#433)

File size: 4.8 KB
RevLine 
[1195]1using System;
2using System.Collections.Generic;
3using System.Windows.Forms;
[1342]4using HeuristicLab.Visualization.Legend;
[1195]5
6namespace HeuristicLab.Visualization.Options {
7  public partial class OptionsDialog : Form {
[1242]8    private readonly IChartDataRowsModel model;
[1341]9    private readonly ViewSettings viewSettings;
[1195]10
[1341]11    public OptionsDialog(IChartDataRowsModel model) {
[1195]12      InitializeComponent();
[1337]13
[1242]14      this.model = model;
[1341]15      viewSettings = model.ViewSettings;
[1345]16
17      cbLegendPosition.Items.Add(LegendPosition.Top);
18      cbLegendPosition.Items.Add(LegendPosition.Bottom);
19      cbLegendPosition.Items.Add(LegendPosition.Left);
20      cbLegendPosition.Items.Add(LegendPosition.Right);
21
22      cbLegendPosition.SelectedItem = viewSettings.LegendPosition;
[1195]23    }
24
[1237]25    private void OptionsDialogSelectColorBtn_Click(object sender, EventArgs e) {
[1233]26      ColorDialog dlg = new ColorDialog();
[1195]27      dlg.ShowDialog();
[1237]28      ColorPreviewTB.BackColor = dlg.Color;
[1195]29    }
30
31    public IList<int> GetThicknesses() {
[1343]32      return new List<int>(new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8});
[1195]33    }
34
35    public IList<DrawingStyle> GetStyles() {
[1343]36      return new List<DrawingStyle>(new DrawingStyle[] {DrawingStyle.Solid, DrawingStyle.Dashed});
[1195]37    }
38
39    private void OptionsDialog_Load(object sender, EventArgs e) {
[1242]40      if (model.Rows.Count != 0) {
41        LineSelectCB.DataSource = model.Rows;
[1237]42        LineSelectCB.DisplayMember = "Label";
[1195]43
[1237]44        LineThicknessCB.DataSource = GetThicknesses();
45        LinestyleCB.DataSource = GetStyles();
46        LineSelectCB.SelectedIndex = 0;
47        LineSelectCB_SelectedIndexChanged(this, null);
48      }
[1343]49
50      InitTabPageYAxes();
[1195]51    }
52
[1343]53    private void InitTabPageYAxes() {
[1350]54      for (int i = 0; i < model.YAxes.Count; i++) {
55        YAxisDescriptor yAxisDescriptor = model.YAxes[i];
[1343]56
57        CheckBox chkbox = new CheckBox();
[1350]58        chkbox.Text = yAxisDescriptor.Label;
59        chkbox.Checked = yAxisDescriptor.ShowYAxis;
60        chkbox.CheckedChanged += delegate { yAxisDescriptor.ShowYAxis = chkbox.Checked; };
[1343]61       
62        dataRowsFlowLayout.Controls.Add(chkbox);
63      }
64    }
65
[1195]66    private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) {
[1237]67      if (LineSelectCB.SelectedValue != null) {
68        int index =
[1328]69          LineThicknessCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Thickness.ToString());
[1237]70        LineThicknessCB.SelectedIndex = index;
[1328]71        index = LinestyleCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Style.ToString());
[1237]72        LinestyleCB.SelectedIndex = index;
[1328]73        ColorPreviewTB.BackColor = ((IDataRow)LineSelectCB.SelectedValue).Color;
[1237]74      }
[1195]75    }
76
77    private void OptionsDialogCancelButton_Click(object sender, EventArgs e) {
[1237]78      Close();
[1195]79    }
80
81    private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
[1328]82      ApplyChanges();
83
[1237]84      Close();
85    }
[1233]86
[1237]87    private void OptionsDialogApplyBtn_Click(object sender, EventArgs e) {
[1328]88      ApplyChanges(); 
89    }
90
91    private void ApplyChanges() {
[1237]92      if (LineSelectCB.SelectedValue != null) {
[1328]93        ((IDataRow)LineSelectCB.SelectedValue).Thickness = (int)LineThicknessCB.SelectedItem;
94        ((IDataRow)LineSelectCB.SelectedValue).Color = ColorPreviewTB.BackColor;
95        ((IDataRow)LineSelectCB.SelectedValue).Style = (DrawingStyle)LinestyleCB.SelectedItem;
[1237]96      }
[1195]97    }
[1328]98
[1342]99    private void cbLegendPosition_SelectedIndexChanged(object sender, EventArgs e) {
[1345]100      viewSettings.LegendPosition = (LegendPosition)cbLegendPosition.SelectedItem;
[1342]101      viewSettings.UpdateView();
102    }
103
[1328]104    private void btnChangeTitleFont_Click(object sender, EventArgs e) {
[1341]105      fdFont.Font = viewSettings.TitleFont;
106      fdFont.Color = viewSettings.TitleColor;
[1328]107
108      DialogResult dr = fdFont.ShowDialog();
109
110      if(dr == DialogResult.OK) {
[1341]111        viewSettings.TitleFont = fdFont.Font;
112        viewSettings.TitleColor = fdFont.Color;
[1337]113
[1341]114        viewSettings.UpdateView();
[1328]115      }
116    }
117
118    private void btnChangeLegendFont_Click(object sender, EventArgs e) {
[1341]119      fdFont.Font = viewSettings.LegendFont;
120      fdFont.Color = viewSettings.LegendColor;
[1328]121
122      DialogResult dr = fdFont.ShowDialog();
123
124      if (dr == DialogResult.OK) {
[1341]125        viewSettings.LegendFont = fdFont.Font;
126        viewSettings.LegendColor = fdFont.Color;
[1337]127
[1341]128        viewSettings.UpdateView();
[1328]129      }
130    }
[1337]131
132    private void btnChangeXAxisFont_Click(object sender, EventArgs e) {
[1341]133      fdFont.Font = viewSettings.XAxisFont;
134      fdFont.Color = viewSettings.XAxisColor;
[1337]135
136      DialogResult dr = fdFont.ShowDialog();
137
138      if (dr == DialogResult.OK) {
[1341]139        viewSettings.XAxisFont = fdFont.Font;
140        viewSettings.XAxisColor = fdFont.Color;
[1337]141
[1341]142        viewSettings.UpdateView();
[1337]143      }
144    }
[1195]145  }
[1342]146}
Note: See TracBrowser for help on using the repository browser.