Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.PTSP.Views/3.3/ProbabilisticTSPDataView.cs @ 17335

Last change on this file since 17335 was 17335, checked in by abeham, 5 years ago

#2521: Refactored pTSP to use compositional pattern

File size: 2.4 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.Windows.Forms;
23using HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26using HeuristicLab.Problems.TravelingSalesman.Views;
27
28namespace HeuristicLab.Problems.PTSP.Views {
29  [View("Probabilistic TSP Data View")]
30  [Content(typeof(ProbabilisticTSPData), IsDefaultView = true)]
31  public partial class ProbabilisticTSPDataView : NamedItemView {
32
33    public ProbabilisticTSPVisualizer Visualizer { get; set; }
34
35    public new ProbabilisticTSPData Content {
36      get { return (ProbabilisticTSPData)base.Content; }
37      set { base.Content = value; }
38    }
39
40    public ProbabilisticTSPDataView() {
41      InitializeComponent();
42      Visualizer = new ProbabilisticTSPVisualizer();
43    }
44
45    protected override void OnContentChanged() {
46      base.OnContentChanged();
47      if (Content == null) {
48        probabilitiesView.Content = null;
49        tspViewHost.Content = null;
50        Visualizer.Probabilities = null;
51      } else {
52        probabilitiesView.Content = Content.Probabilities;
53        Visualizer.Probabilities = Content.Probabilities;
54        tspViewHost.Content = Content.TSPData;
55        if (tspViewHost.ActiveView is ITSPVisualizerView view)
56          view.Visualizer = Visualizer;
57      }
58    }
59
60    protected override void SetEnabledStateOfControls() {
61      base.SetEnabledStateOfControls();
62      probabilitiesView.Enabled = !ReadOnly && !Locked && Content != null;
63      tspViewHost.Enabled = !ReadOnly && !Locked && Content != null;
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.