Changeset 7956


Ignore:
Timestamp:
06/04/12 21:50:19 (7 years ago)
Author:
sforsten
Message:

#1782: improvements from mkommend's comment have been applied

Location:
trunk/sources
Files:
4 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common.Resources/3.3/HeuristicLab.Common.Resources-3.3.csproj

    r7256 r7956  
    430430  </ItemGroup>
    431431  <ItemGroup>
     432    <None Include="Resources\VS2010ImageLibrary\VS2010ImageLibrary_Actions_SaveAsHH.png" />
     433    <None Include="Resources\SaveAs.bmp" />
    432434    <Content Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_Checkout.png" />
    433435    <Content Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_Clone.png" />
  • trunk/sources/HeuristicLab.Common.Resources/3.3/VSImageLibrary.Designer.cs

    r7256 r7956  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.239
     4//     Runtime Version:4.0.30319.269
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    838838        }
    839839       
     840        public static System.Drawing.Bitmap SaveAs {
     841            get {
     842                object obj = ResourceManager.GetObject("SaveAs", resourceCulture);
     843                return ((System.Drawing.Bitmap)(obj));
     844            }
     845        }
     846       
    840847        public static System.Drawing.Bitmap Script {
    841848            get {
  • trunk/sources/HeuristicLab.Common.Resources/3.3/VSImageLibrary.resx

    r7256 r7956  
    508508  <data name="DisplayInColorVertical" type="System.Resources.ResXFileRef, System.Windows.Forms">
    509509    <value>Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_DisplayInColor_Vertical.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    510   </data> 
     510  </data>
    511511  <data name="InformationLarge" type="System.Resources.ResXFileRef, System.Windows.Forms">
    512512    <value>Resources\VS2010ImageLibrary\VS2010ImageLibrary_Objects_Information_Large.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     
    518518    <value>Resources\VS2010ImageLibrary\VS2010ImageLibrary_Objects_Network_Center_Large.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    519519  </data>
     520  <data name="SaveAs" type="System.Resources.ResXFileRef, System.Windows.Forms">
     521    <value>Resources\VS2010ImageLibrary\VS2010ImageLibrary_Actions_SaveAsHH.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     522  </data>
    520523</root>
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs

    r7823 r7956  
    4646    private void InitializeComponent() {
    4747      this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer();
    48       this.problemInstanceConsumerView = new HeuristicLab.Problems.Instances.Views.ProblemInstanceConsumerView();
     48      this.ProblemInstanceConsumerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4949      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5050      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
     
    8787      // problemInstanceSplitContainer.Panel1
    8888      //
    89       this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceConsumerView);
     89      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.ProblemInstanceConsumerViewHost);
    9090      this.problemInstanceSplitContainer.Panel1MinSize = 10;
    9191      //
     
    100100      this.problemInstanceSplitContainer.TabIndex = 13;
    101101      //
    102       // problemInstanceConsumerView
     102      // ProblemInstanceConsumerViewHost
    103103      //
    104       this.problemInstanceConsumerView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     104      this.ProblemInstanceConsumerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    105105            | System.Windows.Forms.AnchorStyles.Left)
    106106            | System.Windows.Forms.AnchorStyles.Right)));
    107       this.problemInstanceConsumerView.Caption = "ProblemInstanceProviderView";
    108       this.problemInstanceConsumerView.Content = null;
    109       this.problemInstanceConsumerView.Location = new System.Drawing.Point(0, 1);
    110       this.problemInstanceConsumerView.Name = "problemInstanceConsumerView";
    111       this.problemInstanceConsumerView.ReadOnly = false;
    112       this.problemInstanceConsumerView.Size = new System.Drawing.Size(511, 23);
    113       this.problemInstanceConsumerView.TabIndex = 0;
     107      this.ProblemInstanceConsumerViewHost.Caption = "ProblemInstanceConsumerView";
     108      this.ProblemInstanceConsumerViewHost.Content = null;
     109      this.ProblemInstanceConsumerViewHost.Enabled = false;
     110      this.ProblemInstanceConsumerViewHost.Location = new System.Drawing.Point(0, 1);
     111      this.ProblemInstanceConsumerViewHost.Name = "ProblemInstanceConsumerViewHost";
     112      this.ProblemInstanceConsumerViewHost.ReadOnly = false;
     113      this.ProblemInstanceConsumerViewHost.Size = new System.Drawing.Size(511, 23);
     114      this.ProblemInstanceConsumerViewHost.TabIndex = 0;
     115      this.ProblemInstanceConsumerViewHost.ViewsLabelVisible = false;
     116      this.ProblemInstanceConsumerViewHost.ViewType = null;
    114117      //
    115118      // ProblemView
     
    133136
    134137    protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer;
    135     protected HeuristicLab.Problems.Instances.Views.ProblemInstanceConsumerView problemInstanceConsumerView;
     138    protected HeuristicLab.MainForm.WindowsForms.ViewHost ProblemInstanceConsumerViewHost;
    136139  }
    137140}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs

    r7823 r7956  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.Linq;
    2325using System.Windows.Forms;
     
    2527using HeuristicLab.MainForm;
    2628using HeuristicLab.Problems.Instances;
     29using HeuristicLab.Problems.Instances.Views;
    2730
    2831namespace HeuristicLab.Optimization.Views {
     
    3336  [Content(typeof(IProblem), true)]
    3437  public partial class ProblemView : ParameterizedNamedItemView {
     38
     39    private static Type neededViewType = typeof(ProblemInstanceConsumerView);
     40
    3541    public new IProblem Content {
    3642      get { return (IProblem)base.Content; }
     
    4955      IProblemInstanceConsumer consumer = Content as IProblemInstanceConsumer;
    5056      if (consumer != null) {
    51         problemInstanceConsumerView.Content = consumer;
    52         problemInstanceSplitContainer.Panel1Collapsed = !problemInstanceConsumerView.ProblemInstanceProviders.Any();
     57        IEnumerable<Type> viewTypes = MainFormManager.GetViewTypes(consumer.GetType(), true);
     58        Type genericView = viewTypes.Where(x => x.IsSubclassOf(neededViewType)).First();
     59        ProblemInstanceConsumerViewHost.ViewType = genericView;
     60        ProblemInstanceConsumerViewHost.Content = consumer;
     61        ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)ProblemInstanceConsumerViewHost.ActiveView;
     62        problemInstanceSplitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
    5363      } else {
    5464        problemInstanceSplitContainer.Panel1Collapsed = true;
  • trunk/sources/HeuristicLab.Problems.Instances.TSPLIB.Views/3.3/TSPLIBTSPInstanceProviderView.cs

    r7823 r7956  
    2121
    2222using System;
     23using System.IO;
    2324using System.Windows.Forms;
    2425using HeuristicLab.MainForm;
    2526using HeuristicLab.MainForm.WindowsForms;
    2627using HeuristicLab.Problems.Instances.Views;
    27 using System.IO;
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB.Views {
    3030  [View("TSPLIB TSP InstanceProvider View")]
    31   [Content(typeof(TSPLIBTSPInstanceProvider), IsDefaultView = true)]
    32   public partial class TSPLIBTSPInstanceProviderView : ProblemInstanceProviderViewGeneric<TSPData> {
    33     public new TSPLIBTSPInstanceProvider Content {
    34       get { return (TSPLIBTSPInstanceProvider)base.Content; }
     31  [Content(typeof(IProblemInstanceConsumer<TSPData>), IsDefaultView = true)]
     32  public partial class TSPLIBTSPInstanceProviderView : ProblemInstanceConsumerViewGeneric<TSPData> {
     33    public new IProblemInstanceConsumer<TSPData> Content {
     34      get { return (IProblemInstanceConsumer<TSPData>)base.Content; }
    3535      set { base.Content = value; }
    3636    }
     
    4141
    4242    protected override void importButton_Click(object sender, EventArgs e) {
    43       using (var dialog = new TSPLIBImportDialog()) {
    44         if (dialog.ShowDialog() == DialogResult.OK) {
    45           var instance = Content.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
    46           try {
    47             GenericConsumer.Load(instance);
    48           }
    49           catch (Exception ex) {
    50             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");
     43      TSPLIBTSPInstanceProvider provider = SelectedProvider as TSPLIBTSPInstanceProvider;
     44      if (provider != null) {
     45        using (var dialog = new TSPLIBImportDialog()) {
     46          if (dialog.ShowDialog() == DialogResult.OK) {
     47            var instance = provider.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
     48            try {
     49              GenericConsumer.Load(instance);
     50            }
     51            catch (Exception ex) {
     52              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");
     53            }
    5154          }
    5255        }
     56      } else {
     57        base.importButton_Click(sender, e);
    5358      }
    5459    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs

    r7882 r7956  
    2121
    2222using System;
     23using System.IO;
    2324using System.Windows.Forms;
    2425using HeuristicLab.MainForm;
    2526using HeuristicLab.MainForm.WindowsForms;
    2627using HeuristicLab.Problems.Instances.Views;
    27 using System.IO;
    2828
    2929namespace HeuristicLab.Problems.Instances.VehicleRouting.Views {
    3030  [View("VRP InstanceProvider View")]
    31   [Content(typeof(VRPInstanceProvider<>), IsDefaultView = true)]
    32   public partial class VRPInstanceProviderView<T> : ProblemInstanceProviderViewGeneric<T> where T : class, IVRPData {
     31  [Content(typeof(IProblemInstanceConsumer<IVRPData>), IsDefaultView = true)]
     32  public partial class VRPInstanceProviderView<T> : ProblemInstanceConsumerViewGeneric<T> where T : class, IVRPData {
    3333
    34     public new VRPInstanceProvider<T> Content {
    35       get { return (VRPInstanceProvider<T>)base.Content; }
     34    public new IProblemInstanceConsumer<T> Content {
     35      get { return (IProblemInstanceConsumer<T>)base.Content; }
    3636      set { base.Content = value; }
    3737    }
     
    4242
    4343    protected override void importButton_Click(object sender, EventArgs e) {
    44       using (var dialog = new VRPImportDialog(Content.Name)) {
    45         if (dialog.ShowDialog() == DialogResult.OK) {
    46           var instance = Content.LoadData(dialog.VRPFileName, dialog.TourFileName);
    47           try {
    48             GenericConsumer.Load(instance as T);
    49           }
    50           catch (Exception ex) {
    51             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");
     44      IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     45      if (provider != null) {
     46        using (var dialog = new VRPImportDialog(SelectedProvider.Name)) {
     47          if (dialog.ShowDialog() == DialogResult.OK) {
     48            var instance = provider.LoadData(dialog.VRPFileName, dialog.TourFileName);
     49            try {
     50              GenericConsumer.Load(instance as T);
     51            }
     52            catch (Exception ex) {
     53              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");
     54            }
    5255          }
    5356        }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/HeuristicLab.Problems.Instances.VehicleRouting-3.4.csproj

    r7901 r7956  
    115115    <Compile Include="GoldenFormat\GoldenParser.cs" />
    116116    <Compile Include="GoldenFormat\GoldenFormatInstanceProvider.cs" />
     117    <Compile Include="IVRPInstanceProvider.cs" />
    117118    <Compile Include="TaillardFormat\TaillardInstanceProvider.cs" />
    118119    <Compile Include="TaillardFormat\TaillardParser.cs" />
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/VRPInstanceProvider.cs

    r7881 r7956  
    2929
    3030namespace HeuristicLab.Problems.Instances.VehicleRouting {
    31   public abstract class VRPInstanceProvider<T> : ProblemInstanceProvider<T> where T : IVRPData {
     31  public abstract class VRPInstanceProvider<T> : ProblemInstanceProvider<T>, IVRPInstanceProvider where T : IVRPData {
    3232    protected abstract string FileName { get; }
    3333
     
    110110    }
    111111
    112     public T LoadData(string vrpFile, string tourFile) {
     112    public IVRPData LoadData(string vrpFile, string tourFile) {
    113113      var data = LoadData(vrpFile);
    114114      if (!String.IsNullOrEmpty(tourFile)) {
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/HeuristicLab.Problems.Instances.Views-3.3.csproj

    r7923 r7956  
    102102  </PropertyGroup>
    103103  <ItemGroup>
     104    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     105    <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     106    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    104107    <Reference Include="System" />
    105108    <Reference Include="System.Core" />
     
    113116  </ItemGroup>
    114117  <ItemGroup>
     118    <Compile Include="ProblemInstanceConsumerViewGeneric.cs">
     119      <SubType>UserControl</SubType>
     120    </Compile>
     121    <Compile Include="ProblemInstanceConsumerViewGeneric.Designer.cs">
     122      <DependentUpon>ProblemInstanceConsumerViewGeneric.cs</DependentUpon>
     123    </Compile>
     124    <Compile Include="Plugin.cs" />
     125    <Compile Include="ProblemInstanceConsumerView.cs">
     126      <SubType>UserControl</SubType>
     127    </Compile>
     128    <Compile Include="ProblemInstanceConsumerView.Designer.cs">
     129      <DependentUpon>ProblemInstanceConsumerView.cs</DependentUpon>
     130    </Compile>
    115131    <Compile Include="ProblemInstanceProviderView.cs">
    116132      <SubType>UserControl</SubType>
     
    118134    <Compile Include="ProblemInstanceProviderView.Designer.cs">
    119135      <DependentUpon>ProblemInstanceProviderView.cs</DependentUpon>
    120     </Compile>
    121     <Compile Include="Plugin.cs" />
    122     <Compile Include="ProblemInstanceConsumerView.cs">
    123       <SubType>UserControl</SubType>
    124     </Compile>
    125     <Compile Include="ProblemInstanceConsumerView.Designer.cs">
    126       <DependentUpon>ProblemInstanceConsumerView.cs</DependentUpon>
    127136    </Compile>
    128137    <Compile Include="ProblemInstanceProviderViewGeneric.cs">
     
    149158      <Name>HeuristicLab.Common-3.3</Name>
    150159      <Private>False</Private>
     160    </ProjectReference>
     161    <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj">
     162      <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project>
     163      <Name>HeuristicLab.Data.Views-3.3</Name>
    151164    </ProjectReference>
    152165    <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj">
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerView.Designer.cs

    r7849 r7956  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
    49       this.libraryInfoButton = new System.Windows.Forms.Button();
    50       this.libraryLabel = new System.Windows.Forms.Label();
    51       this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5248      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    5349      this.SuspendLayout();
    54       //
    55       // problemInstanceProviderComboBox
    56       //
    57       this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    58       this.problemInstanceProviderComboBox.FormattingEnabled = true;
    59       this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 0);
    60       this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
    61       this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21);
    62       this.problemInstanceProviderComboBox.TabIndex = 16;
    63       this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
    64       //
    65       // libraryInfoButton
    66       //
    67       this.libraryInfoButton.Location = new System.Drawing.Point(226, -1);
    68       this.libraryInfoButton.Name = "libraryInfoButton";
    69       this.libraryInfoButton.Size = new System.Drawing.Size(24, 24);
    70       this.libraryInfoButton.TabIndex = 17;
    71       this.libraryInfoButton.Text = "Info";
    72       this.libraryInfoButton.UseVisualStyleBackColor = true;
    73       this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click);
    74       //
    75       // libraryLabel
    76       //
    77       this.libraryLabel.AutoSize = true;
    78       this.libraryLabel.Location = new System.Drawing.Point(3, 3);
    79       this.libraryLabel.Name = "libraryLabel";
    80       this.libraryLabel.Size = new System.Drawing.Size(41, 13);
    81       this.libraryLabel.TabIndex = 15;
    82       this.libraryLabel.Text = "Library:";
    83       //
    84       // problemInstanceProviderViewHost
    85       //
    86       this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    87                   | System.Windows.Forms.AnchorStyles.Right)));
    88       this.problemInstanceProviderViewHost.Caption = "View";
    89       this.problemInstanceProviderViewHost.Content = null;
    90       this.problemInstanceProviderViewHost.Enabled = false;
    91       this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(258, 0);
    92       this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
    93       this.problemInstanceProviderViewHost.ReadOnly = false;
    94       this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(433, 22);
    95       this.problemInstanceProviderViewHost.TabIndex = 15;
    96       this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
    97       this.problemInstanceProviderViewHost.ViewType = null;
    9850      //
    9951      // ProblemInstanceConsumerView
     
    10153      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    10254      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    103       this.Controls.Add(this.problemInstanceProviderViewHost);
    104       this.Controls.Add(this.problemInstanceProviderComboBox);
    105       this.Controls.Add(this.libraryInfoButton);
    106       this.Controls.Add(this.libraryLabel);
    10755      this.Name = "ProblemInstanceConsumerView";
    10856      this.Size = new System.Drawing.Size(694, 22);
    10957      this.ResumeLayout(false);
    110       this.PerformLayout();
    11158
    11259    }
     
    11461    #endregion
    11562
    116     private System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
    117     private System.Windows.Forms.Button libraryInfoButton;
    118     private System.Windows.Forms.Label libraryLabel;
    119     private MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
    12063    private System.Windows.Forms.ToolTip toolTip;
    12164  }
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerView.cs

    r7860 r7956  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.Diagnostics;
    25 using System.Linq;
    2623using System.Windows.Forms;
    27 using HeuristicLab.Common.Resources;
    2824using HeuristicLab.MainForm;
    2925using HeuristicLab.MainForm.WindowsForms;
     
    3228  [View("ProblemInstanceConsumerView")]
    3329  [Content(typeof(IProblemInstanceConsumer), IsDefaultView = false)]
    34   public sealed partial class ProblemInstanceConsumerView : AsynchronousContentView {
     30  public partial class ProblemInstanceConsumerView : AsynchronousContentView {
    3531
    3632    public new IProblemInstanceConsumer Content {
     
    3935    }
    4036
    41     public IProblemInstanceProvider SelectedProvider {
    42       get;
    43       private set;
    44     }
    45 
     37    protected IEnumerable<IProblemInstanceProvider> problemInstanceProviders;
    4638    public IEnumerable<IProblemInstanceProvider> ProblemInstanceProviders {
    47       get;
    48       private set;
     39      get { return new List<IProblemInstanceProvider>(problemInstanceProviders); }
    4940    }
    5041
    5142    public ProblemInstanceConsumerView() {
    5243      InitializeComponent();
    53       libraryInfoButton.Text = String.Empty;
    54       libraryInfoButton.Image = VSImageLibrary.Help;
    5544    }
    56 
    57     protected override void OnContentChanged() {
    58       base.OnContentChanged();
    59       if (Content == null) {
    60         ProblemInstanceProviders = null;
    61         problemInstanceProviderComboBox.DataSource = null;
    62       } else {
    63         problemInstanceProviderComboBox.DisplayMember = "Name";
    64         ProblemInstanceProviders = ProblemInstanceManager.GetProviders(Content);
    65         problemInstanceProviderComboBox.DataSource = ProblemInstanceProviders.OrderBy(x => x.Name).ToList();
    66       }
    67       SetEnabledStateOfControls();
    68     }
    69 
    70     public bool ContainsProviders() {
    71       return problemInstanceProviderComboBox.Items.Count > 0;
    72     }
    73 
    74     protected override void SetEnabledStateOfControls() {
    75       base.SetEnabledStateOfControls();
    76       problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
    77       libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
    78     }
    79 
    80     private void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    81       if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
    82         SelectedProvider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem;
    83         problemInstanceProviderViewHost.Content = SelectedProvider;
    84         ProblemInstanceProviderView view = (ProblemInstanceProviderView)problemInstanceProviderViewHost.ActiveView;
    85         view.Consumer = Content;
    86         if (CheckForIProblemInstanceExporter(Content)) {
    87           view.Exporter = (IProblemInstanceExporter)Content;
    88         }
    89         SetTooltip();
    90       } else {
    91         SelectedProvider = null;
    92       }
    93 
    94       SetEnabledStateOfControls();
    95     }
    96 
    97     private bool CheckForIProblemInstanceExporter(IProblemInstanceConsumer content) {
    98       return Content.GetType().GetInterfaces()
    99                     .Any(x => x.Equals(typeof(IProblemInstanceExporter)));
    100     }
    101 
    102     private void libraryInfoButton_Click(object sender, EventArgs e) {
    103       if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
    104         if (SelectedProvider != null && SelectedProvider.WebLink != null)
    105           Process.Start(SelectedProvider.WebLink.ToString());
    106       }
    107     }
    108 
    109     #region ToolTip
    110     private void SetTooltip() {
    111       toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
    112       if (SelectedProvider.WebLink != null)
    113         toolTip.SetToolTip(libraryInfoButton, "Browse to " + SelectedProvider.WebLink.ToString());
    114       else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference.");
    115     }
    116 
    117     private string GetProviderToolTip() {
    118       var provider = SelectedProvider;
    119       string toolTip = provider.Name;
    120 
    121       if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
    122         toolTip = toolTip
    123             + Environment.NewLine + Environment.NewLine
    124             + provider.ReferencePublication;
    125       }
    126       if (provider.WebLink != null) {
    127         toolTip = toolTip
    128             + Environment.NewLine
    129             + provider.WebLink.ToString();
    130       }
    131 
    132       return toolTip;
    133     }
    134     #endregion
    13545  }
    13646}
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderView.cs

    r7684 r7956  
    3636    public abstract IProblemInstanceConsumer Consumer { get; set; }
    3737
    38     public abstract IProblemInstanceExporter Exporter { get; set; }
    39 
    4038    public ProblemInstanceProviderView() {
    4139      InitializeComponent();
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.Designer.cs

    r7849 r7956  
    4949      this.instanceLabel = new System.Windows.Forms.Label();
    5050      this.instancesComboBox = new System.Windows.Forms.ComboBox();
    51       this.importButton = new System.Windows.Forms.Button();
    5251      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    5352      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    54       this.exportButton = new System.Windows.Forms.Button();
    5553      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    56       this.problemInstanceProviderSplitContainer = new System.Windows.Forms.SplitContainer();
    57       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceProviderSplitContainer)).BeginInit();
    58       this.problemInstanceProviderSplitContainer.Panel1.SuspendLayout();
    59       this.problemInstanceProviderSplitContainer.Panel2.SuspendLayout();
    60       this.problemInstanceProviderSplitContainer.SuspendLayout();
    6154      this.SuspendLayout();
    6255      //
     
    6457      //
    6558      this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    66       this.loadButton.Location = new System.Drawing.Point(604, 0);
     59      this.loadButton.Location = new System.Drawing.Point(667, -1);
    6760      this.loadButton.Name = "loadButton";
    6861      this.loadButton.Size = new System.Drawing.Size(24, 24);
     
    8376      // instancesComboBox
    8477      //
    85       this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     78      this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    8679            | System.Windows.Forms.AnchorStyles.Right)));
    8780      this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    8982      this.instancesComboBox.Location = new System.Drawing.Point(60, 1);
    9083      this.instancesComboBox.Name = "instancesComboBox";
    91       this.instancesComboBox.Size = new System.Drawing.Size(538, 21);
     84      this.instancesComboBox.Size = new System.Drawing.Size(601, 21);
    9285      this.instancesComboBox.TabIndex = 7;
    93       this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
    94       //
    95       // importButton
    96       //
    97       this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    98       this.importButton.Location = new System.Drawing.Point(636, 0);
    99       this.importButton.Name = "importButton";
    100       this.importButton.Size = new System.Drawing.Size(24, 24);
    101       this.importButton.TabIndex = 6;
    102       this.importButton.Text = "Import";
    103       this.importButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    104       this.importButton.UseVisualStyleBackColor = true;
    105       this.importButton.Click += new System.EventHandler(this.importButton_Click);
     86      this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.instancesComboBox_DataSourceChanged);
    10687      //
    10788      // openFileDialog
    10889      //
    10990      this.openFileDialog.Filter = "All files|*.*";
    110       //
    111       // exportButton
    112       //
    113       this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    114       this.exportButton.Location = new System.Drawing.Point(-1, 0);
    115       this.exportButton.Name = "exportButton";
    116       this.exportButton.Size = new System.Drawing.Size(24, 24);
    117       this.exportButton.TabIndex = 8;
    118       this.exportButton.Text = "Export";
    119       this.exportButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    120       this.exportButton.UseVisualStyleBackColor = true;
    121       this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
    12291      //
    12392      // saveFileDialog
     
    12695      this.saveFileDialog.Title = "Save RegressionInstance...";
    12796      //
    128       // problemInstanceProviderSplitContainer
    129       //
    130       this.problemInstanceProviderSplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    131             | System.Windows.Forms.AnchorStyles.Left)
    132             | System.Windows.Forms.AnchorStyles.Right)));
    133       this.problemInstanceProviderSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
    134       this.problemInstanceProviderSplitContainer.IsSplitterFixed = true;
    135       this.problemInstanceProviderSplitContainer.Location = new System.Drawing.Point(0, -1);
    136       this.problemInstanceProviderSplitContainer.Name = "problemInstanceProviderSplitContainer";
    137       //
    138       // problemInstanceProviderSplitContainer.Panel1
    139       //
    140       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.instanceLabel);
    141       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.instancesComboBox);
    142       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.importButton);
    143       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.loadButton);
    144       //
    145       // problemInstanceProviderSplitContainer.Panel2
    146       //
    147       this.problemInstanceProviderSplitContainer.Panel2.Controls.Add(this.exportButton);
    148       this.problemInstanceProviderSplitContainer.Size = new System.Drawing.Size(694, 22);
    149       this.problemInstanceProviderSplitContainer.SplitterDistance = 665;
    150       this.problemInstanceProviderSplitContainer.TabIndex = 9;
    151       //
    152       // ProblemInstanceProviderView
     97      // ProblemInstanceProviderViewGeneric
    15398      //
    15499      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    155100      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    156       this.Controls.Add(this.problemInstanceProviderSplitContainer);
    157       this.Name = "ProblemInstanceProviderView";
     101      this.Controls.Add(this.instanceLabel);
     102      this.Controls.Add(this.instancesComboBox);
     103      this.Controls.Add(this.loadButton);
     104      this.Name = "ProblemInstanceProviderViewGeneric";
    158105      this.Size = new System.Drawing.Size(694, 21);
    159       this.problemInstanceProviderSplitContainer.Panel1.ResumeLayout(false);
    160       this.problemInstanceProviderSplitContainer.Panel1.PerformLayout();
    161       this.problemInstanceProviderSplitContainer.Panel2.ResumeLayout(false);
    162       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceProviderSplitContainer)).EndInit();
    163       this.problemInstanceProviderSplitContainer.ResumeLayout(false);
    164106      this.ResumeLayout(false);
     107      this.PerformLayout();
    165108
    166109    }
     
    173116    protected System.Windows.Forms.Label instanceLabel;
    174117    protected System.Windows.Forms.ComboBox instancesComboBox;
    175     protected System.Windows.Forms.Button importButton;
    176     protected System.Windows.Forms.Button exportButton;
    177118    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
    178     protected System.Windows.Forms.SplitContainer problemInstanceProviderSplitContainer;
    179 
    180119  }
    181120}
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs

    r7860 r7956  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.IO;
    2524using System.Linq;
    2625using System.Windows.Forms;
     
    2827using HeuristicLab.MainForm;
    2928using HeuristicLab.MainForm.WindowsForms;
    30 using HeuristicLab.PluginInfrastructure;
    3129
    3230namespace HeuristicLab.Problems.Instances.Views {
     
    4038    }
    4139
    42     #region Importer & Exporter
    43     protected IProblemInstanceConsumer<T> GenericConsumer { get { return Consumer as IProblemInstanceConsumer<T>; } }
    44     protected IProblemInstanceConsumer consumer;
     40    private IProblemInstanceConsumer<T> GenericConsumer { get { return Consumer as IProblemInstanceConsumer<T>; } }
     41
     42    public IProblemInstanceConsumer consumer;
    4543    public override IProblemInstanceConsumer Consumer {
    4644      get { return consumer; }
     
    5149    }
    5250
    53     protected IProblemInstanceExporter<T> GenericExporter { get { return Exporter as IProblemInstanceExporter<T>; } }
    54     protected IProblemInstanceExporter exporter;
    55     public override IProblemInstanceExporter Exporter {
    56       get { return exporter; }
    57       set {
    58         exporter = value;
    59         SetEnabledStateOfControls();
    60       }
    61     }
    62     #endregion
    63 
    6451    public ProblemInstanceProviderViewGeneric() {
    6552      InitializeComponent();
    66       importButton.Text = String.Empty;
    67       importButton.Image = VSImageLibrary.Open;
    68       toolTip.SetToolTip(importButton, "Open a " + GetProblemType() + " problem from file.");
    69       exportButton.Text = String.Empty;
    70       exportButton.Image = VSImageLibrary.Save;
    71       toolTip.SetToolTip(exportButton, "Export currently loaded " + GetProblemType() + " problem to a file.");
    7253      loadButton.Text = String.Empty;
    7354      loadButton.Image = VSImageLibrary.RefreshDocument;
     
    10384      instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null;
    10485      loadButton.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null;
    105       importButton.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null;
    106       exportButton.Enabled = !ReadOnly && !Locked && Content != null && GenericExporter != null;
    107       problemInstanceProviderSplitContainer.Panel2Collapsed = !exportButton.Enabled;
    10886    }
    10987
     
    11997    }
    12098
    121     protected virtual void importButton_Click(object sender, EventArgs e) {
    122       openFileDialog.FileName = GetProblemType() + " instance";
    123       if (openFileDialog.ShowDialog() == DialogResult.OK) {
    124         T instance = default(T);
    125         try {
    126           instance = Content.LoadData(openFileDialog.FileName);
    127         }
    128         catch (Exception ex) {
    129           MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
    130           return;
    131         }
    132         try {
    133           GenericConsumer.Load(instance);
    134         }
    135         catch (Exception ex) {
    136           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");
    137         }
    138       }
    139     }
    140 
    141     protected virtual void exportButton_Click(object sender, EventArgs e) {
    142       if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    143         try {
    144           Content.SaveData(GenericExporter.Export(), saveFileDialog.FileName);
    145         }
    146         catch (Exception ex) {
    147           ErrorHandling.ShowErrorDialog(this, ex);
    148         }
    149       }
    150     }
    151 
    152     private void comboBox_DataSourceChanged(object sender, EventArgs e) {
     99    private void instancesComboBox_DataSourceChanged(object sender, EventArgs e) {
    153100      var comboBox = (ComboBox)sender;
    154101      if (comboBox.DataSource == null)
    155102        comboBox.Items.Clear();
    156103    }
    157 
    158     protected virtual string GetProblemType() {
    159       string dataTypeName = typeof(T).Name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last();
    160       if (dataTypeName.EndsWith("Data"))
    161         return dataTypeName.Substring(0, dataTypeName.Length - "Data".Length);
    162       else return dataTypeName;
    163     }
    164104  }
    165105}
  • trunk/sources/HeuristicLab.Problems.Instances/3.3/Types/VRP/IVRPData.cs

    r7880 r7956  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2622
    2723namespace HeuristicLab.Problems.Instances {
Note: See TracChangeset for help on using the changeset viewer.