[4374] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4374] | 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;
|
---|
| 23 | using System.Text;
|
---|
| 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.MainForm;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.Problems.VehicleRouting.Views {
|
---|
| 28 | [View("VRPSolution View")]
|
---|
[8053] | 29 | [Content(typeof(VRPSolution), true)]
|
---|
| 30 | public partial class VRPSolutionView : HeuristicLab.Core.Views.ItemView {
|
---|
[4374] | 31 | public new VRPSolution Content {
|
---|
| 32 | get { return (VRPSolution)base.Content; }
|
---|
| 33 | set { base.Content = value; }
|
---|
[8053] | 34 | }
|
---|
| 35 |
|
---|
[4374] | 36 | public VRPSolutionView() {
|
---|
| 37 | InitializeComponent();
|
---|
[7861] | 38 | problemInstanceView.ViewsLabelVisible = false;
|
---|
[4374] | 39 | }
|
---|
| 40 |
|
---|
| 41 | protected override void DeregisterContentEvents() {
|
---|
| 42 | Content.SolutionChanged -= new EventHandler(Content_SolutionChanged);
|
---|
| 43 | base.DeregisterContentEvents();
|
---|
| 44 | }
|
---|
| 45 | protected override void RegisterContentEvents() {
|
---|
| 46 | base.RegisterContentEvents();
|
---|
| 47 | Content.SolutionChanged += new EventHandler(Content_SolutionChanged);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | private void UpdateContent() {
|
---|
[10861] | 51 | var view = problemInstanceView.ActiveView as VRPProblemInstanceView;
|
---|
| 52 | if (view != null) view.Solution = null;
|
---|
| 53 |
|
---|
[4374] | 54 | problemInstanceView.Content = Content.ProblemInstance;
|
---|
| 55 |
|
---|
[10861] | 56 | view = problemInstanceView.ActiveView as VRPProblemInstanceView;
|
---|
| 57 | if (view != null) view.Solution = Content.Solution;
|
---|
| 58 |
|
---|
[4374] | 59 | UpdateTourView();
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | protected override void OnContentChanged() {
|
---|
| 63 | base.OnContentChanged();
|
---|
| 64 | if (Content == null) {
|
---|
| 65 | problemInstanceView.Content = null;
|
---|
| 66 | } else {
|
---|
| 67 | UpdateContent();
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | private void Content_SolutionChanged(object sender, EventArgs e) {
|
---|
| 72 | if (InvokeRequired)
|
---|
| 73 | Invoke(new EventHandler(Content_SolutionChanged), sender, e);
|
---|
| 74 | else {
|
---|
| 75 | UpdateContent();
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | protected override void OnReadOnlyChanged() {
|
---|
| 80 | base.OnReadOnlyChanged();
|
---|
| 81 | SetEnabledStateOfControls();
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | protected override void SetEnabledStateOfControls() {
|
---|
| 85 | base.SetEnabledStateOfControls();
|
---|
| 86 | tabControl1.Enabled = Content != null;
|
---|
| 87 | problemInstanceView.Enabled = Content != null;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | private void UpdateTourView() {
|
---|
[6607] | 91 | StringBuilder sb = new StringBuilder();
|
---|
[4374] | 92 |
|
---|
| 93 | if (Content != null && Content.Solution != null) {
|
---|
| 94 | foreach (Tour tour in Content.Solution.GetTours()) {
|
---|
| 95 | foreach (int city in tour.Stops) {
|
---|
[6607] | 96 | sb.Append(city);
|
---|
| 97 | sb.Append(" ");
|
---|
[4374] | 98 | }
|
---|
[6607] | 99 | sb.AppendLine();
|
---|
[4374] | 100 | }
|
---|
| 101 | }
|
---|
[6607] | 102 |
|
---|
| 103 | valueTextBox.Text = sb.ToString();
|
---|
[4374] | 104 | }
|
---|
| 105 | }
|
---|
| 106 | }
|
---|