Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OptimizationNetworks/HeuristicLab.Optimization.Views/3.3/ResultView.cs @ 11063

Last change on this file since 11063 was 9456, checked in by swagner, 12 years ago

Updated copyright year and added some missing license headers (#1889)

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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
22using System;
23using System.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.Optimization.Views {
29  [View("Result View")]
30  [Content(typeof(Result), false)]
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
38    public override bool ReadOnly {
39      get { return true; }
40      set { /*not needed because results are always readonly */}
41    }
42
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    }
67
68    protected override void SetEnabledStateOfControls() {
69      base.SetEnabledStateOfControls();
70      dataTypeTextBox.Enabled = Content != null;
71      viewHost.Enabled = Content != null;
72      viewHost.ReadOnly = this.ReadOnly;
73    }
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}
Note: See TracBrowser for help on using the repository browser.