Free cookie consent management tool by TermsFeed Policy Generator

source: branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs @ 4362

Last change on this file since 4362 was 4362, checked in by svonolfe, 14 years ago

Added initial version - WIP (#1177)

File size: 3.1 KB
Line 
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
22using System;
23using System.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.Optimization.Views;
26using HeuristicLab.Core.Views;
27using HeuristicLab.Core;
28
29namespace 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      base.DeregisterContentEvents();
44    }
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47    }
48
49    protected override void OnContentChanged() {
50      base.OnContentChanged();
51      if (Content == null) {
52        parameterCollectionView.Content = null;
53      } else {
54        parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
55      }
56    }
57
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      parameterCollectionView.Enabled = Content != null;
61      importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
62    }
63
64    private void importButton_Click(object sender, EventArgs e) {
65      OpenFileDialog dialog = new OpenFileDialog();
66      dialog.Filter = "Solomon files (*.txt)|*.txt";
67
68      if (dialog.ShowDialog() == DialogResult.OK) {
69        Content.ImportFromSolomon(dialog.FileName);
70      }
71    }
72
73    private void importButton2_Click(object sender, EventArgs e) {
74      OpenFileDialog dialog = new OpenFileDialog();
75      dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
76
77      if (dialog.ShowDialog() == DialogResult.OK) {
78        Content.ImportFromTSPLib(dialog.FileName);
79      }
80    }
81
82    private void importButton3_Click(object sender, EventArgs e) {
83      OpenFileDialog dialog = new OpenFileDialog();
84      dialog.Filter = "ORLib files (*.txt)|*.txt";
85
86      if (dialog.ShowDialog() == DialogResult.OK) {
87        Content.ImportFromORLib(dialog.FileName);
88      }
89    }   
90  }
91}
Note: See TracBrowser for help on using the repository browser.