Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Problems.TravelingSalesman.Views/3.3/TravelingSalesmanProblemView.cs @ 16207

Last change on this file since 16207 was 15584, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers on stable

File size: 3.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.Optimization.Views;
26
27namespace HeuristicLab.Problems.TravelingSalesman.Views {
28  /// <summary>
29  /// A view for a Traveling Salesman Problem instance.
30  /// </summary>
31  [View("Traveling Salesman Problem View")]
32  [Content(typeof(TravelingSalesmanProblem), true)]
33  public sealed partial class TravelingSalesmanProblemView : ProblemView {
34    public new TravelingSalesmanProblem Content {
35      get { return (TravelingSalesmanProblem)base.Content; }
36      set { base.Content = value; }
37    }
38
39    /// <summary>
40    /// Initializes a new instance of <see cref="TravelingSalesmanProblemView"/>.
41    /// </summary>
42    public TravelingSalesmanProblemView() {
43      InitializeComponent();
44    }
45
46    protected override void DeregisterContentEvents() {
47      Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
48      Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
49      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
50      base.DeregisterContentEvents();
51    }
52    protected override void RegisterContentEvents() {
53      base.RegisterContentEvents();
54      Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
55      Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
56      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
57    }
58
59    protected override void OnContentChanged() {
60      base.OnContentChanged();
61      if (Content == null) {
62        pathTSPTourView.Content = null;
63      } else {
64        pathTSPTourView.Content = new PathTSPTour(Content.Coordinates, Content.BestKnownSolution, Content.BestKnownQuality);
65      }
66    }
67
68    protected override void SetEnabledStateOfControls() {
69      base.SetEnabledStateOfControls();
70      pathTSPTourView.Enabled = Content != null;
71    }
72
73    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
74      pathTSPTourView.Content.Coordinates = Content.Coordinates;
75    }
76    private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
77      pathTSPTourView.Content.Quality = Content.BestKnownQuality;
78    }
79    private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
80      pathTSPTourView.Content.Permutation = Content.BestKnownSolution;
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.