Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/24/13 11:49:28 (11 years ago)
Author:
jkarder
Message:

#2110: refactored ProblemInstanceProviderViews

Location:
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/HeuristicLab.Problems.Instances.VehicleRouting.Views-3.4.csproj

    r8600 r10000  
    115115    <Compile Include="Plugin.cs" />
    116116    <Compile Include="Properties\AssemblyInfo.cs" />
    117     <Compile Include="VRPInstanceConsumerView.cs">
     117    <Compile Include="VRPInstanceProviderView.cs">
    118118      <SubType>UserControl</SubType>
    119119    </Compile>
    120     <Compile Include="VRPInstanceConsumerView.designer.cs">
    121       <DependentUpon>VRPInstanceConsumerView.cs</DependentUpon>
     120    <Compile Include="VRPInstanceProviderView.designer.cs">
     121      <DependentUpon>VRPInstanceProviderView.cs</DependentUpon>
    122122    </Compile>
    123123    <Compile Include="VRPImportDialog.cs">
     
    182182  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    183183  <PropertyGroup>
    184    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     184    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    185185set ProjectDir=$(ProjectDir)
    186186set SolutionDir=$(SolutionDir)
     
    188188
    189189call PreBuildEvent.cmd</PreBuildEvent>
    190 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     190    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    191191export ProjectDir=$(ProjectDir)
    192192export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs

    r9999 r10000  
    2424using System.Windows.Forms;
    2525using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
    2726using HeuristicLab.PluginInfrastructure;
    2827using HeuristicLab.Problems.Instances.Views;
     
    3029namespace HeuristicLab.Problems.Instances.VehicleRouting.Views {
    3130  [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 {
    3933
    4034    public VRPInstanceProviderView() {
     
    4236    }
    4337
    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 
    5638    protected override void importButton_Click(object sender, EventArgs e) {
    57       IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     39      var provider = Content as IVRPInstanceProvider;
    5840      if (provider != null) {
    59         using (var dialog = new VRPImportDialog(SelectedProvider.Name)) {
     41        using (var dialog = new VRPImportDialog(Content.Name)) {
    6042          if (dialog.ShowDialog() == DialogResult.OK) {
    6143            var instance = provider.Import(dialog.VRPFileName, dialog.TourFileName);
    6244            try {
    6345              GenericConsumer.Load(instance as T);
    64             }
    65             catch (Exception ex) {
     46              instancesComboBox.SelectedIndex = -1;
     47            } catch (Exception ex) {
    6648              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");
    6749            }
     
    7254
    7355    protected override void exportButton_Click(object sender, EventArgs e) {
    74       IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     56      var provider = Content as IVRPInstanceProvider;
    7557      if (provider != null) {
    7658        if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    7759          try {
    7860            provider.Export(GenericExporter.Export(), saveFileDialog.FileName);
    79           }
    80           catch (Exception ex) {
     61          } catch (Exception ex) {
    8162            ErrorHandling.ShowErrorDialog(this, ex);
    8263          }
Note: See TracChangeset for help on using the changeset viewer.