Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/20/12 17:26:56 (12 years ago)
Author:
sforsten
Message:

#1782:

  • HeuristicOptimizationView has been integrated in ProblemView and was deleted afterwards.
  • the icons for the load and the info button have been changed
  • QuadraticAssignmentProblem now also loads name and description of problem instance
  • A unused OpenFileDialog has been removed in QuadraticAssignmentProblemView
Location:
trunk/sources/HeuristicLab.Optimization.Views/3.3
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r7558 r7641  
    264264      <DependentUpon>EngineAlgorithmView.cs</DependentUpon>
    265265    </Compile>
    266     <Compile Include="HeuristicOptimizationProblemView.cs">
    267       <SubType>UserControl</SubType>
    268     </Compile>
    269     <Compile Include="HeuristicOptimizationProblemView.Designer.cs">
    270       <DependentUpon>HeuristicOptimizationProblemView.cs</DependentUpon>
    271     </Compile>
    272266    <Compile Include="Properties\AssemblyInfo.cs" />
    273267    <Compile Include="ResultCollectionView.cs">
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.cs

    r7558 r7641  
    4545      toolTip.SetToolTip(importButton, "Import a " + GetProblemType() + " instance from file.");
    4646      loadButton.Text = String.Empty;
    47       loadButton.Image = VSImageLibrary.Checkout;
     47      loadButton.Image = VSImageLibrary.RefreshDocument;
    4848      toolTip.SetToolTip(loadButton, "Load the selected instance.");
    4949    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs

    r7259 r7641  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
     48      this.libraryLabel = new System.Windows.Forms.Label();
     49      this.libraryInfoButton = new System.Windows.Forms.Button();
     50      this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer();
     51      this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4752      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     53      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
     54      this.problemInstanceSplitContainer.Panel1.SuspendLayout();
     55      this.problemInstanceSplitContainer.Panel2.SuspendLayout();
     56      this.problemInstanceSplitContainer.SuspendLayout();
    4857      this.SuspendLayout();
     58      //
     59      // parameterCollectionView
     60      //
     61      this.parameterCollectionView.Location = new System.Drawing.Point(6, 27);
     62      this.parameterCollectionView.Size = new System.Drawing.Size(501, 303);
    4963      //
    5064      // nameTextBox
     
    5266      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    5367      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
     68      this.nameTextBox.Location = new System.Drawing.Point(47, 1);
     69      this.nameTextBox.Size = new System.Drawing.Size(438, 20);
     70      //
     71      // nameLabel
     72      //
     73      this.nameLabel.Location = new System.Drawing.Point(3, 6);
     74      //
     75      // infoLabel
     76      //
     77      this.infoLabel.Location = new System.Drawing.Point(491, 4);
     78      //
     79      // problemInstanceProviderComboBox
     80      //
     81      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     82      this.problemInstanceProviderComboBox.FormattingEnabled = true;
     83      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(47, 2);
     84      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
     85      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21);
     86      this.problemInstanceProviderComboBox.TabIndex = 13;
     87      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
     88      this.problemInstanceProviderComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
     89      //
     90      // libraryLabel
     91      //
     92      this.libraryLabel.AutoSize = true;
     93      this.libraryLabel.Location = new System.Drawing.Point(3, 6);
     94      this.libraryLabel.Name = "libraryLabel";
     95      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
     96      this.libraryLabel.TabIndex = 12;
     97      this.libraryLabel.Text = "Library:";
     98      //
     99      // libraryInfoButton
     100      //
     101      this.libraryInfoButton.Location = new System.Drawing.Point(224, 1);
     102      this.libraryInfoButton.Name = "libraryInfoButton";
     103      this.libraryInfoButton.Size = new System.Drawing.Size(26, 23);
     104      this.libraryInfoButton.TabIndex = 14;
     105      this.libraryInfoButton.Text = "Info";
     106      this.libraryInfoButton.UseVisualStyleBackColor = true;
     107      this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click);
     108      //
     109      // problemInstanceSplitContainer
     110      //
     111      this.problemInstanceSplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     112                  | System.Windows.Forms.AnchorStyles.Left)
     113                  | System.Windows.Forms.AnchorStyles.Right)));
     114      this.problemInstanceSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     115      this.problemInstanceSplitContainer.IsSplitterFixed = true;
     116      this.problemInstanceSplitContainer.Location = new System.Drawing.Point(0, 0);
     117      this.problemInstanceSplitContainer.Name = "problemInstanceSplitContainer";
     118      this.problemInstanceSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
     119      //
     120      // problemInstanceSplitContainer.Panel1
     121      //
     122      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderViewHost);
     123      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox);
     124      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryInfoButton);
     125      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryLabel);
     126      this.problemInstanceSplitContainer.Panel1MinSize = 10;
     127      //
     128      // problemInstanceSplitContainer.Panel2
     129      //
     130      this.problemInstanceSplitContainer.Panel2.Controls.Add(this.nameLabel);
     131      this.problemInstanceSplitContainer.Panel2.Controls.Add(this.nameTextBox);
     132      this.problemInstanceSplitContainer.Panel2.Controls.Add(this.parameterCollectionView);
     133      this.problemInstanceSplitContainer.Panel2.Controls.Add(this.infoLabel);
     134      this.problemInstanceSplitContainer.Size = new System.Drawing.Size(511, 363);
     135      this.problemInstanceSplitContainer.SplitterDistance = 26;
     136      this.problemInstanceSplitContainer.TabIndex = 13;
     137      //
     138      // problemInstanceProviderViewHost
     139      //
     140      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     141                  | System.Windows.Forms.AnchorStyles.Right)));
     142      this.problemInstanceProviderViewHost.Caption = "View";
     143      this.problemInstanceProviderViewHost.Content = null;
     144      this.problemInstanceProviderViewHost.Enabled = false;
     145      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(256, 3);
     146      this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
     147      this.problemInstanceProviderViewHost.ReadOnly = false;
     148      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(251, 22);
     149      this.problemInstanceProviderViewHost.TabIndex = 15;
     150      this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
     151      this.problemInstanceProviderViewHost.ViewType = null;
    54152      //
    55153      // ProblemView
     
    57155      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    58156      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     157      this.Controls.Add(this.problemInstanceSplitContainer);
    59158      this.Name = "ProblemView";
     159      this.Size = new System.Drawing.Size(511, 363);
    60160      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     161      this.problemInstanceSplitContainer.Panel1.ResumeLayout(false);
     162      this.problemInstanceSplitContainer.Panel1.PerformLayout();
     163      this.problemInstanceSplitContainer.Panel2.ResumeLayout(false);
     164      this.problemInstanceSplitContainer.Panel2.PerformLayout();
     165      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).EndInit();
     166      this.problemInstanceSplitContainer.ResumeLayout(false);
    61167      this.ResumeLayout(false);
    62       this.PerformLayout();
    63168
    64169    }
     
    66171    #endregion
    67172
    68 
     173    protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
     174    protected System.Windows.Forms.Label libraryLabel;
     175    protected System.Windows.Forms.Button libraryInfoButton;
     176    protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer;
     177    protected MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
    69178  }
    70179}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs

    r7259 r7641  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Diagnostics;
     25using System.Linq;
     26using System.Windows.Forms;
     27using HeuristicLab.Common.Resources;
    2228using HeuristicLab.Core.Views;
    2329using HeuristicLab.MainForm;
     30using HeuristicLab.PluginInfrastructure;
     31using HeuristicLab.Problems.Instances;
    2432
    2533namespace HeuristicLab.Optimization.Views {
     
    3543    }
    3644
     45    protected IProblemInstanceProvider SelectedProvider {
     46      get { return (problemInstanceProviderComboBox.SelectedIndex >= 0 ? (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem : null); }
     47    }
     48
    3749    /// <summary>
    3850    /// Initializes a new instance of <see cref="ItemBaseView"/>.
     
    4052    public ProblemView() {
    4153      InitializeComponent();
     54      libraryInfoButton.Text = String.Empty;
     55      libraryInfoButton.Image = VSImageLibrary.Internet;
    4256    }
    4357
    4458    protected override void OnContentChanged() {
    4559      base.OnContentChanged();
     60      if (Content == null) {
     61        problemInstanceProviderComboBox.DataSource = null;
     62      } else {
     63        problemInstanceProviderComboBox.DisplayMember = "Name";
     64        problemInstanceProviderComboBox.DataSource = GetProblemInstanceProviders().ToList();
     65        problemInstanceSplitContainer.Panel1Collapsed = problemInstanceProviderComboBox.Items.Count <= 0;
     66
     67      }
     68      SetEnabledStateOfControls();
     69    }
     70
     71    protected override void SetEnabledStateOfControls() {
     72      base.SetEnabledStateOfControls();
     73      problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
     74      libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
     75    }
     76
     77    protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     78      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
     79        dynamic provider = SelectedProvider;
     80        dynamic consumer = Content;
     81        provider.Consumer = consumer;
     82        problemInstanceProviderViewHost.Content = SelectedProvider;
     83        SetTooltip();
     84      }
     85      SetEnabledStateOfControls();
     86    }
     87
     88    private void comboBox_DataSourceChanged(object sender, EventArgs e) {
     89      var comboBox = (ComboBox)sender;
     90      if (comboBox.DataSource == null)
     91        comboBox.Items.Clear();
     92    }
     93
     94    protected virtual void libraryInfoButton_Click(object sender, EventArgs e) {
     95      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
     96        if (SelectedProvider != null && SelectedProvider.WebLink != null)
     97          Process.Start(SelectedProvider.WebLink.ToString());
     98      }
     99    }
     100
     101    protected virtual IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders() {
     102      var consumerTypes = Content.GetType().GetInterfaces()
     103        .Where(x => x.IsGenericType
     104          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
     105
     106      if (consumerTypes.Any()) {
     107        var instanceTypes = consumerTypes
     108          .Select(x => x.GetGenericArguments().First())
     109          .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x));
     110
     111        foreach (var type in instanceTypes) {
     112          foreach (var provider in ApplicationManager.Manager.GetInstances(type))
     113            yield return (IProblemInstanceProvider)provider;
     114        }
     115      }
     116    }
     117
     118    protected virtual void SetTooltip() {
     119      toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
     120      if (SelectedProvider.WebLink != null)
     121        toolTip.SetToolTip(libraryInfoButton, "Browse to " + SelectedProvider.WebLink.ToString());
     122      else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference.");
     123    }
     124
     125    protected virtual string GetProviderToolTip() {
     126      var provider = SelectedProvider;
     127      string toolTip = provider.Name;
     128
     129      if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
     130        toolTip = toolTip
     131            + Environment.NewLine + Environment.NewLine
     132            + provider.ReferencePublication;
     133      }
     134      if (provider.WebLink != null) {
     135        toolTip = toolTip
     136            + Environment.NewLine
     137            + provider.WebLink.ToString();
     138      }
     139
     140      return toolTip;
    46141    }
    47142  }
Note: See TracChangeset for help on using the changeset viewer.