1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 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 |
|
---|
22 | using System.ComponentModel;
|
---|
23 | using HeuristicLab.MainForm;
|
---|
24 | using HeuristicLab.Problems.TravelingSalesman.Views;
|
---|
25 |
|
---|
26 | namespace HeuristicLab.Problems.Orienteering.Views {
|
---|
27 | [View("OrienteeringSolution View")]
|
---|
28 | [Content(typeof(OrienteeringSolution), true)]
|
---|
29 | public partial class OrienteeringSolutionView : TSPSolutionView {
|
---|
30 | public new OrienteeringVisualizer Visualizer {
|
---|
31 | get { return (OrienteeringVisualizer)base.Visualizer; }
|
---|
32 | set { base.Visualizer = value; }
|
---|
33 | }
|
---|
34 | public new OrienteeringSolution Content {
|
---|
35 | get { return (OrienteeringSolution)base.Content; }
|
---|
36 | set { base.Content = value; }
|
---|
37 | }
|
---|
38 | public OrienteeringSolutionView() {
|
---|
39 | InitializeComponent();
|
---|
40 | Visualizer = new OrienteeringVisualizer();
|
---|
41 | }
|
---|
42 |
|
---|
43 | protected override void DeregisterContentEvents() {
|
---|
44 | Content.PropertyChanged -= ContentOnPropertyChanged;
|
---|
45 | base.DeregisterContentEvents();
|
---|
46 | }
|
---|
47 | protected override void RegisterContentEvents() {
|
---|
48 | base.RegisterContentEvents();
|
---|
49 | Content.PropertyChanged += ContentOnPropertyChanged;
|
---|
50 | }
|
---|
51 |
|
---|
52 | protected override void ContentOnPropertyChanged(object sender, PropertyChangedEventArgs e) {
|
---|
53 | base.ContentOnPropertyChanged(sender, e);
|
---|
54 | switch (e.PropertyName) {
|
---|
55 | case nameof(Content.Quality):
|
---|
56 | qualityValueView.Content = Content.Quality;
|
---|
57 | break;
|
---|
58 | case nameof(Content.Score):
|
---|
59 | scoreValueView.Content = Content.Score;
|
---|
60 | break;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected override void OnContentChanged() {
|
---|
65 | if (Content == null) {
|
---|
66 | qualityValueView.Content = null;
|
---|
67 | scoreValueView.Content = null;
|
---|
68 | Visualizer.Data = null;
|
---|
69 | Visualizer.IsFeasible = false;
|
---|
70 | } else {
|
---|
71 | qualityValueView.Content = Content.Quality;
|
---|
72 | scoreValueView.Content = Content.Score;
|
---|
73 | Visualizer.Data = Content.OPData;
|
---|
74 | Visualizer.IsFeasible = Content.TravelCosts.Value <= Content.OPData.MaximumTravelCosts;
|
---|
75 | }
|
---|
76 | base.OnContentChanged();
|
---|
77 | }
|
---|
78 |
|
---|
79 | protected override void SetEnabledStateOfControls() {
|
---|
80 | base.SetEnabledStateOfControls();
|
---|
81 | qualityValueView.Enabled = Content != null && !ReadOnly && !Locked;
|
---|
82 | scoreValueView.Enabled = Content != null && !ReadOnly && !Locked;
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|