Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/13/16 10:51:56 (8 years ago)
Author:
abeham
Message:

#2431: Refactored ResultsParameter

Location:
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/ResultParameterView.Designer.cs

    r12764 r14058  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2626    /// </summary>
    2727    private System.ComponentModel.IContainer components = null;
    28 
    29     /// <summary>
    30     /// Clean up any resources being used.
    31     /// </summary>
    32     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    33     protected override void Dispose(bool disposing) {
    34       if (disposing) {
    35         if (components != null) components.Dispose();
    36       }
    37       base.Dispose(disposing);
    38     }
    39 
     28   
    4029    #region Component Designer generated code
    4130
     
    4534    /// </summary>
    4635    private void InitializeComponent() {
    47       this.resultNameTextBox = new System.Windows.Forms.TextBox();
    48       this.resultNameLabel = new System.Windows.Forms.Label();
     36      this.resultCollectionNameTextBox = new System.Windows.Forms.TextBox();
     37      this.resultCollectionNameLabel = new System.Windows.Forms.Label();
     38      this.defaultValueGroupBox = new System.Windows.Forms.GroupBox();
     39      this.removeDefaultValueButton = new System.Windows.Forms.Button();
     40      this.setDefaultValueButton = new System.Windows.Forms.Button();
     41      this.defaultValueViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4942      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     43      this.defaultValueGroupBox.SuspendLayout();
    5044      this.SuspendLayout();
    5145      //
    52       // dataTypeLabel
     46      // actualNameTextBox
    5347      //
    54       this.dataTypeLabel.Location = new System.Drawing.Point(3, 55);
    55       this.dataTypeLabel.TabIndex = 5;
     48      this.actualNameTextBox.Location = new System.Drawing.Point(98, 26);
     49      this.actualNameTextBox.Size = new System.Drawing.Size(288, 20);
    5650      //
    5751      // dataTypeTextBox
    5852      //
    59       this.dataTypeTextBox.Location = new System.Drawing.Point(80, 52);
    60       this.dataTypeTextBox.Size = new System.Drawing.Size(306, 20);
    61       this.dataTypeTextBox.TabIndex = 6;
     53      this.dataTypeTextBox.Location = new System.Drawing.Point(98, 52);
     54      this.dataTypeTextBox.Size = new System.Drawing.Size(288, 20);
    6255      //
    6356      // nameTextBox
     
    6558      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    6659      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    67       this.nameTextBox.Location = new System.Drawing.Point(80, 0);
    68       this.nameTextBox.Size = new System.Drawing.Size(281, 20);
     60      this.nameTextBox.Location = new System.Drawing.Point(98, 0);
     61      this.nameTextBox.Size = new System.Drawing.Size(263, 20);
    6962      //
    70       // infoLabel
     63      // resultCollectionNameTextBox
    7164      //
    72       this.infoLabel.Location = new System.Drawing.Point(367, 3);
     65      this.resultCollectionNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     66            | System.Windows.Forms.AnchorStyles.Right)));
     67      this.resultCollectionNameTextBox.Location = new System.Drawing.Point(98, 78);
     68      this.resultCollectionNameTextBox.Name = "resultCollectionNameTextBox";
     69      this.resultCollectionNameTextBox.Size = new System.Drawing.Size(288, 20);
     70      this.resultCollectionNameTextBox.TabIndex = 6;
     71      this.resultCollectionNameTextBox.Validated += new System.EventHandler(this.resultNameTextBox_Validated);
    7372      //
    74       // actualNameTextBox
     73      // resultCollectionNameLabel
    7574      //
    76       this.actualNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    77                   | System.Windows.Forms.AnchorStyles.Right)));
    78       this.actualNameTextBox.Location = new System.Drawing.Point(80, 26);
    79       this.actualNameTextBox.Name = "actualNameTextBox";
    80       this.actualNameTextBox.Size = new System.Drawing.Size(306, 20);
    81       this.actualNameTextBox.TabIndex = 4;
    82       this.actualNameTextBox.Validated += new System.EventHandler(this.actualNameTextBox_Validated);
     75      this.resultCollectionNameLabel.AutoSize = true;
     76      this.resultCollectionNameLabel.Location = new System.Drawing.Point(3, 81);
     77      this.resultCollectionNameLabel.Name = "resultCollectionNameLabel";
     78      this.resultCollectionNameLabel.Size = new System.Drawing.Size(89, 13);
     79      this.resultCollectionNameLabel.TabIndex = 5;
     80      this.resultCollectionNameLabel.Text = "&Result Collection:";
    8381      //
    84       // actualNameLabel
     82      // defaultValueGroupBox
    8583      //
    86       this.actualNameLabel.AutoSize = true;
    87       this.actualNameLabel.Location = new System.Drawing.Point(3, 29);
    88       this.actualNameLabel.Name = "actualNameLabel";
    89       this.actualNameLabel.Size = new System.Drawing.Size(71, 13);
    90       this.actualNameLabel.TabIndex = 3;
    91       this.actualNameLabel.Text = "&Actual Name:";
     84      this.defaultValueGroupBox.AllowDrop = true;
     85      this.defaultValueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     86            | System.Windows.Forms.AnchorStyles.Left)
     87            | System.Windows.Forms.AnchorStyles.Right)));
     88      this.defaultValueGroupBox.Controls.Add(this.removeDefaultValueButton);
     89      this.defaultValueGroupBox.Controls.Add(this.setDefaultValueButton);
     90      this.defaultValueGroupBox.Controls.Add(this.defaultValueViewHost);
     91      this.defaultValueGroupBox.Location = new System.Drawing.Point(0, 104);
     92      this.defaultValueGroupBox.Name = "defaultValueGroupBox";
     93      this.defaultValueGroupBox.Size = new System.Drawing.Size(386, 222);
     94      this.defaultValueGroupBox.TabIndex = 7;
     95      this.defaultValueGroupBox.TabStop = false;
     96      this.defaultValueGroupBox.Text = "Default Value";
     97      this.defaultValueGroupBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.defaultValueGroupBox_DragDrop);
     98      this.defaultValueGroupBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.defaultValueGroupBox_DragEnterOver);
     99      this.defaultValueGroupBox.DragOver += new System.Windows.Forms.DragEventHandler(this.defaultValueGroupBox_DragEnterOver);
    92100      //
    93       // resultNameTextBox
     101      // removeDefaultValueButton
    94102      //
    95       this.resultNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    96                   | System.Windows.Forms.AnchorStyles.Right)));
    97       this.resultNameTextBox.Location = new System.Drawing.Point(80, 78);
    98       this.resultNameTextBox.Name = "resultNameTextBox";
    99       this.resultNameTextBox.Size = new System.Drawing.Size(306, 20);
    100       this.resultNameTextBox.TabIndex = 6;
    101       this.resultNameTextBox.Validated += new System.EventHandler(this.resultNameTextBox_Validated);
     103      this.removeDefaultValueButton.Location = new System.Drawing.Point(38, 19);
     104      this.removeDefaultValueButton.Name = "removeDefaultValueButton";
     105      this.removeDefaultValueButton.Size = new System.Drawing.Size(26, 23);
     106      this.removeDefaultValueButton.TabIndex = 1;
     107      this.removeDefaultValueButton.Text = "Remove";
     108      this.removeDefaultValueButton.UseVisualStyleBackColor = true;
     109      this.removeDefaultValueButton.Click += new System.EventHandler(this.removeDefaultValueButton_Click);
    102110      //
    103       // resultNameLabel
     111      // setDefaultValueButton
    104112      //
    105       this.resultNameLabel.AutoSize = true;
    106       this.resultNameLabel.Location = new System.Drawing.Point(3, 81);
    107       this.resultNameLabel.Name = "resultNameLabel";
    108       this.resultNameLabel.Size = new System.Drawing.Size(71, 13);
    109       this.resultNameLabel.TabIndex = 5;
    110       this.resultNameLabel.Text = "&Result Name:";
     113      this.setDefaultValueButton.Location = new System.Drawing.Point(6, 19);
     114      this.setDefaultValueButton.Name = "setDefaultValueButton";
     115      this.setDefaultValueButton.Size = new System.Drawing.Size(26, 23);
     116      this.setDefaultValueButton.TabIndex = 1;
     117      this.setDefaultValueButton.Text = "Set";
     118      this.setDefaultValueButton.UseVisualStyleBackColor = true;
     119      this.setDefaultValueButton.Click += new System.EventHandler(this.setDefaultValueButton_Click);
    111120      //
    112       // LookupParameterView
     121      // defaultValueViewHost
    113122      //
    114       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     123      this.defaultValueViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     124            | System.Windows.Forms.AnchorStyles.Left)
     125            | System.Windows.Forms.AnchorStyles.Right)));
     126      this.defaultValueViewHost.Caption = "View";
     127      this.defaultValueViewHost.Content = null;
     128      this.defaultValueViewHost.Enabled = false;
     129      this.defaultValueViewHost.Location = new System.Drawing.Point(6, 48);
     130      this.defaultValueViewHost.Name = "defaultValueViewHost";
     131      this.defaultValueViewHost.ReadOnly = false;
     132      this.defaultValueViewHost.Size = new System.Drawing.Size(374, 168);
     133      this.defaultValueViewHost.TabIndex = 0;
     134      this.defaultValueViewHost.ViewsLabelVisible = true;
     135      this.defaultValueViewHost.ViewType = null;
     136      //
     137      // ResultParameterView
     138      //
    115139      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    116       this.Controls.Add(this.resultNameTextBox);
    117       this.Controls.Add(this.resultNameLabel);
     140      this.Controls.Add(this.defaultValueGroupBox);
     141      this.Controls.Add(this.resultCollectionNameTextBox);
     142      this.Controls.Add(this.resultCollectionNameLabel);
    118143      this.Name = "ResultParameterView";
    119       this.Size = new System.Drawing.Size(386, 76);
     144      this.Size = new System.Drawing.Size(386, 326);
    120145      this.Controls.SetChildIndex(this.dataTypeLabel, 0);
    121146      this.Controls.SetChildIndex(this.dataTypeTextBox, 0);
     
    125150      this.Controls.SetChildIndex(this.actualNameTextBox, 0);
    126151      this.Controls.SetChildIndex(this.nameLabel, 0);
    127       this.Controls.SetChildIndex(this.resultNameLabel, 0);
    128       this.Controls.SetChildIndex(this.resultNameTextBox, 0);
     152      this.Controls.SetChildIndex(this.resultCollectionNameLabel, 0);
     153      this.Controls.SetChildIndex(this.resultCollectionNameTextBox, 0);
     154      this.Controls.SetChildIndex(this.defaultValueGroupBox, 0);
    129155      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     156      this.defaultValueGroupBox.ResumeLayout(false);
    130157      this.ResumeLayout(false);
    131158      this.PerformLayout();
     
    135162    #endregion
    136163
    137     protected System.Windows.Forms.TextBox resultNameTextBox;
    138     protected System.Windows.Forms.Label resultNameLabel;
     164    protected System.Windows.Forms.TextBox resultCollectionNameTextBox;
     165    protected System.Windows.Forms.Label resultCollectionNameLabel;
     166    private System.Windows.Forms.GroupBox defaultValueGroupBox;
     167    private MainForm.WindowsForms.ViewHost defaultValueViewHost;
     168    private System.Windows.Forms.Button removeDefaultValueButton;
     169    private System.Windows.Forms.Button setDefaultValueButton;
    139170  }
    140171}
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/ResultParameterView.cs

    r12764 r14058  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Windows.Forms;
     24using HeuristicLab.Common.Resources;
    2325using HeuristicLab.Core;
     26using HeuristicLab.Core.Views;
    2427using HeuristicLab.MainForm;
    2528using HeuristicLab.Parameters.Views;
     29using HeuristicLab.PluginInfrastructure;
    2630
    2731namespace HeuristicLab.Optimization.Views {
     
    2933  [Content(typeof(ResultParameter<>), true)]
    3034  [Content(typeof(IResultParameter<>), false)]
    31   public partial class ResultParameterView<T> : LookupParameterView<ResultCollection> where T : class, IItem, new() {
     35  public partial class ResultParameterView<T> : LookupParameterView<T> where T : class, IItem {
     36    protected TypeSelectorDialog typeSelectorDialog;
    3237
    3338    public new IResultParameter<T> Content {
     
    3843    public ResultParameterView() {
    3944      InitializeComponent();
     45      setDefaultValueButton.Text = string.Empty;
     46      setDefaultValueButton.Image = VSImageLibrary.Edit;
     47      removeDefaultValueButton.Text = string.Empty;
     48      removeDefaultValueButton.Image = VSImageLibrary.Remove;
     49    }
     50
     51    /// <summary>
     52    /// Clean up any resources being used.
     53    /// </summary>
     54    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
     55    protected override void Dispose(bool disposing) {
     56      if (disposing) {
     57        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
     58        if (components != null) components.Dispose();
     59      }
     60      base.Dispose(disposing);
    4061    }
    4162
    4263    protected override void DeregisterContentEvents() {
    43       Content.ResultNameChanged -= new EventHandler(Content_ResultNameChanged);
     64      Content.ResultCollectionNameChanged -= ContentOnResultCollectionNameChanged;
     65      Content.DefaultValueChanged -= ContentOnDefaultValueChanged;
    4466      base.DeregisterContentEvents();
    4567    }
     
    4769    protected override void RegisterContentEvents() {
    4870      base.RegisterContentEvents();
    49       Content.ResultNameChanged += new EventHandler(Content_ResultNameChanged);
     71      Content.ResultCollectionNameChanged += ContentOnResultCollectionNameChanged;
     72      Content.DefaultValueChanged += ContentOnDefaultValueChanged;
    5073    }
    5174
    5275    protected override void OnContentChanged() {
    5376      base.OnContentChanged();
    54       if (Content == null)
    55         resultNameTextBox.Text = "-";
    56       else
    57         resultNameTextBox.Text = Content.ResultName;
     77      if (Content == null) {
     78        resultCollectionNameTextBox.Text = "-";
     79        defaultValueViewHost.Content = null;
     80      } else {
     81        resultCollectionNameTextBox.Text = Content.ResultCollectionName;
     82        defaultValueViewHost.Content = Content.DefaultValue;
     83      }
    5884    }
    5985
    6086    protected override void SetEnabledStateOfControls() {
    6187      base.SetEnabledStateOfControls();
    62       resultNameTextBox.Enabled = Content != null;
    63       resultNameTextBox.ReadOnly = ReadOnly;
     88      resultCollectionNameTextBox.Enabled = Content != null;
     89      resultCollectionNameTextBox.ReadOnly = ReadOnly;
    6490    }
    6591
    66     private void Content_ResultNameChanged(object sender, EventArgs e) {
    67       if (InvokeRequired)
    68         Invoke(new EventHandler(Content_ResultNameChanged), sender, e);
    69       else
    70         resultNameTextBox.Text = Content.ResultName;
     92    private void ContentOnDefaultValueChanged(object sender, EventArgs e) {
     93      if (InvokeRequired) Invoke((Action<object, EventArgs>)ContentOnDefaultValueChanged, sender, e);
     94      else defaultValueViewHost.Content = Content.DefaultValue;
     95    }
     96
     97    private void ContentOnResultCollectionNameChanged(object sender, EventArgs e) {
     98      if (InvokeRequired) Invoke((Action<object, EventArgs>)ContentOnResultCollectionNameChanged, sender, e);
     99      else resultCollectionNameTextBox.Text = Content.ResultCollectionName;
    71100    }
    72101
    73102    private void resultNameTextBox_Validated(object sender, EventArgs e) {
    74       Content.ResultName = resultNameTextBox.Text;
     103      if (InvokeRequired) Invoke((Action<object, EventArgs>)resultNameTextBox_Validated, sender, e);
     104      else Content.ResultCollectionName = resultCollectionNameTextBox.Text;
     105    }
     106
     107    private void setDefaultValueButton_Click(object sender, EventArgs e) {
     108      if (typeSelectorDialog == null) {
     109        typeSelectorDialog = new TypeSelectorDialog();
     110        typeSelectorDialog.Caption = "Select Value";
     111        typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, true);
     112      }
     113      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     114        try {
     115          Content.DefaultValue = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     116        } catch (Exception ex) {
     117          ErrorHandling.ShowErrorDialog(this, ex);
     118        }
     119      }
     120    }
     121
     122    private void removeDefaultValueButton_Click(object sender, EventArgs e) {
     123      Content.DefaultValue = null;
     124    }
     125
     126    protected virtual void defaultValueGroupBox_DragEnterOver(object sender, DragEventArgs e) {
     127      e.Effect = DragDropEffects.None;
     128      if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) != null) && Content.DataType.IsAssignableFrom(e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat).GetType())) {
     129        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     130        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     131        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     132        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     133        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
     134      }
     135    }
     136    protected virtual void defaultValueGroupBox_DragDrop(object sender, DragEventArgs e) {
     137      if (e.Effect != DragDropEffects.None) {
     138        T value = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as T;
     139        if (e.Effect.HasFlag(DragDropEffects.Copy)) value = (T)value.Clone();
     140        Content.DefaultValue = value;
     141      }
    75142    }
    76143  }
Note: See TracChangeset for help on using the changeset viewer.