1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Windows.Forms;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Visualization.Options {
|
---|
6 | public partial class OptionsDialog : Form {
|
---|
7 | private readonly IChartDataRowsModel model;
|
---|
8 |
|
---|
9 | public OptionsDialog(IChartDataRowsModel model) {
|
---|
10 | InitializeComponent();
|
---|
11 | this.model = model;
|
---|
12 | }
|
---|
13 |
|
---|
14 | private void OptionsDialogSelectColorBtn_Click(object sender, EventArgs e) {
|
---|
15 | ColorDialog dlg = new ColorDialog();
|
---|
16 | dlg.ShowDialog();
|
---|
17 | 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 | if (model.Rows.Count != 0) {
|
---|
30 | LineSelectCB.DataSource = model.Rows;
|
---|
31 | LineSelectCB.DisplayMember = "Label";
|
---|
32 |
|
---|
33 | LineThicknessCB.DataSource = GetThicknesses();
|
---|
34 | LinestyleCB.DataSource = GetStyles();
|
---|
35 | LineSelectCB.SelectedIndex = 0;
|
---|
36 | LineSelectCB_SelectedIndexChanged(this, null);
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
41 | if (LineSelectCB.SelectedValue != null) {
|
---|
42 | int index =
|
---|
43 | LineThicknessCB.FindStringExact(((IDataRow) LineSelectCB.SelectedValue).Thickness.ToString());
|
---|
44 | LineThicknessCB.SelectedIndex = index;
|
---|
45 | index = LinestyleCB.FindStringExact(((IDataRow) LineSelectCB.SelectedValue).Style.ToString());
|
---|
46 | LinestyleCB.SelectedIndex = index;
|
---|
47 | ColorPreviewTB.BackColor = ((IDataRow) LineSelectCB.SelectedValue).Color;
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | private void OptionsDialogCancelButton_Click(object sender, EventArgs e) {
|
---|
52 | Close();
|
---|
53 | }
|
---|
54 |
|
---|
55 | private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
|
---|
56 | if (LineSelectCB.SelectedValue != null) {
|
---|
57 | ((IDataRow) LineSelectCB.SelectedValue).Thickness = (int) LineThicknessCB.SelectedItem;
|
---|
58 | ((IDataRow) LineSelectCB.SelectedValue).Color = ColorPreviewTB.BackColor;
|
---|
59 | ((IDataRow) LineSelectCB.SelectedValue).Style = (DrawingStyle) LinestyleCB.SelectedItem;
|
---|
60 | }
|
---|
61 | Close();
|
---|
62 | }
|
---|
63 |
|
---|
64 | private void OptionsDialogApplyBtn_Click(object sender, EventArgs e) {
|
---|
65 | if (LineSelectCB.SelectedValue != null) {
|
---|
66 | ((IDataRow) LineSelectCB.SelectedValue).Thickness = (int) LineThicknessCB.SelectedItem;
|
---|
67 | ((IDataRow) LineSelectCB.SelectedValue).Color = ColorPreviewTB.BackColor;
|
---|
68 | ((IDataRow) LineSelectCB.SelectedValue).Style = (DrawingStyle) LinestyleCB.SelectedItem;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | }
|
---|
72 | }
|
---|