Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/OptionsDialog.cs @ 1187

Last change on this file since 1187 was 1187, checked in by dwagner, 15 years ago

Added OptionsDialog, min and max lines and fixed bug in auto-adjust. (#478) (#345)

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