Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/10 11:12:40 (13 years ago)
Author:
svonolfe
Message:

Implemented review comments (#1236)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4722 r4847  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    3233  [Content(typeof(VehicleRoutingProblem), true)]
    3334  public partial class VehicleRoutingProblemView : NamedItemView {
     35    private VRPImportDialog vrpImportDialog;
     36   
    3437    public new VehicleRoutingProblem Content {
    3538      get { return (VehicleRoutingProblem)base.Content; }
     
    6770      parameterCollectionView.Enabled = Content != null;
    6871      vrpSolutionView.Enabled = Content != null;
    69       importBestButton.Enabled = importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
     72      importButton.Enabled = Content != null && !ReadOnly;
    7073    }
    7174
    7275    private void importButton_Click(object sender, EventArgs e) {
    73       OpenFileDialog dialog = new OpenFileDialog();
    74       dialog.Filter = "Solomon files (*.txt)|*.txt";
     76      if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog();
    7577
    76       if (dialog.ShowDialog() == DialogResult.OK) {
    77         Content.ImportFromSolomon(dialog.FileName);
     78      if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) {
     79        try {
     80          switch (vrpImportDialog.Format) {
     81            case VRPFormat.TSPLib:
     82              Content.ImportFromTSPLib(vrpImportDialog.VRPFileName);
     83              break;
     84
     85            case VRPFormat.Solomon:
     86              Content.ImportFromSolomon(vrpImportDialog.VRPFileName);
     87              break;
     88
     89            case VRPFormat.ORLib:
     90              Content.ImportFromORLib(vrpImportDialog.VRPFileName);
     91              break;
     92          }
     93
     94          if(!string.IsNullOrEmpty(vrpImportDialog.TourFileName))
     95            Content.ImportSolution(vrpImportDialog.TourFileName);
     96         }
     97        catch (Exception ex) {
     98          ErrorHandling.ShowErrorDialog(this, ex);
     99        }
    78100      }
    79101    }
    80 
    81     private void importButton2_Click(object sender, EventArgs e) {
    82       OpenFileDialog dialog = new OpenFileDialog();
    83       dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
    84 
    85       if (dialog.ShowDialog() == DialogResult.OK) {
    86         Content.ImportFromTSPLib(dialog.FileName);
    87       }
    88     }
    89 
    90     private void importBestButton_Click(object sender, EventArgs e) {
    91       OpenFileDialog dialog = new OpenFileDialog();
    92       dialog.Filter = "VRP solution files (*.opt)|*.opt";
    93 
    94       if (dialog.ShowDialog() == DialogResult.OK) {
    95         Content.ImportSolution(dialog.FileName);
    96       }
    97     }
    98 
    99     private void importButton3_Click(object sender, EventArgs e) {
    100       OpenFileDialog dialog = new OpenFileDialog();
    101       dialog.Filter = "ORLib files (*.txt)|*.txt";
    102 
    103       if (dialog.ShowDialog() == DialogResult.OK) {
    104         Content.ImportFromORLib(dialog.FileName);
    105       }
    106     } 
    107102
    108103    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.