Free cookie consent management tool by TermsFeed Policy Generator

source: branches/crossvalidation-2434/HeuristicLab.Problems.QuadraticAssignment.Views/3.3/QuadraticAssignmentProblemView.cs @ 15078

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

#2212 merged r12008, r12009, r12010 back into trunk

File size: 3.1 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;
23using System.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26using HeuristicLab.Optimization.Views;
27
28namespace HeuristicLab.Problems.QuadraticAssignment.Views {
29  [View("Quadratic Assignment Problem View")]
30  [Content(typeof(QuadraticAssignmentProblem), IsDefaultView = true)]
31  public sealed partial class QuadraticAssignmentProblemView : ProblemView {
32    public new QuadraticAssignmentProblem Content {
33      get { return (QuadraticAssignmentProblem)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public QuadraticAssignmentProblemView() {
38      InitializeComponent();
39    }
40
41    protected override void RegisterContentEvents() {
42      base.RegisterContentEvents();
43      Content.DistancesParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged);
44      Content.WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
45      Content.BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
46    }
47
48    protected override void DeregisterContentEvents() {
49      Content.DistancesParameter.ValueChanged -= new EventHandler(DistanceMatrixParameter_ValueChanged);
50      Content.WeightsParameter.ValueChanged -= new EventHandler(WeightsParameter_ValueChanged);
51      Content.BestKnownSolutionParameter.ValueChanged -= new EventHandler(BestKnownSolutionParameter_ValueChanged);
52      base.DeregisterContentEvents();
53    }
54
55    private void DistanceMatrixParameter_ValueChanged(object sender, EventArgs e) {
56      qapView.Distances = Content.Distances;
57    }
58
59    private void WeightsParameter_ValueChanged(object sender, EventArgs e) {
60      qapView.Weights = Content.Weights;
61    }
62
63    private void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
64      qapView.Assignment = Content.BestKnownSolution;
65    }
66
67    protected override void OnContentChanged() {
68      base.OnContentChanged();
69      if (Content != null) {
70        qapView.Distances = Content.Distances;
71        qapView.Weights = Content.Weights;
72        qapView.Assignment = Content.BestKnownSolution;
73      } else {
74        qapView.Distances = null;
75        qapView.Weights = null;
76        qapView.Assignment = null;
77      }
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.