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;
|
---|
26 | using HeuristicLab.Core.Views;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.VehicleRouting.Views {
|
---|
30 | [View("VehicleRouting Problem View")]
|
---|
31 | [Content(typeof(VehicleRoutingProblem), true)]
|
---|
32 | public partial class VehicleRoutingProblemView : NamedItemView {
|
---|
33 | public new VehicleRoutingProblem Content {
|
---|
34 | get { return (VehicleRoutingProblem)base.Content; }
|
---|
35 | set { base.Content = value; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public VehicleRoutingProblemView() {
|
---|
39 | InitializeComponent();
|
---|
40 | }
|
---|
41 |
|
---|
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;
|
---|
66 | importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
|
---|
67 | }
|
---|
68 |
|
---|
69 | private void importButton_Click(object sender, EventArgs e) {
|
---|
70 | OpenFileDialog dialog = new OpenFileDialog();
|
---|
71 | dialog.Filter = "Solomon files (*.txt)|*.txt";
|
---|
72 |
|
---|
73 | if (dialog.ShowDialog() == DialogResult.OK) {
|
---|
74 | Content.ImportFromSolomon(dialog.FileName);
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
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 |
|
---|
96 | private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
97 | vrpSolutionView.Content.Coordinates = Content.Coordinates;
|
---|
98 | }
|
---|
99 | }
|
---|
100 | }
|
---|