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