1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using System.Drawing;
|
---|
26 | using System.Data;
|
---|
27 | using System.Linq;
|
---|
28 | using System.Text;
|
---|
29 | using System.Windows.Forms;
|
---|
30 | using HeuristicLab.Core;
|
---|
31 | using HeuristicLab.Data;
|
---|
32 |
|
---|
33 | namespace HeuristicLab.SimOpt {
|
---|
34 | public partial class IntParameterBoundConstraintView : ViewBase {
|
---|
35 | public IntParameterBoundConstraint IntParameterBoundConstraint {
|
---|
36 | get { return (IntParameterBoundConstraint)Item; }
|
---|
37 | set { base.Item = value; }
|
---|
38 | }
|
---|
39 |
|
---|
40 | public IntParameterBoundConstraintView() {
|
---|
41 | InitializeComponent();
|
---|
42 | }
|
---|
43 |
|
---|
44 | public IntParameterBoundConstraintView(IntParameterBoundConstraint dpbc)
|
---|
45 | : this() {
|
---|
46 | IntParameterBoundConstraint = dpbc;
|
---|
47 | }
|
---|
48 |
|
---|
49 | protected override void RemoveItemEvents() {
|
---|
50 | IntParameterBoundConstraint.Changed -= new EventHandler(IntParameterBoundConstraint_Changed);
|
---|
51 | base.RemoveItemEvents();
|
---|
52 | }
|
---|
53 |
|
---|
54 | protected override void AddItemEvents() {
|
---|
55 | base.AddItemEvents();
|
---|
56 | IntParameterBoundConstraint.Changed += new EventHandler(IntParameterBoundConstraint_Changed);
|
---|
57 | }
|
---|
58 |
|
---|
59 | protected override void UpdateControls() {
|
---|
60 | base.UpdateControls();
|
---|
61 | if (IntParameterBoundConstraint == null) {
|
---|
62 | pmTextBox.Enabled = false;
|
---|
63 | lbTextBox.Enabled = false;
|
---|
64 | lbTextBox.Text = "";
|
---|
65 | lbIncludedCheckBox.Enabled = false;
|
---|
66 | lbEnabledCheckBox.Checked = false;
|
---|
67 |
|
---|
68 | ubTextBox.Enabled = false;
|
---|
69 | ubTextBox.Text = "";
|
---|
70 | ubIncludedCheckBox.Checked = false;
|
---|
71 | ubEnabledCheckBox.Enabled = false;
|
---|
72 | } else {
|
---|
73 | pmTextBox.Text = IntParameterBoundConstraint.ParameterName;
|
---|
74 | lbTextBox.Text = IntParameterBoundConstraint.LowerBound.ToString();
|
---|
75 | lbTextBox.Enabled = IntParameterBoundConstraint.LowerBoundEnabled;
|
---|
76 | lbIncludedCheckBox.Checked = IntParameterBoundConstraint.LowerBoundIncluded;
|
---|
77 | lbIncludedCheckBox.Enabled = true;
|
---|
78 | lbEnabledCheckBox.Checked = IntParameterBoundConstraint.LowerBoundEnabled;
|
---|
79 | lbEnabledCheckBox.Enabled = true;
|
---|
80 |
|
---|
81 | ubTextBox.Text = IntParameterBoundConstraint.UpperBound.ToString();
|
---|
82 | ubTextBox.Enabled = IntParameterBoundConstraint.UpperBoundEnabled;
|
---|
83 | ubIncludedCheckBox.Checked = IntParameterBoundConstraint.UpperBoundIncluded;
|
---|
84 | ubIncludedCheckBox.Enabled = true;
|
---|
85 | ubEnabledCheckBox.Checked = IntParameterBoundConstraint.UpperBoundEnabled;
|
---|
86 | ubEnabledCheckBox.Enabled = true;
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | void IntParameterBoundConstraint_Changed(object sender, EventArgs e) {
|
---|
91 | Refresh();
|
---|
92 | }
|
---|
93 |
|
---|
94 | private void lbEnabledCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
95 | IntParameterBoundConstraint.LowerBoundEnabled = lbEnabledCheckBox.Checked;
|
---|
96 | lbTextBox.Enabled = lbEnabledCheckBox.Checked;
|
---|
97 | lbIncludedCheckBox.Enabled = lbEnabledCheckBox.Checked;
|
---|
98 | }
|
---|
99 |
|
---|
100 | private void ubEnabledCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
101 | IntParameterBoundConstraint.UpperBoundEnabled = ubEnabledCheckBox.Checked;
|
---|
102 | ubTextBox.Enabled = ubEnabledCheckBox.Checked;
|
---|
103 | ubIncludedCheckBox.Enabled = ubEnabledCheckBox.Checked;
|
---|
104 | }
|
---|
105 |
|
---|
106 | private void lbIncludedCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
107 | IntParameterBoundConstraint.LowerBoundIncluded = lbIncludedCheckBox.Checked;
|
---|
108 | }
|
---|
109 |
|
---|
110 | private void ubIncludedCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
111 | IntParameterBoundConstraint.UpperBoundIncluded = ubIncludedCheckBox.Checked;
|
---|
112 | }
|
---|
113 |
|
---|
114 | private void lbTextBox_Validating(object sender, CancelEventArgs e) {
|
---|
115 | double result;
|
---|
116 | if (!double.TryParse(lbTextBox.Text, out result)) {
|
---|
117 | e.Cancel = true;
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | private void ubTextBox_Validating(object sender, CancelEventArgs e) {
|
---|
122 | double result;
|
---|
123 | if (!double.TryParse(ubTextBox.Text, out result)) {
|
---|
124 | e.Cancel = true;
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|
128 | private void lbTextBox_Validated(object sender, EventArgs e) {
|
---|
129 | IntParameterBoundConstraint.LowerBound = int.Parse(lbTextBox.Text);
|
---|
130 | }
|
---|
131 |
|
---|
132 | private void ubTextBox_Validated(object sender, EventArgs e) {
|
---|
133 | IntParameterBoundConstraint.UpperBound = int.Parse(ubTextBox.Text);
|
---|
134 | }
|
---|
135 |
|
---|
136 | private void pmTextBox_TextChanged(object sender, EventArgs e) {
|
---|
137 | IntParameterBoundConstraint.ParameterName = pmTextBox.Text;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|