Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs @ 3649

Last change on this file since 3649 was 3649, checked in by svonolfe, 14 years ago

Fixed wiring of analyzer views (#999)

File size: 3.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Drawing;
24using System.Windows.Forms;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27using HeuristicLab.Problems.TestFunctions;
28using HeuristicLab.Data;
29using System.Collections.Generic;
30
31namespace HeuristicLab.Problems.TestFunctions.Views {
32  /// <summary>
33  /// A view for a OneMax solution.
34  /// </summary>
35  [View("OneMax View")]
36  [Content(typeof(SingleObjectiveTestFunctionSolution), true)]
37  public partial class SingleObjectiveTestFunctionSolutionView : HeuristicLab.Core.Views.ItemView {
38    public new SingleObjectiveTestFunctionSolution Content {
39      get { return (SingleObjectiveTestFunctionSolution)base.Content; }
40      set { base.Content = value; }
41    }
42
43    public SingleObjectiveTestFunctionSolutionView() {
44      InitializeComponent();
45
46      qualityView.ReadOnly = true;
47      realVectorView.ReadOnly = true;
48    }
49
50    protected override void DeregisterContentEvents() {
51      Content.RealVectorChanged -= new EventHandler(Content_RealVectorChanged);
52      Content.QualityChanged -= new EventHandler(Content_QualityChanged);
53      base.DeregisterContentEvents();
54    }
55    protected override void RegisterContentEvents() {
56      base.RegisterContentEvents();
57      Content.RealVectorChanged += new EventHandler(Content_RealVectorChanged);
58      Content.QualityChanged += new EventHandler(Content_QualityChanged);
59    }
60
61    void Content_QualityChanged(object sender, EventArgs e) {
62      if (InvokeRequired)
63        Invoke(new EventHandler(Content_QualityChanged), sender, e);
64      else {
65        qualityView.ViewType = null;
66        qualityView.Content = Content.Quality;
67      }
68    }
69
70    void Content_RealVectorChanged(object sender, EventArgs e) {
71      if (InvokeRequired)
72        Invoke(new EventHandler(Content_QualityChanged), sender, e);
73      else {
74        realVectorView.ViewType = null;
75        realVectorView.Content = Content.RealVector;
76      }
77    }
78
79    protected override void OnContentChanged() {
80      base.OnContentChanged();
81
82      if (Content == null) {
83        qualityView.Content = null;
84        realVectorView.Content = null;
85      } else {
86        qualityView.ViewType = null;
87        qualityView.Content = Content.Quality;
88
89        realVectorView.ViewType = null;
90        realVectorView.Content = Content.RealVector;
91      }
92
93      SetEnabledStateOfControls();
94    }
95
96    private void SetEnabledStateOfControls() {
97      qualityView.Enabled = Content != null;
98      realVectorView.Enabled = Content != null;
99    }
100  }
101}
Note: See TracBrowser for help on using the repository browser.