1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Data;
|
---|
5 | using System.Drawing;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 |
|
---|
10 | namespace 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.LinestyleCB.SelectedItem;
|
---|
60 | this.lc.ApplyChangesToRow((IDataRow) this.LineSelectCB.SelectedValue);
|
---|
61 | this.Close();
|
---|
62 | }
|
---|
63 | }
|
---|
64 | } |
---|