[3226] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3226] | 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.Windows.Forms;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Optimization.Views {
|
---|
| 29 | [View("Result View")]
|
---|
[5896] | 30 | [Content(typeof(Result), false)]
|
---|
[3226] | 31 | [Content(typeof(IResult), false)]
|
---|
| 32 | public sealed partial class ResultView : NamedItemView {
|
---|
| 33 | public new IResult Content {
|
---|
| 34 | get { return (IResult)base.Content; }
|
---|
| 35 | set { base.Content = value; }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[3350] | 38 | public override bool ReadOnly {
|
---|
[4435] | 39 | get { return true; }
|
---|
[3350] | 40 | set { /*not needed because results are always readonly */}
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[3226] | 43 | public ResultView() {
|
---|
| 44 | InitializeComponent();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | protected override void DeregisterContentEvents() {
|
---|
| 48 | Content.ValueChanged -= new EventHandler(Content_ValueChanged);
|
---|
| 49 | base.DeregisterContentEvents();
|
---|
| 50 | }
|
---|
| 51 | protected override void RegisterContentEvents() {
|
---|
| 52 | base.RegisterContentEvents();
|
---|
| 53 | Content.ValueChanged += new EventHandler(Content_ValueChanged);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | protected override void OnContentChanged() {
|
---|
| 57 | base.OnContentChanged();
|
---|
| 58 | if (Content == null) {
|
---|
| 59 | dataTypeTextBox.Text = "-";
|
---|
| 60 | viewHost.Content = null;
|
---|
| 61 | } else {
|
---|
| 62 | dataTypeTextBox.Text = Content.DataType.GetPrettyName();
|
---|
| 63 | viewHost.ViewType = null;
|
---|
| 64 | viewHost.Content = Content.Value;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
[3904] | 67 |
|
---|
| 68 | protected override void SetEnabledStateOfControls() {
|
---|
| 69 | base.SetEnabledStateOfControls();
|
---|
[3454] | 70 | dataTypeTextBox.Enabled = Content != null;
|
---|
| 71 | viewHost.Enabled = Content != null;
|
---|
[4435] | 72 | viewHost.ReadOnly = this.ReadOnly;
|
---|
[3350] | 73 | }
|
---|
[3226] | 74 |
|
---|
| 75 | private void Content_ValueChanged(object sender, EventArgs e) {
|
---|
| 76 | if (InvokeRequired)
|
---|
| 77 | Invoke(new EventHandler(Content_ValueChanged), sender, e);
|
---|
| 78 | else {
|
---|
| 79 | viewHost.Content = Content.Value;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|