Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1341 was 1341, checked in by bspisic, 15 years ago

#520 Renamed ViewPropertiesModel to ViewSettings and moved from LineChart to ChartDataRowsModel

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