Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering.Views/3.3/OrienteeringProblemView.cs @ 11265

Last change on this file since 11265 was 11265, checked in by pfleck, 10 years ago

#2208 Improved orienteering solution view by labeling start and endpoint

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