[2805] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16565] | 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2805] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
[7558] | 25 | using HeuristicLab.Optimization.Views;
|
---|
[2805] | 26 |
|
---|
[3158] | 27 | namespace HeuristicLab.Problems.TravelingSalesman.Views {
|
---|
[2805] | 28 | /// <summary>
|
---|
[4513] | 29 | /// A view for a Traveling Salesman Problem instance.
|
---|
[2805] | 30 | /// </summary>
|
---|
[3159] | 31 | [View("Traveling Salesman Problem View")]
|
---|
| 32 | [Content(typeof(TravelingSalesmanProblem), true)]
|
---|
[7641] | 33 | public sealed partial class TravelingSalesmanProblemView : ProblemView {
|
---|
[3159] | 34 | public new TravelingSalesmanProblem Content {
|
---|
| 35 | get { return (TravelingSalesmanProblem)base.Content; }
|
---|
[2805] | 36 | set { base.Content = value; }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | /// <summary>
|
---|
[4513] | 40 | /// Initializes a new instance of <see cref="TravelingSalesmanProblemView"/>.
|
---|
[2805] | 41 | /// </summary>
|
---|
[3159] | 42 | public TravelingSalesmanProblemView() {
|
---|
[2805] | 43 | InitializeComponent();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[3153] | 46 | protected override void DeregisterContentEvents() {
|
---|
| 47 | Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
[3712] | 48 | Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
[3153] | 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);
|
---|
[3712] | 55 | Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
|
---|
[3153] | 56 | Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[2998] | 59 | protected override void OnContentChanged() {
|
---|
| 60 | base.OnContentChanged();
|
---|
| 61 | if (Content == null) {
|
---|
[3153] | 62 | pathTSPTourView.Content = null;
|
---|
[2998] | 63 | } else {
|
---|
[3616] | 64 | pathTSPTourView.Content = new PathTSPTour(Content.Coordinates, Content.BestKnownSolution, Content.BestKnownQuality);
|
---|
[2998] | 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[3904] | 68 | protected override void SetEnabledStateOfControls() {
|
---|
| 69 | base.SetEnabledStateOfControls();
|
---|
[3454] | 70 | pathTSPTourView.Enabled = Content != null;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[3153] | 73 | private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 74 | pathTSPTourView.Content.Coordinates = Content.Coordinates;
|
---|
| 75 | }
|
---|
[3712] | 76 | private void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 77 | pathTSPTourView.Content.Quality = Content.BestKnownQuality;
|
---|
| 78 | }
|
---|
[3153] | 79 | private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 80 | pathTSPTourView.Content.Permutation = Content.BestKnownSolution;
|
---|
| 81 | }
|
---|
[2805] | 82 | }
|
---|
| 83 | }
|
---|