Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Optimization.Views/3.3/ProblemView.cs @ 17956

Last change on this file since 17956 was 17955, checked in by mkommend, 3 years ago

#2521: Removed obsolete problem views (Orienteering, QAP, Scheduling).

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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 HeuristicLab.MainForm;
24using HeuristicLab.MainForm.WindowsForms;
25using HeuristicLab.Problems.Instances;
26
27namespace HeuristicLab.Optimization.Views {
28  /// <summary>
29  /// The base class for visual representations of items.
30  /// </summary>
31  [View("Problem View")]
32  [Content(typeof(IProblem), true)]
33  public partial class ProblemView : AsynchronousContentView {
34
35    public new IProblem Content {
36      get { return (IProblem)base.Content; }
37      set { base.Content = value; }
38    }
39
40    /// <summary>
41    /// Initializes a new instance of <see cref="ItemBaseView"/>.
42    /// </summary>
43    public ProblemView() {
44      InitializeComponent();
45    }
46
47    protected override void RegisterContentEvents() {
48      base.RegisterContentEvents();
49      Content.NameChanged += Content_NameChanged;
50    }
51
52    protected override void DeregisterContentEvents() {
53      Content.NameChanged -= Content_NameChanged;
54      base.DeregisterContentEvents();
55    }
56
57    protected override void OnContentChanged() {
58      base.OnContentChanged();
59      problemInstanceProvidersControl.Consumer = Content as IProblemInstanceConsumer;
60      namedItemView.Content = Content;
61      resultsProducingItemView.Content = Content;
62
63      if (!problemInstanceProvidersControl.ProvidersAvailable) problemInstanceSplitContainer.Panel1Collapsed = true;
64      if (Content == null) return;
65
66      Caption = Content.Name;
67    }
68
69    protected virtual void Content_NameChanged(object sender, EventArgs e) {
70      if (InvokeRequired) {
71        Invoke(new EventHandler(Content_NameChanged), sender, e);
72        return;
73      }
74      Caption = Content.Name;
75    }
76
77  }
78}
Note: See TracBrowser for help on using the repository browser.