Changeset 10000 for trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs
- Timestamp:
- 09/24/13 11:49:28 (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs
r9999 r10000 24 24 using System.Windows.Forms; 25 25 using HeuristicLab.MainForm; 26 using HeuristicLab.MainForm.WindowsForms;27 26 using HeuristicLab.PluginInfrastructure; 28 27 using HeuristicLab.Problems.Instances.Views; … … 30 29 namespace HeuristicLab.Problems.Instances.VehicleRouting.Views { 31 30 [View("VRP InstanceProvider View")] 32 [Content(typeof(IProblemInstanceConsumer<IVRPData>), IsDefaultView = true)] 33 public partial class VRPInstanceProviderView<T> : ProblemInstanceConsumerViewGeneric<T> where T : class, IVRPData { 34 35 public new IProblemInstanceConsumer<T> Content { 36 get { return (IProblemInstanceConsumer<T>)base.Content; } 37 set { base.Content = value; } 38 } 31 [Content(typeof(IProblemInstanceProvider<IVRPData>), IsDefaultView = true)] 32 public partial class VRPInstanceProviderView<T> : ProblemInstanceProviderViewGeneric<T> where T : class, IVRPData { 39 33 40 34 public VRPInstanceProviderView() { … … 42 36 } 43 37 44 protected override void SetEnabledStateOfControls() {45 problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;46 libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;47 IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;48 importButton.Enabled = !ReadOnly && !Locked && Content != null && Consumer != null &&49 provider != null && provider.CanImportData;50 ProviderImportSplitContainer.Panel2Collapsed = !importButton.Enabled;51 exportButton.Enabled = !ReadOnly && !Locked && Content != null && Exporter != null &&52 provider != null && provider.CanExportData;53 ProviderExportSplitContainer.Panel2Collapsed = !exportButton.Enabled;54 }55 56 38 protected override void importButton_Click(object sender, EventArgs e) { 57 IVRPInstanceProvider provider = SelectedProvideras IVRPInstanceProvider;39 var provider = Content as IVRPInstanceProvider; 58 40 if (provider != null) { 59 using (var dialog = new VRPImportDialog( SelectedProvider.Name)) {41 using (var dialog = new VRPImportDialog(Content.Name)) { 60 42 if (dialog.ShowDialog() == DialogResult.OK) { 61 43 var instance = provider.Import(dialog.VRPFileName, dialog.TourFileName); 62 44 try { 63 45 GenericConsumer.Load(instance as T); 64 }65 catch (Exception ex) {46 instancesComboBox.SelectedIndex = -1; 47 } catch (Exception ex) { 66 48 MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance"); 67 49 } … … 72 54 73 55 protected override void exportButton_Click(object sender, EventArgs e) { 74 IVRPInstanceProvider provider = SelectedProvideras IVRPInstanceProvider;56 var provider = Content as IVRPInstanceProvider; 75 57 if (provider != null) { 76 58 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 77 59 try { 78 60 provider.Export(GenericExporter.Export(), saveFileDialog.FileName); 79 } 80 catch (Exception ex) { 61 } catch (Exception ex) { 81 62 ErrorHandling.ShowErrorDialog(this, ex); 82 63 }
Note: See TracChangeset
for help on using the changeset viewer.