Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3661 was 3661, checked in by abeham, 15 years ago

#999

  • prepared TF visualization
  • removed obsolete TF solution analyzers
File size: 3.6 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 SingleObjectiveTestFunctions solution.
34  /// </summary>
35  [View("Single Objective Test Functions 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.BestQuality;
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.BestRealVector;
76        pictureBox.Visible = Content.BestRealVector.Length == 2;
77      }
78    }
79
80    protected override void OnContentChanged() {
81      base.OnContentChanged();
82
83      if (Content == null) {
84        qualityView.Content = null;
85        realVectorView.Content = null;
86      } else {
87        qualityView.ViewType = null;
88        qualityView.Content = Content.BestQuality;
89
90        realVectorView.ViewType = null;
91        realVectorView.Content = Content.BestRealVector;
92
93        pictureBox.Visible = Content.BestRealVector.Length == 2;
94      }
95
96      SetEnabledStateOfControls();
97    }
98
99    private void SetEnabledStateOfControls() {
100      qualityView.Enabled = Content != null;
101      realVectorView.Enabled = Content != null;
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.