[2852] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[9456] | 3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2852] | 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;
|
---|
[4257] | 23 | using HeuristicLab.Common;
|
---|
[2852] | 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.MainForm;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.Parameters.Views {
|
---|
[5421] | 28 | [View("ConstrainedValueParameter Configuration View")]
|
---|
[5345] | 29 | [Content(typeof(OptionalConstrainedValueParameter<>), false)]
|
---|
| 30 | [Content(typeof(ConstrainedValueParameter<>), false)]
|
---|
| 31 | public partial class ConstrainedValueParameterConfigurationView<T> : ConstrainedValueParameterView<T> where T : class, IItem {
|
---|
| 32 | public ConstrainedValueParameterConfigurationView() {
|
---|
[2852] | 33 | InitializeComponent();
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | protected override void OnContentChanged() {
|
---|
| 37 | base.OnContentChanged();
|
---|
[5345] | 38 | configureButton.Checked = false;
|
---|
[2852] | 39 | }
|
---|
| 40 |
|
---|
[3904] | 41 | protected override void SetEnabledStateOfControls() {
|
---|
[5421] | 42 | base.SetEnabledStateOfControls();
|
---|
[5345] | 43 | configureButton.Enabled = Content != null && !ReadOnly;
|
---|
[3365] | 44 | }
|
---|
| 45 |
|
---|
[2852] | 46 | #region Content Events
|
---|
[5345] | 47 | protected override void Content_ValueChanged(object sender, EventArgs e) {
|
---|
[2852] | 48 | if (InvokeRequired)
|
---|
| 49 | Invoke(new EventHandler(Content_ValueChanged), sender, e);
|
---|
| 50 | else {
|
---|
[4257] | 51 | SetDataTypeTextBoxText();
|
---|
[5345] | 52 | SetComboBoxSelectedIndex();
|
---|
| 53 | if (!configureButton.Checked) {
|
---|
| 54 | viewHost.ViewType = null;
|
---|
| 55 | viewHost.Content = Content != null ? Content.Value : null;
|
---|
| 56 | }
|
---|
[2852] | 57 | }
|
---|
| 58 | }
|
---|
| 59 | #endregion
|
---|
| 60 |
|
---|
[5345] | 61 | protected virtual void configureButton_CheckedChanged(object sender, EventArgs e) {
|
---|
| 62 | if (Content == null) return;
|
---|
| 63 | var newContent = configureButton.Checked ? (IContent)Content.ValidValues : (IContent)Content.Value;
|
---|
| 64 | if (viewHost.Content != newContent) {
|
---|
| 65 | viewHost.ViewType = null;
|
---|
| 66 | viewHost.Content = newContent;
|
---|
[4257] | 67 | }
|
---|
| 68 | }
|
---|
[2852] | 69 | }
|
---|
| 70 | }
|
---|