Changeset 12466


Ignore:
Timestamp:
06/18/15 11:17:50 (4 years ago)
Author:
pfleck
Message:

#2366 Merged trunk to fix compile errors caused by changes of the DefineArithmeticProgressionDialog from r12293.

Location:
branches/EnumValue in CreateExperiment/HeuristicLab.Optimizer
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/EnumValue in CreateExperiment/HeuristicLab.Optimizer

  • branches/EnumValue in CreateExperiment/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r12268 r12466  
    286286      var parameter = (IValueParameter)generateButton.Tag;
    287287      bool integerOnly = intParameters.ContainsKey(parameter);
    288       double min = 0, max = 1, step = 1;
     288      decimal min = 0, max = 1, step = 1;
    289289      #region Try to calculate some meaningful values
    290290      if (integerOnly) {
     
    298298        int len = doubleParameters[parameter].Length;
    299299        if (len > 0) {
    300           min = doubleParameters[parameter].Min();
    301           max = doubleParameters[parameter].Max();
    302           step = len >= 2 ? Math.Abs((doubleParameters[parameter][len - 1] - doubleParameters[parameter][len - 2])) : 1;
     300          min = (decimal)doubleParameters[parameter].Min();
     301          max = (decimal)doubleParameters[parameter].Max();
     302          step = len >= 2 ? Math.Abs(((decimal)doubleParameters[parameter][len - 1] - (decimal)doubleParameters[parameter][len - 2])) : 1m;
    303303        }
    304304      }
     
    314314          } else {
    315315            doubleParameters[parameter].Reset -= new EventHandler(ValuesArray_Reset);
    316             doubleParameters[parameter] = new DoubleArray(values.ToArray());
     316            doubleParameters[parameter] = new DoubleArray(values.Select(x => (double)x).ToArray());
    317317            doubleParameters[parameter].Reset += new EventHandler(ValuesArray_Reset);
    318318            stringConvertibleArrayView.Content = doubleParameters[parameter];
  • branches/EnumValue in CreateExperiment/HeuristicLab.Optimizer/3.3/NewItemDialog.Designer.cs

    r12012 r12466  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NewItemDialog));
    4849      this.okButton = new System.Windows.Forms.Button();
    4950      this.cancelButton = new System.Windows.Forms.Button();
    50       this.itemsListView = new System.Windows.Forms.ListView();
    51       this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();
    52       this.descriptioncolumnHeader = new System.Windows.Forms.ColumnHeader();
    5351      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    54       this.versionColumnHeader = new System.Windows.Forms.ColumnHeader();
     52      this.searchLabel = new System.Windows.Forms.Label();
     53      this.searchTextBox = new System.Windows.Forms.TextBox();
     54      this.clearSearchButton = new System.Windows.Forms.Button();
     55      this.splitContainer = new System.Windows.Forms.SplitContainer();
     56      this.availableItemsGroupBox = new System.Windows.Forms.GroupBox();
     57      this.typesTreeView = new System.Windows.Forms.TreeView();
     58      this.imageList = new System.Windows.Forms.ImageList(this.components);
     59      this.descriptionSplitContainer = new System.Windows.Forms.SplitContainer();
     60      this.itemGroupBox = new System.Windows.Forms.GroupBox();
     61      this.itemDescriptionTextBox = new System.Windows.Forms.TextBox();
     62      this.pluginDescriptionGroupBox = new System.Windows.Forms.GroupBox();
     63      this.versionTextBox = new System.Windows.Forms.TextBox();
     64      this.pluginTextBox = new System.Windows.Forms.TextBox();
     65      this.pluginDescriptionTextBox = new System.Windows.Forms.TextBox();
     66      this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     67      this.expandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     68      this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     69      this.collapseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     70      this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     71      this.searchTextBox.SuspendLayout();
     72      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     73      this.splitContainer.Panel1.SuspendLayout();
     74      this.splitContainer.Panel2.SuspendLayout();
     75      this.splitContainer.SuspendLayout();
     76      this.availableItemsGroupBox.SuspendLayout();
     77      ((System.ComponentModel.ISupportInitialize)(this.descriptionSplitContainer)).BeginInit();
     78      this.descriptionSplitContainer.Panel1.SuspendLayout();
     79      this.descriptionSplitContainer.Panel2.SuspendLayout();
     80      this.descriptionSplitContainer.SuspendLayout();
     81      this.itemGroupBox.SuspendLayout();
     82      this.pluginDescriptionGroupBox.SuspendLayout();
     83      this.contextMenuStrip.SuspendLayout();
    5584      this.SuspendLayout();
    5685      //
     
    6089      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    6190      this.okButton.Enabled = false;
    62       this.okButton.Location = new System.Drawing.Point(456, 409);
     91      this.okButton.Location = new System.Drawing.Point(456, 587);
    6392      this.okButton.Name = "okButton";
    6493      this.okButton.Size = new System.Drawing.Size(75, 23);
    65       this.okButton.TabIndex = 2;
     94      this.okButton.TabIndex = 1;
    6695      this.okButton.Text = "&OK";
    6796      this.okButton.UseVisualStyleBackColor = true;
     
    72101      this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    73102      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    74       this.cancelButton.Location = new System.Drawing.Point(537, 409);
     103      this.cancelButton.Location = new System.Drawing.Point(537, 587);
    75104      this.cancelButton.Name = "cancelButton";
    76105      this.cancelButton.Size = new System.Drawing.Size(75, 23);
    77       this.cancelButton.TabIndex = 3;
     106      this.cancelButton.TabIndex = 2;
    78107      this.cancelButton.Text = "&Cancel";
    79108      this.cancelButton.UseVisualStyleBackColor = true;
    80109      //
    81       // itemsListView
    82       //
    83       this.itemsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    84                   | System.Windows.Forms.AnchorStyles.Left)
    85                   | System.Windows.Forms.AnchorStyles.Right)));
    86       this.itemsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
    87             this.nameColumnHeader,
    88             this.versionColumnHeader,
    89             this.descriptioncolumnHeader});
    90       this.itemsListView.FullRowSelect = true;
    91       this.itemsListView.HideSelection = false;
    92       this.itemsListView.Location = new System.Drawing.Point(12, 12);
    93       this.itemsListView.MultiSelect = false;
    94       this.itemsListView.Name = "itemsListView";
    95       this.itemsListView.Size = new System.Drawing.Size(600, 391);
    96       this.itemsListView.TabIndex = 1;
    97       this.itemsListView.UseCompatibleStateImageBehavior = false;
    98       this.itemsListView.View = System.Windows.Forms.View.Details;
    99       this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemTypesListView_SelectedIndexChanged);
    100       this.itemsListView.DoubleClick += new System.EventHandler(this.itemTypesListView_DoubleClick);
    101       //
    102       // nameColumnHeader
    103       //
    104       this.nameColumnHeader.DisplayIndex = 0;
    105       this.nameColumnHeader.Text = "Name";
    106       this.nameColumnHeader.Width = 91;
    107       //
    108       // descriptioncolumnHeader
    109       //
    110       this.descriptioncolumnHeader.DisplayIndex = 2;
    111       this.descriptioncolumnHeader.Text = "Description";
    112       this.descriptioncolumnHeader.Width = 190;
    113       //
    114       // versionColumnHeader
    115       //
    116       this.versionColumnHeader.DisplayIndex = 1;
    117       this.versionColumnHeader.Text = "Version";
     110      // searchLabel
     111      //
     112      this.searchLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
     113      this.searchLabel.Location = new System.Drawing.Point(6, 17);
     114      this.searchLabel.Name = "searchLabel";
     115      this.searchLabel.Size = new System.Drawing.Size(20, 20);
     116      this.searchLabel.TabIndex = 0;
     117      this.toolTip.SetToolTip(this.searchLabel, "Enter string to search for items");
     118      //
     119      // searchTextBox
     120      //
     121      this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     122            | System.Windows.Forms.AnchorStyles.Left)
     123            | System.Windows.Forms.AnchorStyles.Right)));
     124      this.searchTextBox.Controls.Add(this.clearSearchButton);
     125      this.searchTextBox.Location = new System.Drawing.Point(32, 17);
     126      this.searchTextBox.Name = "searchTextBox";
     127      this.searchTextBox.Size = new System.Drawing.Size(562, 20);
     128      this.searchTextBox.TabIndex = 1;
     129      this.toolTip.SetToolTip(this.searchTextBox, "Filters the available Items.\r\nThe search term is tokenized by space and a name ha" +
     130        "s to contain all tokens to be displayed.\r\n(E.g. \"Sym Reg\" matches \"Symbolic Regr" +
     131        "ession\")");
     132      this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged);
     133      this.searchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchTextBox_KeyDown);
     134      //
     135      // clearSearchButton
     136      //
     137      this.clearSearchButton.BackColor = System.Drawing.Color.Transparent;
     138      this.clearSearchButton.Cursor = System.Windows.Forms.Cursors.Default;
     139      this.clearSearchButton.Dock = System.Windows.Forms.DockStyle.Right;
     140      this.clearSearchButton.FlatAppearance.BorderSize = 0;
     141      this.clearSearchButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
     142      this.clearSearchButton.ForeColor = System.Drawing.Color.Transparent;
     143      this.clearSearchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Delete;
     144      this.clearSearchButton.Location = new System.Drawing.Point(543, 0);
     145      this.clearSearchButton.Margin = new System.Windows.Forms.Padding(0);
     146      this.clearSearchButton.Name = "clearSearchButton";
     147      this.clearSearchButton.Size = new System.Drawing.Size(15, 16);
     148      this.clearSearchButton.TabIndex = 0;
     149      this.clearSearchButton.TabStop = false;
     150      this.clearSearchButton.UseVisualStyleBackColor = false;
     151      this.clearSearchButton.Click += new System.EventHandler(this.clearSearchButton_Click);
     152      //
     153      // splitContainer
     154      //
     155      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     156            | System.Windows.Forms.AnchorStyles.Left)
     157            | System.Windows.Forms.AnchorStyles.Right)));
     158      this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
     159      this.splitContainer.Location = new System.Drawing.Point(12, 12);
     160      this.splitContainer.Name = "splitContainer";
     161      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
     162      //
     163      // splitContainer.Panel1
     164      //
     165      this.splitContainer.Panel1.Controls.Add(this.availableItemsGroupBox);
     166      //
     167      // splitContainer.Panel2
     168      //
     169      this.splitContainer.Panel2.Controls.Add(this.descriptionSplitContainer);
     170      this.splitContainer.Size = new System.Drawing.Size(600, 569);
     171      this.splitContainer.SplitterDistance = 373;
     172      this.splitContainer.TabIndex = 0;
     173      this.splitContainer.TabStop = false;
     174      //
     175      // availableItemsGroupBox
     176      //
     177      this.availableItemsGroupBox.Controls.Add(this.searchLabel);
     178      this.availableItemsGroupBox.Controls.Add(this.searchTextBox);
     179      this.availableItemsGroupBox.Controls.Add(this.typesTreeView);
     180      this.availableItemsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     181      this.availableItemsGroupBox.Location = new System.Drawing.Point(0, 0);
     182      this.availableItemsGroupBox.Name = "availableItemsGroupBox";
     183      this.availableItemsGroupBox.Padding = new System.Windows.Forms.Padding(3, 15, 3, 3);
     184      this.availableItemsGroupBox.Size = new System.Drawing.Size(600, 373);
     185      this.availableItemsGroupBox.TabIndex = 5;
     186      this.availableItemsGroupBox.TabStop = false;
     187      this.availableItemsGroupBox.Text = "Available Items";
     188      //
     189      // typesTreeView
     190      //
     191      this.typesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     192            | System.Windows.Forms.AnchorStyles.Left)
     193            | System.Windows.Forms.AnchorStyles.Right)));
     194      this.typesTreeView.HideSelection = false;
     195      this.typesTreeView.ImageIndex = 0;
     196      this.typesTreeView.ImageList = this.imageList;
     197      this.typesTreeView.Location = new System.Drawing.Point(6, 41);
     198      this.typesTreeView.Name = "typesTreeView";
     199      this.typesTreeView.SelectedImageIndex = 0;
     200      this.typesTreeView.ShowNodeToolTips = true;
     201      this.typesTreeView.Size = new System.Drawing.Size(588, 326);
     202      this.typesTreeView.TabIndex = 2;
     203      this.typesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.itemsTreeView_AfterSelect);
     204      this.typesTreeView.VisibleChanged += new System.EventHandler(this.itemsTreeView_VisibleChanged);
     205      this.typesTreeView.DoubleClick += new System.EventHandler(this.itemTreeView_DoubleClick);
     206      this.typesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.typesTreeView_MouseDown);
     207      //
     208      // imageList
     209      //
     210      this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     211      this.imageList.ImageSize = new System.Drawing.Size(16, 16);
     212      this.imageList.TransparentColor = System.Drawing.Color.Transparent;
     213      //
     214      // descriptionSplitContainer
     215      //
     216      this.descriptionSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     217      this.descriptionSplitContainer.Location = new System.Drawing.Point(0, 0);
     218      this.descriptionSplitContainer.Name = "descriptionSplitContainer";
     219      this.descriptionSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
     220      //
     221      // descriptionSplitContainer.Panel1
     222      //
     223      this.descriptionSplitContainer.Panel1.Controls.Add(this.itemGroupBox);
     224      //
     225      // descriptionSplitContainer.Panel2
     226      //
     227      this.descriptionSplitContainer.Panel2.Controls.Add(this.pluginDescriptionGroupBox);
     228      this.descriptionSplitContainer.Size = new System.Drawing.Size(600, 192);
     229      this.descriptionSplitContainer.SplitterDistance = 81;
     230      this.descriptionSplitContainer.TabIndex = 1;
     231      this.descriptionSplitContainer.TabStop = false;
     232      //
     233      // itemGroupBox
     234      //
     235      this.itemGroupBox.Controls.Add(this.itemDescriptionTextBox);
     236      this.itemGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     237      this.itemGroupBox.Location = new System.Drawing.Point(0, 0);
     238      this.itemGroupBox.Name = "itemGroupBox";
     239      this.itemGroupBox.Size = new System.Drawing.Size(600, 81);
     240      this.itemGroupBox.TabIndex = 1;
     241      this.itemGroupBox.TabStop = false;
     242      this.itemGroupBox.Text = "Item";
     243      //
     244      // itemDescriptionTextBox
     245      //
     246      this.itemDescriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     247            | System.Windows.Forms.AnchorStyles.Left)
     248            | System.Windows.Forms.AnchorStyles.Right)));
     249      this.itemDescriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     250      this.itemDescriptionTextBox.Location = new System.Drawing.Point(6, 19);
     251      this.itemDescriptionTextBox.Multiline = true;
     252      this.itemDescriptionTextBox.Name = "itemDescriptionTextBox";
     253      this.itemDescriptionTextBox.ReadOnly = true;
     254      this.itemDescriptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     255      this.itemDescriptionTextBox.Size = new System.Drawing.Size(588, 56);
     256      this.itemDescriptionTextBox.TabIndex = 0;
     257      this.itemDescriptionTextBox.TabStop = false;
     258      //
     259      // pluginDescriptionGroupBox
     260      //
     261      this.pluginDescriptionGroupBox.Controls.Add(this.versionTextBox);
     262      this.pluginDescriptionGroupBox.Controls.Add(this.pluginTextBox);
     263      this.pluginDescriptionGroupBox.Controls.Add(this.pluginDescriptionTextBox);
     264      this.pluginDescriptionGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     265      this.pluginDescriptionGroupBox.Location = new System.Drawing.Point(0, 0);
     266      this.pluginDescriptionGroupBox.Name = "pluginDescriptionGroupBox";
     267      this.pluginDescriptionGroupBox.Size = new System.Drawing.Size(600, 107);
     268      this.pluginDescriptionGroupBox.TabIndex = 1;
     269      this.pluginDescriptionGroupBox.TabStop = false;
     270      this.pluginDescriptionGroupBox.Text = "Plugin";
     271      //
     272      // versionTextBox
     273      //
     274      this.versionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     275      this.versionTextBox.Location = new System.Drawing.Point(444, 20);
     276      this.versionTextBox.Name = "versionTextBox";
     277      this.versionTextBox.ReadOnly = true;
     278      this.versionTextBox.Size = new System.Drawing.Size(150, 20);
     279      this.versionTextBox.TabIndex = 0;
     280      this.versionTextBox.TabStop = false;
     281      //
     282      // pluginTextBox
     283      //
     284      this.pluginTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     285            | System.Windows.Forms.AnchorStyles.Right)));
     286      this.pluginTextBox.Location = new System.Drawing.Point(6, 20);
     287      this.pluginTextBox.Name = "pluginTextBox";
     288      this.pluginTextBox.ReadOnly = true;
     289      this.pluginTextBox.Size = new System.Drawing.Size(432, 20);
     290      this.pluginTextBox.TabIndex = 0;
     291      this.pluginTextBox.TabStop = false;
     292      //
     293      // pluginDescriptionTextBox
     294      //
     295      this.pluginDescriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     296            | System.Windows.Forms.AnchorStyles.Left)
     297            | System.Windows.Forms.AnchorStyles.Right)));
     298      this.pluginDescriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     299      this.pluginDescriptionTextBox.Location = new System.Drawing.Point(6, 46);
     300      this.pluginDescriptionTextBox.Multiline = true;
     301      this.pluginDescriptionTextBox.Name = "pluginDescriptionTextBox";
     302      this.pluginDescriptionTextBox.ReadOnly = true;
     303      this.pluginDescriptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     304      this.pluginDescriptionTextBox.Size = new System.Drawing.Size(588, 55);
     305      this.pluginDescriptionTextBox.TabIndex = 0;
     306      this.pluginDescriptionTextBox.TabStop = false;
     307      //
     308      // contextMenuStrip
     309      //
     310      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     311            this.expandToolStripMenuItem,
     312            this.expandAllToolStripMenuItem,
     313            this.collapseToolStripMenuItem,
     314            this.collapseAllToolStripMenuItem});
     315      this.contextMenuStrip.Name = "contextMenuStrip";
     316      this.contextMenuStrip.Size = new System.Drawing.Size(137, 92);
     317      //
     318      // expandToolStripMenuItem
     319      //
     320      this.expandToolStripMenuItem.Name = "expandToolStripMenuItem";
     321      this.expandToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
     322      this.expandToolStripMenuItem.Text = "Expand";
     323      this.expandToolStripMenuItem.Click += new System.EventHandler(this.expandToolStripMenuItem_Click);
     324      //
     325      // expandAllToolStripMenuItem
     326      //
     327      this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem";
     328      this.expandAllToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
     329      this.expandAllToolStripMenuItem.Text = "Expand All";
     330      this.expandAllToolStripMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click);
     331      //
     332      // collapseToolStripMenuItem
     333      //
     334      this.collapseToolStripMenuItem.Name = "collapseToolStripMenuItem";
     335      this.collapseToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
     336      this.collapseToolStripMenuItem.Text = "Collapse";
     337      this.collapseToolStripMenuItem.Click += new System.EventHandler(this.collapseToolStripMenuItem_Click);
     338      //
     339      // collapseAllToolStripMenuItem
     340      //
     341      this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem";
     342      this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
     343      this.collapseAllToolStripMenuItem.Text = "Collapse All";
     344      this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click);
    118345      //
    119346      // NewItemDialog
    120347      //
    121348      this.AcceptButton = this.okButton;
    122       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    123349      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    124350      this.CancelButton = this.cancelButton;
    125       this.ClientSize = new System.Drawing.Size(624, 444);
    126       this.Controls.Add(this.itemsListView);
     351      this.ClientSize = new System.Drawing.Size(624, 622);
     352      this.Controls.Add(this.splitContainer);
    127353      this.Controls.Add(this.cancelButton);
    128354      this.Controls.Add(this.okButton);
     
    137363      this.Load += new System.EventHandler(this.NewItemDialog_Load);
    138364      this.Shown += new System.EventHandler(this.NewItemDialog_Shown);
     365      this.searchTextBox.ResumeLayout(false);
     366      this.splitContainer.Panel1.ResumeLayout(false);
     367      this.splitContainer.Panel2.ResumeLayout(false);
     368      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     369      this.splitContainer.ResumeLayout(false);
     370      this.availableItemsGroupBox.ResumeLayout(false);
     371      this.availableItemsGroupBox.PerformLayout();
     372      this.descriptionSplitContainer.Panel1.ResumeLayout(false);
     373      this.descriptionSplitContainer.Panel2.ResumeLayout(false);
     374      ((System.ComponentModel.ISupportInitialize)(this.descriptionSplitContainer)).EndInit();
     375      this.descriptionSplitContainer.ResumeLayout(false);
     376      this.itemGroupBox.ResumeLayout(false);
     377      this.itemGroupBox.PerformLayout();
     378      this.pluginDescriptionGroupBox.ResumeLayout(false);
     379      this.pluginDescriptionGroupBox.PerformLayout();
     380      this.contextMenuStrip.ResumeLayout(false);
    139381      this.ResumeLayout(false);
    140382
     
    145387    private System.Windows.Forms.Button okButton;
    146388    private System.Windows.Forms.Button cancelButton;
    147     private System.Windows.Forms.ListView itemsListView;
    148389    private System.Windows.Forms.ToolTip toolTip;
    149     private System.Windows.Forms.ColumnHeader nameColumnHeader;
    150     private System.Windows.Forms.ColumnHeader descriptioncolumnHeader;
    151     private System.Windows.Forms.ColumnHeader versionColumnHeader;
     390    private System.Windows.Forms.SplitContainer splitContainer;
     391    private System.Windows.Forms.TextBox pluginDescriptionTextBox;
     392    private System.Windows.Forms.Label searchLabel;
     393    private System.Windows.Forms.TextBox searchTextBox;
     394    private System.Windows.Forms.TreeView typesTreeView;
     395    private System.Windows.Forms.ImageList imageList;
     396    private System.Windows.Forms.GroupBox availableItemsGroupBox;
     397    private System.Windows.Forms.GroupBox pluginDescriptionGroupBox;
     398    private System.Windows.Forms.TextBox versionTextBox;
     399    private System.Windows.Forms.TextBox pluginTextBox;
     400    private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
     401    private System.Windows.Forms.ToolStripMenuItem expandToolStripMenuItem;
     402    private System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem;
     403    private System.Windows.Forms.ToolStripMenuItem collapseToolStripMenuItem;
     404    private System.Windows.Forms.ToolStripMenuItem collapseAllToolStripMenuItem;
     405    private System.Windows.Forms.Button clearSearchButton;
     406    private System.Windows.Forms.GroupBox itemGroupBox;
     407    private System.Windows.Forms.TextBox itemDescriptionTextBox;
     408    private System.Windows.Forms.SplitContainer descriptionSplitContainer;
    152409  }
    153410}
  • branches/EnumValue in CreateExperiment/HeuristicLab.Optimizer/3.3/NewItemDialog.cs

    r12012 r12466  
    2121
    2222using System;
     23using System.Collections;
     24using System.Collections.Generic;
    2325using System.Drawing;
    2426using System.Linq;
     
    2931namespace HeuristicLab.Optimizer {
    3032  internal partial class NewItemDialog : Form {
    31     private bool initialized;
     33    private bool isInitialized;
     34
     35    private readonly List<TreeNode> treeNodes;
     36    private string currentSearchString;
     37
     38    private Type selectedType;
     39    public Type SelectedType {
     40      get { return selectedType; }
     41      private set {
     42        if (value != selectedType) {
     43          selectedType = value;
     44          OnSelectedTypeChanged();
     45        }
     46      }
     47    }
    3248
    3349    private IItem item;
     
    3753
    3854    public NewItemDialog() {
    39       initialized = false;
     55      InitializeComponent();
     56      treeNodes = new List<TreeNode>();
     57      currentSearchString = string.Empty;
    4058      item = null;
    41       InitializeComponent();
     59      SelectedTypeChanged += this_SelectedTypeChanged;
    4260    }
    4361
    4462    private void NewItemDialog_Load(object sender, EventArgs e) {
    45       if (!initialized) {
    46         var categories = from t in ApplicationManager.Manager.GetTypes(typeof(IItem))
    47                          where CreatableAttribute.IsCreatable(t)
    48                          orderby CreatableAttribute.GetCategory(t), ItemAttribute.GetName(t), ItemAttribute.GetVersion(t) ascending
    49                          group t by CreatableAttribute.GetCategory(t) into c
    50                          select c;
    51 
    52         itemsListView.SmallImageList = new ImageList();
    53         itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class);  // default icon
    54         foreach (var category in categories) {
    55           ListViewGroup group = new ListViewGroup(category.Key);
    56           itemsListView.Groups.Add(group);
    57           foreach (var creatable in category) {
    58             string name = ItemAttribute.GetName(creatable);
    59             string version = ItemAttribute.GetVersion(creatable).ToString();
    60             string description = ItemAttribute.GetDescription(creatable);
    61             ListViewItem item = new ListViewItem(new string[] { name, version, description }, group);
    62             item.ImageIndex = 0;
    63             Image image = ItemAttribute.GetImage(creatable);
    64             if (image != null) {
    65               itemsListView.SmallImageList.Images.Add(image);
    66               item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
    67             }
    68             item.Tag = creatable;
    69             itemsListView.Items.Add(item);
     63      if (isInitialized) return;
     64
     65      var categories =
     66        from type in ApplicationManager.Manager.GetTypes(typeof(IItem))
     67        let category = CreatableAttribute.GetCategory(type)
     68        let name = ItemAttribute.GetName(type)
     69        let priority = CreatableAttribute.GetPriority(type)
     70        let version = ItemAttribute.GetVersion(type)
     71        where CreatableAttribute.IsCreatable(type)
     72        orderby category, priority, name, version ascending
     73        group type by category into categoryGroup
     74        select categoryGroup;
     75
     76      var rootNode = CreateCategoryTree(categories);
     77      CreateItemNodes(rootNode, categories);
     78
     79      foreach (TreeNode topNode in rootNode.Nodes)
     80        treeNodes.Add(topNode);
     81      foreach (var node in treeNodes)
     82        typesTreeView.Nodes.Add((TreeNode)node.Clone());
     83
     84      typesTreeView.TreeViewNodeSorter = new ItemTreeNodeComparer();
     85      typesTreeView.Sort();
     86
     87      isInitialized = true;
     88    }
     89
     90    private TreeNode CreateCategoryTree(IEnumerable<IGrouping<string, Type>> categories) {
     91      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class);      // default icon
     92      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Namespace);  // plugins
     93
     94      var rootNode = new TreeNode();
     95
     96      foreach (var category in categories) {
     97        var fullName = category.Key;
     98        var tokens = fullName.Split('#');
     99        var name = tokens.Last();
     100        var parents = tokens.Take(tokens.Length - 1);
     101
     102        var categoryNode = new TreeNode(name, imageIndex: 1, selectedImageIndex: 1) {
     103          Name = fullName,
     104          Tag = fullName
     105        };
     106
     107        var parentNode = FindOrCreateParentNode(rootNode, parents);
     108        if (parentNode != null)
     109          parentNode.Nodes.Add(categoryNode);
     110        else
     111          rootNode.Nodes.Add(categoryNode);
     112      }
     113
     114      return rootNode;
     115    }
     116    private TreeNode FindOrCreateParentNode(TreeNode node, IEnumerable<string> parentCategories) {
     117      TreeNode parentNode = null;
     118      string fullName = null;
     119      foreach (string parentCategory in parentCategories) {
     120        fullName = fullName == null ? parentCategory : fullName + "#" + parentCategory;
     121        parentNode = node.Nodes.Find(fullName, searchAllChildren: false).SingleOrDefault();
     122        if (parentNode == null) {
     123          parentNode = new TreeNode(parentCategory, imageIndex: 1, selectedImageIndex: 1) {
     124            Name = fullName,
     125            Tag = fullName
     126          };
     127          node.Nodes.Add(parentNode);
     128        }
     129        node = parentNode;
     130      }
     131      return parentNode;
     132    }
     133    private void CreateItemNodes(TreeNode node, IEnumerable<IGrouping<string, Type>> categories) {
     134      foreach (var category in categories) {
     135        var categoryNode = node.Nodes.Find(category.Key, searchAllChildren: true).Single();
     136        foreach (var creatable in category) {
     137          var itemNode = CreateItemNode(creatable);
     138          itemNode.Name = itemNode.Name + ":" + category.Key;
     139          categoryNode.Nodes.Add(itemNode);
     140        }
     141      }
     142    }
     143    private TreeNode CreateItemNode(Type creatable) {
     144      string name = ItemAttribute.GetName(creatable);
     145
     146      var itemNode = new TreeNode(name) {
     147        ImageIndex = 0,
     148        Tag = creatable,
     149        Name = name
     150      };
     151
     152      var image = ItemAttribute.GetImage(creatable);
     153      if (image != null) {
     154        imageList.Images.Add(image);
     155        itemNode.ImageIndex = imageList.Images.Count - 1;
     156      }
     157      itemNode.SelectedImageIndex = itemNode.ImageIndex;
     158
     159      return itemNode;
     160    }
     161
     162    private void NewItemDialog_Shown(object sender, EventArgs e) {
     163      searchTextBox.Text = string.Empty;
     164      searchTextBox.Focus();
     165      SelectedType = null;
     166      typesTreeView.SelectedNode = null;
     167      typesTreeView.CollapseAll();
     168      UpdateDescription();
     169    }
     170
     171    public virtual void Filter(string searchString) {
     172      if (InvokeRequired) {
     173        Invoke(new Action<string>(Filter), searchString);
     174      } else {
     175        searchString = searchString.ToLower();
     176        var selectedNode = typesTreeView.SelectedNode;
     177
     178        if (!searchString.Contains(currentSearchString)) {
     179          typesTreeView.BeginUpdate();
     180          // expand search -> restore all tree nodes
     181          typesTreeView.Nodes.Clear();
     182          foreach (TreeNode node in treeNodes)
     183            typesTreeView.Nodes.Add((TreeNode)node.Clone());
     184          typesTreeView.EndUpdate();
     185        }
     186
     187        // remove nodes
     188        typesTreeView.BeginUpdate();
     189        var searchTokens = searchString.Split(' ');
     190        int i = 0;
     191        while (i < typesTreeView.Nodes.Count) {
     192          var categoryNode = typesTreeView.Nodes[i];
     193          bool remove = FilterNode(categoryNode, searchTokens);
     194          if (remove)
     195            typesTreeView.Nodes.RemoveAt(i);
     196          else i++;
     197        }
     198        typesTreeView.EndUpdate();
     199        currentSearchString = searchString;
     200
     201        // select first item
     202        typesTreeView.BeginUpdate();
     203        var firstNode = FirstVisibleNode;
     204        while (firstNode != null && !(firstNode.Tag is Type))
     205          firstNode = firstNode.NextVisibleNode;
     206        if (firstNode != null)
     207          typesTreeView.SelectedNode = firstNode;
     208
     209        if (typesTreeView.Nodes.Count == 0) {
     210          SelectedType = null;
     211          typesTreeView.Enabled = false;
     212        } else {
     213          SetTreeNodeVisibility();
     214          typesTreeView.Enabled = true;
     215        }
     216        typesTreeView.EndUpdate();
     217
     218        RestoreSelectedNode(selectedNode);
     219        UpdateDescription();
     220      }
     221    }
     222
     223    private bool FilterNode(TreeNode node, string[] searchTokens) {
     224      if (node.Tag is string) { // Category node
     225        int i = 0;
     226        while (i < node.Nodes.Count) {
     227          bool remove = FilterNode(node.Nodes[i], searchTokens);
     228          if (remove)
     229            node.Nodes.RemoveAt(i);
     230          else i++;
     231        }
     232        return node.Nodes.Count == 0;
     233      } if (node.Tag is Type) { // Type node
     234        var text = node.Text;
     235        if (searchTokens.Any(searchToken => !text.ToLower().Contains(searchToken))) {
     236          var typeTag = (Type)node.Tag;
     237          if (typeTag == SelectedType) {
     238            SelectedType = null;
     239            typesTreeView.SelectedNode = null;
    70240          }
    71         }
    72         for (int i = 0; i < itemsListView.Columns.Count; i++)
    73           itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    74         initialized = true;
    75       }
    76     }
    77 
    78     private void NewItemDialog_Shown(object sender, EventArgs e) {
    79       item = null;
    80     }
    81 
    82     private void itemTypesListView_SelectedIndexChanged(object sender, EventArgs e) {
    83       okButton.Enabled = itemsListView.SelectedItems.Count == 1;
    84     }
     241          return true;
     242        }
     243        return false;
     244      }
     245      throw new InvalidOperationException("Encountered neither a category nor a creatable node during tree traversal.");
     246    }
     247
     248    protected virtual void UpdateDescription() {
     249      itemDescriptionTextBox.Text = string.Empty;
     250      pluginDescriptionTextBox.Text = string.Empty;
     251      pluginTextBox.Text = string.Empty;
     252      versionTextBox.Text = string.Empty;
     253
     254      if (typesTreeView.SelectedNode != null) {
     255        string category = typesTreeView.SelectedNode.Tag as string;
     256        if (category != null) {
     257          itemDescriptionTextBox.Text = category;
     258        }
     259        Type type = typesTreeView.SelectedNode.Tag as Type;
     260        if (type != null) {
     261          string description = ItemAttribute.GetDescription(type);
     262          var version = ItemAttribute.GetVersion(type);
     263          var plugin = ApplicationManager.Manager.GetDeclaringPlugin(type);
     264          if (description != null)
     265            itemDescriptionTextBox.Text = description;
     266          if (plugin != null) {
     267            pluginTextBox.Text = plugin.Name;
     268            pluginDescriptionTextBox.Text = plugin.Description;
     269          }
     270          if (version != null)
     271            versionTextBox.Text = version.ToString();
     272        }
     273      } else if (typesTreeView.Nodes.Count == 0) {
     274        itemDescriptionTextBox.Text = "No types found";
     275      }
     276    }
     277
     278    #region Events
     279    public event EventHandler SelectedTypeChanged;
     280    protected virtual void OnSelectedTypeChanged() {
     281      if (SelectedTypeChanged != null)
     282        SelectedTypeChanged(this, EventArgs.Empty);
     283    }
     284    #endregion
     285
     286    #region Control Events
     287    protected virtual void searchTextBox_TextChanged(object sender, EventArgs e) {
     288      Filter(searchTextBox.Text);
     289    }
     290
     291    protected virtual void itemsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
     292      if (typesTreeView.SelectedNode == null) SelectedType = null;
     293      else SelectedType = typesTreeView.SelectedNode.Tag as Type;
     294      UpdateDescription();
     295    }
     296
     297    protected virtual void itemsTreeView_VisibleChanged(object sender, EventArgs e) {
     298      if (Visible) SetTreeNodeVisibility();
     299    }
     300    #endregion
     301
     302    #region Helpers
     303    private void RestoreSelectedNode(TreeNode selectedNode) {
     304      if (selectedNode != null) {
     305        var node = typesTreeView.Nodes.Find(selectedNode.Name, searchAllChildren: true).SingleOrDefault();
     306        if (node != null)
     307          typesTreeView.SelectedNode = node;
     308        if (typesTreeView.SelectedNode == null)
     309          SelectedType = null;
     310      }
     311    }
     312    private void SetTreeNodeVisibility() {
     313      TreeNode selectedNode = typesTreeView.SelectedNode;
     314      if (string.IsNullOrEmpty(currentSearchString) && (typesTreeView.Nodes.Count > 1)) {
     315        typesTreeView.CollapseAll();
     316        if (selectedNode != null) typesTreeView.SelectedNode = selectedNode;
     317      } else {
     318        typesTreeView.ExpandAll();
     319      }
     320      if (selectedNode != null) selectedNode.EnsureVisible();
     321    }
     322    #endregion
    85323
    86324    private void okButton_Click(object sender, EventArgs e) {
    87       if (itemsListView.SelectedItems.Count == 1) {
    88         item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag);
     325      if (SelectedType != null) {
     326        item = (IItem)Activator.CreateInstance(SelectedType);
    89327        DialogResult = DialogResult.OK;
    90328        Close();
    91329      }
    92330    }
    93     private void itemTypesListView_DoubleClick(object sender, EventArgs e) {
    94       if (itemsListView.SelectedItems.Count == 1) {
    95         item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag);
     331    private void itemTreeView_DoubleClick(object sender, EventArgs e) {
     332      if (SelectedType != null) {
     333        item = (IItem)Activator.CreateInstance(SelectedType);
    96334        DialogResult = DialogResult.OK;
    97335        Close();
    98336      }
    99337    }
     338    private void this_SelectedTypeChanged(object sender, EventArgs e) {
     339      okButton.Enabled = SelectedType != null;
     340    }
     341
     342    private TreeNode toolStripMenuNode = null;
     343    private void typesTreeView_MouseDown(object sender, MouseEventArgs e) {
     344      if (e.Button == MouseButtons.Right) {
     345        Point coordinates = typesTreeView.PointToClient(Cursor.Position);
     346        toolStripMenuNode = typesTreeView.GetNodeAt(coordinates);
     347
     348        if (toolStripMenuNode != null && coordinates.X >= toolStripMenuNode.Bounds.Left &&
     349            coordinates.X <= toolStripMenuNode.Bounds.Right) {
     350          typesTreeView.SelectedNode = toolStripMenuNode;
     351
     352          expandToolStripMenuItem.Enabled =
     353            expandToolStripMenuItem.Visible = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0;
     354          collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded;
     355        } else {
     356          expandToolStripMenuItem.Enabled = expandToolStripMenuItem.Visible = false;
     357          collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = false;
     358        }
     359        expandAllToolStripMenuItem.Enabled =
     360          expandAllToolStripMenuItem.Visible =
     361            !typesTreeView.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x));
     362        collapseAllToolStripMenuItem.Enabled =
     363          collapseAllToolStripMenuItem.Visible = typesTreeView.Nodes.OfType<TreeNode>().Any(x => x.IsExpanded);
     364        if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled))
     365          contextMenuStrip.Show(Cursor.Position);
     366      }
     367    }
     368    private bool TreeNodeIsFullyExpanded(TreeNode node) {
     369      return (node.Nodes.Count == 0) || (node.IsExpanded && node.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x)));
     370    }
     371
     372    private void expandToolStripMenuItem_Click(object sender, EventArgs e) {
     373      typesTreeView.BeginUpdate();
     374      if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll();
     375      typesTreeView.EndUpdate();
     376    }
     377    private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) {
     378      typesTreeView.BeginUpdate();
     379      typesTreeView.ExpandAll();
     380      typesTreeView.EndUpdate();
     381    }
     382    private void collapseToolStripMenuItem_Click(object sender, EventArgs e) {
     383      typesTreeView.BeginUpdate();
     384      if (toolStripMenuNode != null) toolStripMenuNode.Collapse();
     385      typesTreeView.EndUpdate();
     386    }
     387    private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) {
     388      typesTreeView.BeginUpdate();
     389      typesTreeView.CollapseAll();
     390      typesTreeView.EndUpdate();
     391    }
     392
     393    private void clearSearchButton_Click(object sender, EventArgs e) {
     394      searchTextBox.Text = string.Empty;
     395      searchTextBox.Focus();
     396    }
     397
     398    private void searchTextBox_KeyDown(object sender, KeyEventArgs e) {
     399      if (typesTreeView.Nodes.Count == 0)
     400        return;
     401
     402      if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) {
     403        var selectedNode = typesTreeView.SelectedNode;
     404
     405        if (selectedNode == null) { // nothing selected => select first
     406          if (e.KeyCode == Keys.Down) typesTreeView.SelectedNode = FirstVisibleNode;
     407        } else {
     408          if (e.KeyCode == Keys.Down && selectedNode.NextVisibleNode != null)
     409            typesTreeView.SelectedNode = selectedNode.NextVisibleNode;
     410          if (e.KeyCode == Keys.Up && selectedNode.PrevVisibleNode != null)
     411            typesTreeView.SelectedNode = selectedNode.PrevVisibleNode;
     412        }
     413        e.Handled = true;
     414      }
     415    }
     416
     417    private TreeNode FirstVisibleNode {
     418      get {
     419        return typesTreeView.Nodes.Count > 0 ? typesTreeView.Nodes[0] : null;
     420      }
     421    }
     422    private TreeNode LastVisibleNode {
     423      get {
     424        var node = FirstVisibleNode;
     425        while (node != null && node.NextVisibleNode != null) node = node.NextVisibleNode;
     426        return node;
     427      }
     428    }
     429
     430    private class ItemTreeNodeComparer : IComparer {
     431      public int Compare(object x, object y) {
     432        var lhs = (TreeNode)x;
     433        var rhs = (TreeNode)y;
     434
     435        if (lhs.Tag is string && rhs.Tag is string) {
     436          return lhs.Name.CompareTo(rhs.Name);
     437        } else if (lhs.Tag is string) {
     438          return -1;
     439        } else
     440          return 1;
     441      }
     442    }
    100443  }
    101444}
Note: See TracChangeset for help on using the changeset viewer.