[592] | 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;
|
---|
[583] | 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 DoubleParameterBoundConstraintView : ViewBase {
|
---|
| 35 | public DoubleParameterBoundConstraint DoubleParameterBoundConstraint {
|
---|
| 36 | get { return (DoubleParameterBoundConstraint)Item; }
|
---|
| 37 | set { base.Item = value; }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public DoubleParameterBoundConstraintView() {
|
---|
| 41 | InitializeComponent();
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public DoubleParameterBoundConstraintView(DoubleParameterBoundConstraint dpbc)
|
---|
| 45 | : this() {
|
---|
| 46 | DoubleParameterBoundConstraint = dpbc;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | protected override void RemoveItemEvents() {
|
---|
| 50 | DoubleParameterBoundConstraint.Changed -= new EventHandler(DoubleParameterBoundConstraint_Changed);
|
---|
| 51 | base.RemoveItemEvents();
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | protected override void AddItemEvents() {
|
---|
| 55 | base.AddItemEvents();
|
---|
| 56 | DoubleParameterBoundConstraint.Changed += new EventHandler(DoubleParameterBoundConstraint_Changed);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | protected override void UpdateControls() {
|
---|
| 60 | base.UpdateControls();
|
---|
| 61 | if (DoubleParameterBoundConstraint == 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 = DoubleParameterBoundConstraint.ParameterName;
|
---|
| 74 | lbTextBox.Text = DoubleParameterBoundConstraint.LowerBound.ToString("r");
|
---|
| 75 | lbTextBox.Enabled = DoubleParameterBoundConstraint.LowerBoundEnabled;
|
---|
| 76 | lbIncludedCheckBox.Checked = DoubleParameterBoundConstraint.LowerBoundIncluded;
|
---|
| 77 | lbIncludedCheckBox.Enabled = true;
|
---|
| 78 | lbEnabledCheckBox.Checked = DoubleParameterBoundConstraint.LowerBoundEnabled;
|
---|
| 79 | lbEnabledCheckBox.Enabled = true;
|
---|
| 80 |
|
---|
| 81 | ubTextBox.Text = DoubleParameterBoundConstraint.UpperBound.ToString("r");
|
---|
| 82 | ubTextBox.Enabled = DoubleParameterBoundConstraint.UpperBoundEnabled;
|
---|
| 83 | ubIncludedCheckBox.Checked = DoubleParameterBoundConstraint.UpperBoundIncluded;
|
---|
| 84 | ubIncludedCheckBox.Enabled = true;
|
---|
| 85 | ubEnabledCheckBox.Checked = DoubleParameterBoundConstraint.UpperBoundEnabled;
|
---|
| 86 | ubEnabledCheckBox.Enabled = true;
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | void DoubleParameterBoundConstraint_Changed(object sender, EventArgs e) {
|
---|
| 91 | Refresh();
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | private void lbEnabledCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 95 | DoubleParameterBoundConstraint.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 | DoubleParameterBoundConstraint.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 | DoubleParameterBoundConstraint.LowerBoundIncluded = lbIncludedCheckBox.Checked;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | private void ubIncludedCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 111 | DoubleParameterBoundConstraint.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 | DoubleParameterBoundConstraint.LowerBound = double.Parse(lbTextBox.Text);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | private void ubTextBox_Validated(object sender, EventArgs e) {
|
---|
| 133 | DoubleParameterBoundConstraint.UpperBound = double.Parse(ubTextBox.Text);
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | private void pmTextBox_TextChanged(object sender, EventArgs e) {
|
---|
| 137 | DoubleParameterBoundConstraint.ParameterName = pmTextBox.Text;
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | }
|
---|