Free cookie consent management tool by TermsFeed Policy Generator

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

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

General housekeeping (#498) Removed some old unused Z-Order values. Replaced some var types by concrete types. Renamed some LineShape properties. Added caching of Pens and Brushes in LineShape and RectangleShape. Put axis tick calculation algorithm into its own class.

File size: 2.1 KB
RevLine 
[1195]1using System;
2using System.Collections.Generic;
3using System.Windows.Forms;
4
5namespace HeuristicLab.Visualization.Options {
6  public partial class OptionsDialog : Form {
7    private LineChart lc;
8
9    public OptionsDialog(LineChart lc) {
10      InitializeComponent();
11      this.lc = lc;
12    }
13
14    private void button1_Click(object sender, EventArgs e) {
[1233]15      ColorDialog dlg = new ColorDialog();
[1195]16      dlg.ShowDialog();
17      this.ColorPreviewTB.BackColor = dlg.Color;
18    }
19
20    public IList<int> GetThicknesses() {
21      return new List<int>() {0, 1, 2, 3, 4, 5, 6, 7, 8};
22    }
23
24    public IList<DrawingStyle> GetStyles() {
25      return new List<DrawingStyle>() {DrawingStyle.Solid, DrawingStyle.Dashed};
26    }
27
28    private void OptionsDialog_Load(object sender, EventArgs e) {
29      this.LineSelectCB.DataSource = lc.GetRows();
30      this.LineSelectCB.DisplayMember = "Label";
31
32      LineThicknessCB.DataSource = GetThicknesses();
33      LinestyleCB.DataSource = GetStyles();
34      LineSelectCB.SelectedIndex = 0;
35      LineSelectCB_SelectedIndexChanged(this, null);
36    }
37
38    private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) {
[1233]39      IDataRow datarow = (IDataRow)this.LineSelectCB.SelectedValue;
40
41      int index = this.LineThicknessCB.FindStringExact(datarow.Thickness.ToString());
[1195]42      this.LineThicknessCB.SelectedIndex = index;
[1233]43      index = this.LinestyleCB.FindStringExact(datarow.Style.ToString());
[1195]44      LinestyleCB.SelectedIndex = index;
[1233]45      this.ColorPreviewTB.BackColor = datarow.Color;
[1195]46    }
47
48    private void OptionsDialogCancelButton_Click(object sender, EventArgs e) {
49      this.Close();
50    }
51
52    private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
[1233]53      IDataRow datarow = (IDataRow)this.LineSelectCB.SelectedValue;
54
55      datarow.Thickness = (int)this.LineThicknessCB.SelectedItem;
56      datarow.Color = this.ColorPreviewTB.BackColor;
57      datarow.Style = (DrawingStyle)this.LineThicknessCB.SelectedItem;
58
59      this.lc.ApplyChangesToRow(datarow);
[1195]60      this.Close();
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.