[5583] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[5583] | 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.ComponentModel;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.Core.Views;
|
---|
| 25 | using HeuristicLab.MainForm;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.Problems.QuadraticAssignment.Views {
|
---|
| 28 | /// <summary>
|
---|
| 29 | /// The base class for visual representations of a path tour for a TSP.
|
---|
| 30 | /// </summary>
|
---|
| 31 | [View("QAPAssignment View")]
|
---|
| 32 | [Content(typeof(QAPAssignment), true)]
|
---|
| 33 | public sealed partial class QAPAssignmentView : ItemView {
|
---|
| 34 | public new QAPAssignment Content {
|
---|
| 35 | get { return (QAPAssignment)base.Content; }
|
---|
| 36 | set { base.Content = value; }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | /// <summary>
|
---|
| 40 | /// Initializes a new instance of <see cref="PathTSPTourView"/>.
|
---|
| 41 | /// </summary>
|
---|
| 42 | public QAPAssignmentView() {
|
---|
| 43 | InitializeComponent();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | protected override void DeregisterContentEvents() {
|
---|
| 47 | Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged);
|
---|
| 48 | base.DeregisterContentEvents();
|
---|
| 49 | }
|
---|
| 50 | protected override void RegisterContentEvents() {
|
---|
| 51 | base.RegisterContentEvents();
|
---|
| 52 | Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | protected override void OnContentChanged() {
|
---|
| 56 | base.OnContentChanged();
|
---|
| 57 | if (Content == null) {
|
---|
| 58 | qualityViewHost.Content = null;
|
---|
| 59 | assignmentViewHost.Content = null;
|
---|
[5648] | 60 | qapView.Distances = null;
|
---|
| 61 | qapView.Weights = null;
|
---|
| 62 | qapView.Assignment = null;
|
---|
[5583] | 63 | } else {
|
---|
| 64 | qualityViewHost.Content = Content.Quality;
|
---|
| 65 | assignmentViewHost.Content = Content.Assignment;
|
---|
[5648] | 66 | qapView.Distances = Content.Distances;
|
---|
| 67 | qapView.Weights = Content.Weights;
|
---|
| 68 | qapView.Assignment = Content.Assignment;
|
---|
[5583] | 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | protected override void SetEnabledStateOfControls() {
|
---|
| 73 | base.SetEnabledStateOfControls();
|
---|
| 74 | qualityGroupBox.Enabled = Content != null;
|
---|
| 75 | assignmentGroupBox.Enabled = Content != null;
|
---|
[5648] | 76 | qapView.Enabled = Content != null;
|
---|
[5583] | 77 | }
|
---|
| 78 |
|
---|
| 79 | private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
|
---|
| 80 | if (InvokeRequired)
|
---|
| 81 | Invoke(new PropertyChangedEventHandler(Content_PropertyChanged), sender, e);
|
---|
| 82 | else {
|
---|
| 83 | switch (e.PropertyName) {
|
---|
| 84 | case "Coordinates":
|
---|
[5648] | 85 | break;
|
---|
[5583] | 86 | case "Distances":
|
---|
[5648] | 87 | qapView.Distances = Content.Distances;
|
---|
| 88 | break;
|
---|
[5583] | 89 | case "Weights":
|
---|
[5648] | 90 | qapView.Weights = Content.Weights;
|
---|
[5583] | 91 | break;
|
---|
[5648] | 92 | case "Quality":
|
---|
| 93 | break;
|
---|
[5598] | 94 | case "Assignment":
|
---|
[5583] | 95 | assignmentViewHost.Content = Content.Assignment;
|
---|
[5648] | 96 | qapView.Assignment = Content.Assignment;
|
---|
[5583] | 97 | break;
|
---|
| 98 | default:
|
---|
| 99 | break;
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | }
|
---|