[3938] | 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.Windows.Forms;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
| 25 | using HeuristicLab.Optimization.Views;
|
---|
[4185] | 26 | using HeuristicLab.Core.Views;
|
---|
| 27 | using HeuristicLab.Core;
|
---|
[3938] | 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.VehicleRouting.Views {
|
---|
| 30 | [View("VehicleRouting Problem View")]
|
---|
| 31 | [Content(typeof(VehicleRoutingProblem), true)]
|
---|
[4185] | 32 | public partial class VehicleRoutingProblemView : NamedItemView {
|
---|
[3938] | 33 | public new VehicleRoutingProblem Content {
|
---|
| 34 | get { return (VehicleRoutingProblem)base.Content; }
|
---|
| 35 | set { base.Content = value; }
|
---|
| 36 | }
|
---|
[4068] | 37 |
|
---|
[3938] | 38 | public VehicleRoutingProblemView() {
|
---|
| 39 | InitializeComponent();
|
---|
| 40 | }
|
---|
| 41 |
|
---|
[4185] | 42 | protected override void DeregisterContentEvents() {
|
---|
| 43 | Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
| 44 | base.DeregisterContentEvents();
|
---|
| 45 | }
|
---|
| 46 | protected override void RegisterContentEvents() {
|
---|
| 47 | base.RegisterContentEvents();
|
---|
| 48 | Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | protected override void OnContentChanged() {
|
---|
| 52 | base.OnContentChanged();
|
---|
| 53 | if (Content == null) {
|
---|
| 54 | parameterCollectionView.Content = null;
|
---|
| 55 | vrpSolutionView.Content = null;
|
---|
| 56 | } else {
|
---|
| 57 | parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
|
---|
| 58 | vrpSolutionView.Content = new VRPSolution(Content.Coordinates);
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | protected override void SetEnabledStateOfControls() {
|
---|
| 63 | base.SetEnabledStateOfControls();
|
---|
| 64 | parameterCollectionView.Enabled = Content != null;
|
---|
| 65 | vrpSolutionView.Enabled = Content != null;
|
---|
[4352] | 66 | importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
|
---|
[4185] | 67 | }
|
---|
| 68 |
|
---|
[3938] | 69 | private void importButton_Click(object sender, EventArgs e) {
|
---|
| 70 | OpenFileDialog dialog = new OpenFileDialog();
|
---|
[4352] | 71 | dialog.Filter = "Solomon files (*.txt)|*.txt";
|
---|
[3938] | 72 |
|
---|
| 73 | if (dialog.ShowDialog() == DialogResult.OK) {
|
---|
| 74 | Content.ImportFromSolomon(dialog.FileName);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
[4185] | 77 |
|
---|
[4352] | 78 | private void importButton2_Click(object sender, EventArgs e) {
|
---|
| 79 | OpenFileDialog dialog = new OpenFileDialog();
|
---|
| 80 | dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
|
---|
| 81 |
|
---|
| 82 | if (dialog.ShowDialog() == DialogResult.OK) {
|
---|
| 83 | Content.ImportFromTSPLib(dialog.FileName);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | private void importButton3_Click(object sender, EventArgs e) {
|
---|
| 88 | OpenFileDialog dialog = new OpenFileDialog();
|
---|
| 89 | dialog.Filter = "ORLib files (*.txt)|*.txt";
|
---|
| 90 |
|
---|
| 91 | if (dialog.ShowDialog() == DialogResult.OK) {
|
---|
| 92 | Content.ImportFromORLib(dialog.FileName);
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[4185] | 96 | private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 97 | vrpSolutionView.Content.Coordinates = Content.Coordinates;
|
---|
[4352] | 98 | }
|
---|
[3938] | 99 | }
|
---|
| 100 | }
|
---|