Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs @ 12009

Last change on this file since 12009 was 12009, checked in by ascheibe, 9 years ago

#2212 updated copyright year

File size: 2.5 KB
RevLine 
[3267]1#region License Information
2/* HeuristicLab
[12009]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3267]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
[5419]22using System.Linq;
[3267]23using System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.Optimization.Views {
28  [View("Experiment View")]
29  [Content(typeof(Experiment), true)]
[6425]30  public sealed partial class ExperimentView : IOptimizerView {
[3267]31    public ExperimentView() {
32      InitializeComponent();
33    }
34
[6425]35    public new Experiment Content {
36      get { return (Experiment)base.Content; }
37      set { base.Content = value; }
[3267]38    }
39
40    protected override void OnContentChanged() {
41      base.OnContentChanged();
42      if (Content == null) {
[6471]43        experimentTreeView.Content = null;
[3329]44        runsViewHost.Content = null;
[3267]45      } else {
[6471]46        experimentTreeView.Content = Content;
[3329]47        runsViewHost.Content = Content.Runs;
[3267]48      }
49    }
50
[3904]51    protected override void SetEnabledStateOfControls() {
52      base.SetEnabledStateOfControls();
[6471]53      experimentTreeView.Enabled = Content != null;
[3454]54      runsViewHost.Enabled = Content != null;
[3367]55    }
56
[3267]57    protected override void OnClosed(FormClosedEventArgs e) {
[5419]58      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
59        //The content must be stopped if no other view showing the content is available
60        var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
[5420]61        if (!optimizers.Contains(Content)) {
62          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
63          if (!nestedOptimizers.Contains(Content)) Content.Stop();
64        }
[5419]65      }
[3267]66      base.OnClosed(e);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.