source: branches/RegressionBenchmarks/HeuristicLab.Optimization.Views/3.3/ExperimentListView.cs @ 7290

Last change on this file since 7290 was 7290, checked in by gkronber, 8 years ago

#1669 merged r7209:7283 from trunk into regression benchmark branch

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.Linq;
23using System.Windows.Forms;
24using HeuristicLab.Core;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.Optimization.Views {
28  [View("Experiment List View")]
29  [Content(typeof(Experiment), false)]
30  public sealed partial class ExperimentListView : IOptimizerView {
31    public ExperimentListView() {
32      InitializeComponent();
33    }
34
35    public new Experiment Content {
36      get { return (Experiment)base.Content; }
37      set { base.Content = value; }
38    }
39
40    protected override void OnContentChanged() {
41      base.OnContentChanged();
42      if (Content == null) {
43        optimizerListView.Content = null;
44        runsViewHost.Content = null;
45      } else {
46        optimizerListView.Content = Content.Optimizers;
47        runsViewHost.Content = Content.Runs;
48      }
49    }
50
51    protected override void SetEnabledStateOfControls() {
52      base.SetEnabledStateOfControls();
53      optimizerListView.Enabled = Content != null;
54      runsViewHost.Enabled = Content != null;
55    }
56
57    protected override void OnClosed(FormClosedEventArgs e) {
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>();
61        if (!optimizers.Contains(Content)) {
62          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
63          if (!nestedOptimizers.Contains(Content)) Content.Stop();
64        }
65      }
66      base.OnClosed(e);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.