Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/02/13 20:11:14 (11 years ago)
Author:
abeham
Message:

#2110: merged to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs

    r9456 r10021  
    4646    private void InitializeComponent() {
    4747      this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer();
    48       this.ProblemInstanceConsumerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     48      this.libraryLabel = new System.Windows.Forms.Label();
     49      this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
     50      this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4951      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5052      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
     
    8789      // problemInstanceSplitContainer.Panel1
    8890      //
    89       this.problemInstanceSplitContainer.Panel1.Controls.Add(this.ProblemInstanceConsumerViewHost);
     91      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryLabel);
     92      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox);
     93      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderViewHost);
    9094      this.problemInstanceSplitContainer.Panel1MinSize = 10;
    9195      //
     
    100104      this.problemInstanceSplitContainer.TabIndex = 13;
    101105      //
    102       // ProblemInstanceConsumerViewHost
     106      // libraryLabel
    103107      //
    104       this.ProblemInstanceConsumerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     108      this.libraryLabel.AutoSize = true;
     109      this.libraryLabel.Location = new System.Drawing.Point(3, 6);
     110      this.libraryLabel.Name = "libraryLabel";
     111      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
     112      this.libraryLabel.TabIndex = 17;
     113      this.libraryLabel.Text = "Library:";
     114      //
     115      // problemInstanceProviderComboBox
     116      //
     117      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     118      this.problemInstanceProviderComboBox.FormattingEnabled = true;
     119      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 2);
     120      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
     121      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(208, 21);
     122      this.problemInstanceProviderComboBox.TabIndex = 18;
     123      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
     124      //
     125      // problemInstanceProviderViewHost
     126      //
     127      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    105128            | System.Windows.Forms.AnchorStyles.Left)
    106129            | System.Windows.Forms.AnchorStyles.Right)));
    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;
     130      this.problemInstanceProviderViewHost.Caption = "ProblemInstanceConsumerView";
     131      this.problemInstanceProviderViewHost.Content = null;
     132      this.problemInstanceProviderViewHost.Enabled = false;
     133      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(264, 1);
     134      this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
     135      this.problemInstanceProviderViewHost.ReadOnly = false;
     136      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(247, 23);
     137      this.problemInstanceProviderViewHost.TabIndex = 0;
     138      this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
     139      this.problemInstanceProviderViewHost.ViewType = null;
    117140      //
    118141      // ProblemView
    119142      //
    120       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    121143      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    122144      this.Controls.Add(this.problemInstanceSplitContainer);
     
    125147      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    126148      this.problemInstanceSplitContainer.Panel1.ResumeLayout(false);
     149      this.problemInstanceSplitContainer.Panel1.PerformLayout();
    127150      this.problemInstanceSplitContainer.Panel2.ResumeLayout(false);
    128151      this.problemInstanceSplitContainer.Panel2.PerformLayout();
     
    136159
    137160    protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer;
    138     protected HeuristicLab.MainForm.WindowsForms.ViewHost ProblemInstanceConsumerViewHost;
     161    protected HeuristicLab.MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
     162    protected System.Windows.Forms.Label libraryLabel;
     163    protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
    139164  }
    140165}
  • stable/HeuristicLab.Optimization.Views/3.3/ProblemView.cs

    r9456 r10021  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Windows.Forms;
    2625using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
     
    3736  public partial class ProblemView : ParameterizedNamedItemView {
    3837
    39     private static Type neededViewType = typeof(ProblemInstanceConsumerView);
    40 
    4138    public new IProblem Content {
    4239      get { return (IProblem)base.Content; }
    4340      set { base.Content = value; }
    4441    }
     42
     43    protected IEnumerable<IProblemInstanceProvider> problemInstanceProviders;
     44    public IEnumerable<IProblemInstanceProvider> ProblemInstanceProviders {
     45      get { return new List<IProblemInstanceProvider>(problemInstanceProviders); }
     46    }
     47
     48    public IProblemInstanceProvider SelectedProvider { get; protected set; }
    4549
    4650    /// <summary>
     
    5357    protected override void OnContentChanged() {
    5458      base.OnContentChanged();
    55       IProblemInstanceConsumer consumer = Content as IProblemInstanceConsumer;
    56       if (consumer != null) {
    57         IEnumerable<Type> viewTypes = MainFormManager.GetViewTypes(consumer.GetType(), true);
    58         Type genericView = viewTypes.Where(x => x.IsSubclassOf(neededViewType)).First();
    59         ProblemInstanceConsumerViewHost.Content = null; //necessary to enable the change of the ViewType
    60         ProblemInstanceConsumerViewHost.ViewType = genericView;
    61         ProblemInstanceConsumerViewHost.Content = consumer;
    62         ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)ProblemInstanceConsumerViewHost.ActiveView;
    63         problemInstanceSplitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
     59      if (Content == null) {
     60        problemInstanceProviders = null;
     61        problemInstanceProviderComboBox.DataSource = null;
     62        problemInstanceSplitContainer.Panel1Collapsed = true;
    6463      } else {
    65         problemInstanceSplitContainer.Panel1Collapsed = true;
     64        var consumer = Content as IProblemInstanceConsumer;
     65        if (consumer != null) {
     66          problemInstanceProviders = ProblemInstanceManager.GetProviders(Content);
     67          bool expand = problemInstanceProviders.Any();
     68          if (expand) {
     69            problemInstanceProviderComboBox.DisplayMember = "Name";
     70            problemInstanceProviderComboBox.DataSource = ProblemInstanceProviders.OrderBy(x => x.Name).ToList();
     71          }
     72          problemInstanceSplitContainer.Panel1Collapsed = !expand;
     73        } else
     74          problemInstanceSplitContainer.Panel1Collapsed = true;
    6675      }
    6776      SetEnabledStateOfControls();
    6877    }
    6978
     79    protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     80      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
     81        SelectedProvider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem;
     82        problemInstanceProviderViewHost.Content = SelectedProvider;
     83        var view = (ProblemInstanceProviderView)problemInstanceProviderViewHost.ActiveView;
     84        var consumer = (IProblemInstanceConsumer)Content;
     85        view.Consumer = consumer;
     86        if (CheckForIProblemInstanceExporter(consumer))
     87          view.Exporter = (IProblemInstanceExporter)Content;
     88        else view.Exporter = null;
     89        SetTooltip();
     90      } else {
     91        SelectedProvider = null;
     92      }
     93      SetEnabledStateOfControls();
     94    }
     95
     96    protected bool CheckForIProblemInstanceExporter(IProblemInstanceConsumer content) {
     97      return Content.GetType().GetInterfaces()
     98                    .Any(x => x == typeof(IProblemInstanceExporter));
     99    }
     100
     101    #region ToolTip
     102    protected void SetTooltip() {
     103      toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
     104    }
     105
     106    private string GetProviderToolTip() {
     107      var provider = SelectedProvider;
     108      string toolTip = provider.Name;
     109
     110      if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
     111        toolTip = toolTip
     112            + Environment.NewLine + Environment.NewLine
     113            + provider.ReferencePublication;
     114      }
     115      if (provider.WebLink != null) {
     116        toolTip = toolTip
     117            + Environment.NewLine
     118            + provider.WebLink.ToString();
     119      }
     120
     121      return toolTip;
     122    }
     123    #endregion
    70124  }
    71125}
Note: See TracChangeset for help on using the changeset viewer.