Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QAPAssignmentView.cs @ 12372

Last change on this file since 12372 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.ComponentModel;
23using System.Windows.Forms;
24using HeuristicLab.Core.Views;
25using HeuristicLab.MainForm;
26
27namespace 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;
60        qapView.Distances = null;
61        qapView.Weights = null;
62        qapView.Assignment = null;
63      } else {
64        qualityViewHost.Content = Content.Quality;
65        assignmentViewHost.Content = Content.Assignment;
66        qapView.Distances = Content.Distances;
67        qapView.Weights = Content.Weights;
68        qapView.Assignment = Content.Assignment;
69      }
70    }
71
72    protected override void SetEnabledStateOfControls() {
73      base.SetEnabledStateOfControls();
74      qualityGroupBox.Enabled = Content != null;
75      assignmentGroupBox.Enabled = Content != null;
76      qapView.Enabled = Content != null;
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":
85            break;
86          case "Distances":
87            qapView.Distances = Content.Distances;
88            break;
89          case "Weights":
90            qapView.Weights = Content.Weights;
91            break;
92          case "Quality":
93            break;
94          case "Assignment":
95            assignmentViewHost.Content = Content.Assignment;
96            qapView.Assignment = Content.Assignment;
97            break;
98          default:
99            break;
100        }
101      }
102    }
103  }
104}
Note: See TracBrowser for help on using the repository browser.