1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Data;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Text;
|
---|
8 | using System.Windows.Forms;
|
---|
9 | using HeuristicLab.Core;
|
---|
10 | using HeuristicLab.Data;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.SimOpt {
|
---|
13 | public partial class DoubleParameterBoundConstraintView : ViewBase {
|
---|
14 | public DoubleParameterBoundConstraint DoubleParameterBoundConstraint {
|
---|
15 | get { return (DoubleParameterBoundConstraint)Item; }
|
---|
16 | set { base.Item = value; }
|
---|
17 | }
|
---|
18 |
|
---|
19 | public DoubleParameterBoundConstraintView() {
|
---|
20 | InitializeComponent();
|
---|
21 | }
|
---|
22 |
|
---|
23 | public DoubleParameterBoundConstraintView(DoubleParameterBoundConstraint dpbc)
|
---|
24 | : this() {
|
---|
25 | DoubleParameterBoundConstraint = dpbc;
|
---|
26 | }
|
---|
27 |
|
---|
28 | protected override void RemoveItemEvents() {
|
---|
29 | DoubleParameterBoundConstraint.Changed -= new EventHandler(DoubleParameterBoundConstraint_Changed);
|
---|
30 | base.RemoveItemEvents();
|
---|
31 | }
|
---|
32 |
|
---|
33 | protected override void AddItemEvents() {
|
---|
34 | base.AddItemEvents();
|
---|
35 | DoubleParameterBoundConstraint.Changed += new EventHandler(DoubleParameterBoundConstraint_Changed);
|
---|
36 | }
|
---|
37 |
|
---|
38 | protected override void UpdateControls() {
|
---|
39 | base.UpdateControls();
|
---|
40 | if (DoubleParameterBoundConstraint == null) {
|
---|
41 | pmTextBox.Enabled = false;
|
---|
42 | lbTextBox.Enabled = false;
|
---|
43 | lbTextBox.Text = "";
|
---|
44 | lbIncludedCheckBox.Enabled = false;
|
---|
45 | lbEnabledCheckBox.Checked = false;
|
---|
46 |
|
---|
47 | ubTextBox.Enabled = false;
|
---|
48 | ubTextBox.Text = "";
|
---|
49 | ubIncludedCheckBox.Checked = false;
|
---|
50 | ubEnabledCheckBox.Enabled = false;
|
---|
51 | } else {
|
---|
52 | pmTextBox.Text = DoubleParameterBoundConstraint.ParameterName;
|
---|
53 | lbTextBox.Text = DoubleParameterBoundConstraint.LowerBound.ToString("r");
|
---|
54 | lbTextBox.Enabled = DoubleParameterBoundConstraint.LowerBoundEnabled;
|
---|
55 | lbIncludedCheckBox.Checked = DoubleParameterBoundConstraint.LowerBoundIncluded;
|
---|
56 | lbIncludedCheckBox.Enabled = true;
|
---|
57 | lbEnabledCheckBox.Checked = DoubleParameterBoundConstraint.LowerBoundEnabled;
|
---|
58 | lbEnabledCheckBox.Enabled = true;
|
---|
59 |
|
---|
60 | ubTextBox.Text = DoubleParameterBoundConstraint.UpperBound.ToString("r");
|
---|
61 | ubTextBox.Enabled = DoubleParameterBoundConstraint.UpperBoundEnabled;
|
---|
62 | ubIncludedCheckBox.Checked = DoubleParameterBoundConstraint.UpperBoundIncluded;
|
---|
63 | ubIncludedCheckBox.Enabled = true;
|
---|
64 | ubEnabledCheckBox.Checked = DoubleParameterBoundConstraint.UpperBoundEnabled;
|
---|
65 | ubEnabledCheckBox.Enabled = true;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | void DoubleParameterBoundConstraint_Changed(object sender, EventArgs e) {
|
---|
70 | Refresh();
|
---|
71 | }
|
---|
72 |
|
---|
73 | private void lbEnabledCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
74 | DoubleParameterBoundConstraint.LowerBoundEnabled = lbEnabledCheckBox.Checked;
|
---|
75 | lbTextBox.Enabled = lbEnabledCheckBox.Checked;
|
---|
76 | lbIncludedCheckBox.Enabled = lbEnabledCheckBox.Checked;
|
---|
77 | }
|
---|
78 |
|
---|
79 | private void ubEnabledCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
80 | DoubleParameterBoundConstraint.UpperBoundEnabled = ubEnabledCheckBox.Checked;
|
---|
81 | ubTextBox.Enabled = ubEnabledCheckBox.Checked;
|
---|
82 | ubIncludedCheckBox.Enabled = ubEnabledCheckBox.Checked;
|
---|
83 | }
|
---|
84 |
|
---|
85 | private void lbIncludedCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
86 | DoubleParameterBoundConstraint.LowerBoundIncluded = lbIncludedCheckBox.Checked;
|
---|
87 | }
|
---|
88 |
|
---|
89 | private void ubIncludedCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
90 | DoubleParameterBoundConstraint.UpperBoundIncluded = ubIncludedCheckBox.Checked;
|
---|
91 | }
|
---|
92 |
|
---|
93 | private void lbTextBox_Validating(object sender, CancelEventArgs e) {
|
---|
94 | double result;
|
---|
95 | if (!double.TryParse(lbTextBox.Text, out result)) {
|
---|
96 | e.Cancel = true;
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | private void ubTextBox_Validating(object sender, CancelEventArgs e) {
|
---|
101 | double result;
|
---|
102 | if (!double.TryParse(ubTextBox.Text, out result)) {
|
---|
103 | e.Cancel = true;
|
---|
104 | }
|
---|
105 | }
|
---|
106 |
|
---|
107 | private void lbTextBox_Validated(object sender, EventArgs e) {
|
---|
108 | DoubleParameterBoundConstraint.LowerBound = double.Parse(lbTextBox.Text);
|
---|
109 | }
|
---|
110 |
|
---|
111 | private void ubTextBox_Validated(object sender, EventArgs e) {
|
---|
112 | DoubleParameterBoundConstraint.UpperBound = double.Parse(ubTextBox.Text);
|
---|
113 | }
|
---|
114 |
|
---|
115 | private void pmTextBox_TextChanged(object sender, EventArgs e) {
|
---|
116 | DoubleParameterBoundConstraint.ParameterName = pmTextBox.Text;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|