Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs @ 4185

Last change on this file since 4185 was 4185, checked in by svonolfe, 12 years ago

Improved VRP visualization (#1039)

File size: 2.9 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      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 = Content != null && !ReadOnly;
67    }
68
69    private void importButton_Click(object sender, EventArgs e) {
70      OpenFileDialog dialog = new OpenFileDialog();
71      dialog.DefaultExt = "txt";
72
73      if (dialog.ShowDialog() == DialogResult.OK) {
74        Content.ImportFromSolomon(dialog.FileName);
75      }
76    }
77
78    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
79      vrpSolutionView.Content.Coordinates = Content.Coordinates;
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.