Free cookie consent management tool by TermsFeed Policy Generator

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

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

Merged changes from trunk into branch (#1177)

File size: 3.2 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;
28using HeuristicLab.PluginInfrastructure;
29
30namespace HeuristicLab.Problems.VehicleRouting.Views {
31  [View("VehicleRouting Problem View")]
32  [Content(typeof(VehicleRoutingProblem), true)]
33  public partial class VehicleRoutingProblemView : NamedItemView {
34    private VRPImportDialog vrpImportDialog;
35
36    public new VehicleRoutingProblem Content {
37      get { return (VehicleRoutingProblem)base.Content; }
38      set { base.Content = value; }
39    }
40
41    public VehicleRoutingProblemView() {
42      InitializeComponent();
43    }
44
45    protected override void DeregisterContentEvents() {
46      base.DeregisterContentEvents();
47    }
48    protected override void RegisterContentEvents() {
49      base.RegisterContentEvents();
50    }
51
52    protected override void OnContentChanged() {
53      base.OnContentChanged();
54      if (Content == null) {
55        parameterCollectionView.Content = null;
56      } else {
57        parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
58      }
59    }
60
61    protected override void SetEnabledStateOfControls() {
62      base.SetEnabledStateOfControls();
63      parameterCollectionView.Enabled = Content != null;
64      importButton.Enabled = Content != null && !ReadOnly;
65    }
66
67    private void importButton_Click(object sender, EventArgs e) {
68      if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog();
69
70      if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) {
71        try {
72          switch (vrpImportDialog.Format) {
73            case VRPFormat.TSPLib:
74              Content.ImportFromTSPLib(vrpImportDialog.VRPFileName);
75              break;
76
77            case VRPFormat.Solomon:
78              Content.ImportFromSolomon(vrpImportDialog.VRPFileName);
79              break;
80
81            case VRPFormat.ORLib:
82              Content.ImportFromORLib(vrpImportDialog.VRPFileName);
83              break;
84          }
85
86          if (!string.IsNullOrEmpty(vrpImportDialog.TourFileName))
87            Content.ImportSolution(vrpImportDialog.TourFileName);
88        }
89        catch (Exception ex) {
90          ErrorHandling.ShowErrorDialog(this, ex);
91        }
92      }
93    } 
94  }
95}
Note: See TracBrowser for help on using the repository browser.