1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Windows.Forms;
|
---|
4 | using HeuristicLab.Visualization.Legend;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Visualization.Options {
|
---|
7 | public partial class OptionsDialog : Form {
|
---|
8 | private readonly IChartDataRowsModel model;
|
---|
9 | private readonly ViewSettings viewSettings;
|
---|
10 |
|
---|
11 | public OptionsDialog(IChartDataRowsModel model) {
|
---|
12 | InitializeComponent();
|
---|
13 |
|
---|
14 | this.model = model;
|
---|
15 | viewSettings = model.ViewSettings;
|
---|
16 | }
|
---|
17 |
|
---|
18 | private void OptionsDialogSelectColorBtn_Click(object sender, EventArgs e) {
|
---|
19 | ColorDialog dlg = new ColorDialog();
|
---|
20 | dlg.ShowDialog();
|
---|
21 | ColorPreviewTB.BackColor = dlg.Color;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public IList<int> GetThicknesses() {
|
---|
25 | return new List<int> {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
---|
26 | }
|
---|
27 |
|
---|
28 | public IList<DrawingStyle> GetStyles() {
|
---|
29 | return new List<DrawingStyle> {DrawingStyle.Solid, DrawingStyle.Dashed};
|
---|
30 | }
|
---|
31 |
|
---|
32 | private void OptionsDialog_Load(object sender, EventArgs e) {
|
---|
33 | if (model.Rows.Count != 0) {
|
---|
34 | LineSelectCB.DataSource = model.Rows;
|
---|
35 | LineSelectCB.DisplayMember = "Label";
|
---|
36 |
|
---|
37 | LineThicknessCB.DataSource = GetThicknesses();
|
---|
38 | LinestyleCB.DataSource = GetStyles();
|
---|
39 | LineSelectCB.SelectedIndex = 0;
|
---|
40 | LineSelectCB_SelectedIndexChanged(this, null);
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 | private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
45 | if (LineSelectCB.SelectedValue != null) {
|
---|
46 | int index =
|
---|
47 | LineThicknessCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Thickness.ToString());
|
---|
48 | LineThicknessCB.SelectedIndex = index;
|
---|
49 | index = LinestyleCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Style.ToString());
|
---|
50 | LinestyleCB.SelectedIndex = index;
|
---|
51 | ColorPreviewTB.BackColor = ((IDataRow)LineSelectCB.SelectedValue).Color;
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | private void OptionsDialogCancelButton_Click(object sender, EventArgs e) {
|
---|
56 | Close();
|
---|
57 | }
|
---|
58 |
|
---|
59 | private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
|
---|
60 | ApplyChanges();
|
---|
61 |
|
---|
62 | Close();
|
---|
63 | }
|
---|
64 |
|
---|
65 | private void OptionsDialogApplyBtn_Click(object sender, EventArgs e) {
|
---|
66 | ApplyChanges();
|
---|
67 | }
|
---|
68 |
|
---|
69 | private void ApplyChanges() {
|
---|
70 | if (LineSelectCB.SelectedValue != null) {
|
---|
71 | ((IDataRow)LineSelectCB.SelectedValue).Thickness = (int)LineThicknessCB.SelectedItem;
|
---|
72 | ((IDataRow)LineSelectCB.SelectedValue).Color = ColorPreviewTB.BackColor;
|
---|
73 | ((IDataRow)LineSelectCB.SelectedValue).Style = (DrawingStyle)LinestyleCB.SelectedItem;
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | private void cbLegendPosition_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
78 | string pos = cbLegendPosition.SelectedItem.ToString();
|
---|
79 | if (pos.Equals("left")) {
|
---|
80 | viewSettings.LegendPosition = LegendPosition.Left;
|
---|
81 | } else if (pos.Equals("right")) {
|
---|
82 | viewSettings.LegendPosition = LegendPosition.Right;
|
---|
83 | } else if (pos.Equals("bottom")) {
|
---|
84 | viewSettings.LegendPosition = LegendPosition.Bottom;
|
---|
85 | } else {
|
---|
86 | viewSettings.LegendPosition = LegendPosition.Top;
|
---|
87 | }
|
---|
88 |
|
---|
89 | viewSettings.UpdateView();
|
---|
90 | }
|
---|
91 |
|
---|
92 | private void btnChangeTitleFont_Click(object sender, EventArgs e) {
|
---|
93 | fdFont.Font = viewSettings.TitleFont;
|
---|
94 | fdFont.Color = viewSettings.TitleColor;
|
---|
95 |
|
---|
96 | DialogResult dr = fdFont.ShowDialog();
|
---|
97 |
|
---|
98 | if(dr == DialogResult.OK) {
|
---|
99 | viewSettings.TitleFont = fdFont.Font;
|
---|
100 | viewSettings.TitleColor = fdFont.Color;
|
---|
101 |
|
---|
102 | viewSettings.UpdateView();
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | private void btnChangeLegendFont_Click(object sender, EventArgs e) {
|
---|
107 | fdFont.Font = viewSettings.LegendFont;
|
---|
108 | fdFont.Color = viewSettings.LegendColor;
|
---|
109 |
|
---|
110 | DialogResult dr = fdFont.ShowDialog();
|
---|
111 |
|
---|
112 | if (dr == DialogResult.OK) {
|
---|
113 | viewSettings.LegendFont = fdFont.Font;
|
---|
114 | viewSettings.LegendColor = fdFont.Color;
|
---|
115 |
|
---|
116 | viewSettings.UpdateView();
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | private void btnChangeXAxisFont_Click(object sender, EventArgs e) {
|
---|
121 | fdFont.Font = viewSettings.XAxisFont;
|
---|
122 | fdFont.Color = viewSettings.XAxisColor;
|
---|
123 |
|
---|
124 | DialogResult dr = fdFont.ShowDialog();
|
---|
125 |
|
---|
126 | if (dr == DialogResult.OK) {
|
---|
127 | viewSettings.XAxisFont = fdFont.Font;
|
---|
128 | viewSettings.XAxisColor = fdFont.Color;
|
---|
129 |
|
---|
130 | viewSettings.UpdateView();
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|
134 | }
|
---|