Changeset 12495 for branches/GBT/HeuristicLab.Core.Views/3.3
- Timestamp:
- 06/23/15 12:50:05 (9 years ago)
- Location:
- branches/GBT
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GBT
- Property svn:mergeinfo changed
/trunk/sources merged: 12392-12393,12397-12401,12422,12424,12428-12435,12442-12443,12445,12455-12458,12461,12463-12465,12470-12476,12478-12482,12485,12488,12490-12494 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
branches/GBT/HeuristicLab.Core.Views/3.3/TypeSelector.Designer.cs
r12012 r12495 42 42 this.searchLabel = new System.Windows.Forms.Label(); 43 43 this.searchTextBox = new System.Windows.Forms.TextBox(); 44 this.clearSearchButton = new System.Windows.Forms.Button(); 45 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 46 this.expandToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 47 this.expandAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 48 this.collapseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 49 this.collapseAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 44 50 this.typeParametersGroupBox = new System.Windows.Forms.GroupBox(); 45 51 this.setTypeParameterButton = new System.Windows.Forms.Button(); … … 56 62 this.typeParametersSplitContainer.SuspendLayout(); 57 63 this.typeParametersGroupBox.SuspendLayout(); 64 this.contextMenuStrip.SuspendLayout(); 58 65 this.SuspendLayout(); 59 66 // … … 75 82 this.typesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.typesTreeView_AfterSelect); 76 83 this.typesTreeView.VisibleChanged += new System.EventHandler(this.typesTreeView_VisibleChanged); 84 this.typesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.typesTreeView_MouseDown); 77 85 // 78 86 // imageList … … 146 154 this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 147 155 | System.Windows.Forms.AnchorStyles.Right))); 156 this.searchTextBox.Controls.Add(this.clearSearchButton); 148 157 this.searchTextBox.Location = new System.Drawing.Point(29, 3); 149 158 this.searchTextBox.Name = "searchTextBox"; 150 159 this.searchTextBox.Size = new System.Drawing.Size(193, 20); 151 160 this.searchTextBox.TabIndex = 1; 152 this.toolTip.SetToolTip(this.searchTextBox, "Enter string to search for types"); 161 this.toolTip.SetToolTip(this.searchTextBox, "Filters the available Types.\r\nThe search term is tokenized by space and a name ha" + 162 "s to contain all tokens to be displayed.\r\n(E.g. \"Sym Reg\" matches \"SymbolicRegr" + 163 "ession\")"); 153 164 this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged); 165 this.searchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchTextBox_KeyDown); 166 // 167 // clearSearchButton 168 // 169 this.clearSearchButton.BackColor = System.Drawing.Color.Transparent; 170 this.clearSearchButton.Cursor = System.Windows.Forms.Cursors.Default; 171 this.clearSearchButton.Dock = System.Windows.Forms.DockStyle.Right; 172 this.clearSearchButton.FlatAppearance.BorderSize = 0; 173 this.clearSearchButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 174 this.clearSearchButton.ForeColor = System.Drawing.Color.Transparent; 175 this.clearSearchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Delete; 176 this.clearSearchButton.Location = new System.Drawing.Point(543, 0); 177 this.clearSearchButton.Margin = new System.Windows.Forms.Padding(0); 178 this.clearSearchButton.Name = "clearSearchButton"; 179 this.clearSearchButton.Size = new System.Drawing.Size(15, 16); 180 this.clearSearchButton.TabIndex = 0; 181 this.clearSearchButton.TabStop = false; 182 this.clearSearchButton.UseVisualStyleBackColor = false; 183 this.clearSearchButton.Click += new System.EventHandler(this.clearSearchButton_Click); 154 184 // 155 185 // typeParametersGroupBox … … 213 243 this.descriptionTextBox.Size = new System.Drawing.Size(219, 114); 214 244 this.descriptionTextBox.TabIndex = 0; 245 // 246 // contextMenuStrip 247 // 248 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 249 this.expandToolStripMenuItem, 250 this.expandAllToolStripMenuItem, 251 this.collapseToolStripMenuItem, 252 this.collapseAllToolStripMenuItem}); 253 this.contextMenuStrip.Name = "contextMenuStrip"; 254 this.contextMenuStrip.Size = new System.Drawing.Size(137, 92); 255 // 256 // expandToolStripMenuItem 257 // 258 this.expandToolStripMenuItem.Name = "expandToolStripMenuItem"; 259 this.expandToolStripMenuItem.Size = new System.Drawing.Size(136, 22); 260 this.expandToolStripMenuItem.Text = "Expand"; 261 this.expandToolStripMenuItem.Click += new System.EventHandler(this.expandToolStripMenuItem_Click); 262 // 263 // expandAllToolStripMenuItem 264 // 265 this.expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; 266 this.expandAllToolStripMenuItem.Size = new System.Drawing.Size(136, 22); 267 this.expandAllToolStripMenuItem.Text = "Expand All"; 268 this.expandAllToolStripMenuItem.Click += new System.EventHandler(this.expandAllToolStripMenuItem_Click); 269 // 270 // collapseToolStripMenuItem 271 // 272 this.collapseToolStripMenuItem.Name = "collapseToolStripMenuItem"; 273 this.collapseToolStripMenuItem.Size = new System.Drawing.Size(136, 22); 274 this.collapseToolStripMenuItem.Text = "Collapse"; 275 this.collapseToolStripMenuItem.Click += new System.EventHandler(this.collapseToolStripMenuItem_Click); 276 // 277 // collapseAllToolStripMenuItem 278 // 279 this.collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; 280 this.collapseAllToolStripMenuItem.Size = new System.Drawing.Size(136, 22); 281 this.collapseAllToolStripMenuItem.Text = "Collapse All"; 282 this.collapseAllToolStripMenuItem.Click += new System.EventHandler(this.collapseAllToolStripMenuItem_Click); 215 283 // 216 284 // TypeSelector … … 231 299 this.typeParametersSplitContainer.ResumeLayout(false); 232 300 this.typeParametersGroupBox.ResumeLayout(false); 301 this.contextMenuStrip.ResumeLayout(false); 233 302 this.ResumeLayout(false); 234 303 … … 244 313 protected System.Windows.Forms.Label searchLabel; 245 314 protected System.Windows.Forms.TextBox searchTextBox; 315 protected System.Windows.Forms.Button clearSearchButton; 246 316 protected System.Windows.Forms.ToolTip toolTip; 317 protected System.Windows.Forms.ContextMenuStrip contextMenuStrip; 318 protected System.Windows.Forms.ToolStripMenuItem expandToolStripMenuItem; 319 protected System.Windows.Forms.ToolStripMenuItem expandAllToolStripMenuItem; 320 protected System.Windows.Forms.ToolStripMenuItem collapseToolStripMenuItem; 321 protected System.Windows.Forms.ToolStripMenuItem collapseAllToolStripMenuItem; 247 322 protected System.Windows.Forms.SplitContainer typeParametersSplitContainer; 248 323 protected System.Windows.Forms.GroupBox typeParametersGroupBox; … … 250 325 protected System.Windows.Forms.Button setTypeParameterButton; 251 326 protected System.Windows.Forms.ColumnHeader columnHeader1; 252 253 327 } 254 328 } -
branches/GBT/HeuristicLab.Core.Views/3.3/TypeSelector.cs
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs (added) merged: 12397-12398,12400
r12012 r12495 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Reflection; … … 177 178 else { 178 179 searchString = searchString.ToLower(); 180 TreeNode selectedNode = typesTreeView.SelectedNode; 179 181 180 182 if (!searchString.Contains(currentSearchString)) { 181 183 typesTreeView.BeginUpdate(); 182 184 // expand search -> restore all tree nodes 183 TreeNode selectedNode = typesTreeView.SelectedNode;184 185 typesTreeView.Nodes.Clear(); 185 186 foreach (TreeNode node in treeNodes) 186 187 typesTreeView.Nodes.Add((TreeNode)node.Clone()); 187 RestoreSelectedNode(selectedNode);188 188 typesTreeView.EndUpdate(); 189 189 } 190 191 190 192 191 // remove nodes 193 192 typesTreeView.BeginUpdate(); 193 var searchTokens = searchString.Split(' '); 194 194 int i = 0; 195 195 while (i < typesTreeView.Nodes.Count) { 196 int j = 0; 197 while (j < typesTreeView.Nodes[i].Nodes.Count) { 198 if (!typesTreeView.Nodes[i].Nodes[j].Text.ToLower().Contains(searchString)) { 199 if ((typesTreeView.Nodes[i].Nodes[j].Tag as Type).Equals(selectedType)) 200 SelectedType = null; 201 typesTreeView.Nodes[i].Nodes[j].Remove(); 202 } else 203 j++; 204 } 205 if (typesTreeView.Nodes[i].Nodes.Count == 0) 206 typesTreeView.Nodes[i].Remove(); 207 else 208 i++; 196 var node = typesTreeView.Nodes[i]; 197 bool remove = FilterNode(node, searchTokens); 198 if (remove) 199 typesTreeView.Nodes.RemoveAt(i); 200 else i++; 209 201 } 210 202 typesTreeView.EndUpdate(); 211 203 currentSearchString = searchString; 212 204 213 // if there is just one type node left, select by default 214 if (typesTreeView.Nodes.Count == 1) { 215 if (typesTreeView.Nodes[0].Nodes.Count == 1) { 216 typesTreeView.SelectedNode = typesTreeView.Nodes[0].Nodes[0]; 217 } 218 } 205 // select first item 206 typesTreeView.BeginUpdate(); 207 var firstNode = typesTreeView.Nodes.Count > 0 ? typesTreeView.Nodes[0] : null; 208 while (firstNode != null && !(firstNode.Tag is Type)) 209 firstNode = firstNode.NextVisibleNode; 210 if (firstNode != null) 211 typesTreeView.SelectedNode = firstNode; 219 212 220 213 if (typesTreeView.Nodes.Count == 0) { … … 225 218 typesTreeView.Enabled = true; 226 219 } 220 typesTreeView.EndUpdate(); 221 222 RestoreSelectedNode(selectedNode); 227 223 UpdateDescription(); 228 224 } 225 } 226 227 private bool FilterNode(TreeNode node, string[] searchTokens) { 228 if (node.Tag is IPluginDescription) { // Plugin node 229 int i = 0; 230 while (i < node.Nodes.Count) { 231 bool remove = FilterNode(node.Nodes[i], searchTokens); 232 if (remove) 233 node.Nodes.RemoveAt(i); 234 else i++; 235 } 236 return node.Nodes.Count == 0; 237 } if (node.Tag is Type) { // Type node 238 var text = node.Text; 239 if (searchTokens.Any(searchToken => !text.ToLower().Contains(searchToken))) { 240 var typeTag = (Type)node.Tag; 241 if (typeTag == SelectedType) { 242 SelectedType = null; 243 typesTreeView.SelectedNode = null; 244 } 245 return true; 246 } 247 return false; 248 } 249 throw new InvalidOperationException("Encountered neither a plugin nor a type node during tree traversal."); 229 250 } 230 251 … … 355 376 SetTypeParameter(); 356 377 } 378 private void searchTextBox_KeyDown(object sender, KeyEventArgs e) { 379 if (typesTreeView.Nodes.Count == 0) 380 return; 381 382 if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) { 383 var selectedNode = typesTreeView.SelectedNode; 384 385 if (selectedNode == null) { // nothing selected => select first 386 if (e.KeyCode == Keys.Down) typesTreeView.SelectedNode = typesTreeView.Nodes.Count > 0 ? typesTreeView.Nodes[0] : null; 387 } else { 388 if (e.KeyCode == Keys.Down && selectedNode.NextVisibleNode != null) 389 typesTreeView.SelectedNode = selectedNode.NextVisibleNode; 390 if (e.KeyCode == Keys.Up && selectedNode.PrevVisibleNode != null) 391 typesTreeView.SelectedNode = selectedNode.PrevVisibleNode; 392 } 393 e.Handled = true; 394 } 395 } 396 private void clearSearchButton_Click(object sender, EventArgs e) { 397 searchTextBox.Text = string.Empty; 398 searchTextBox.Focus(); 399 } 400 401 private TreeNode toolStripMenuNode = null; 402 private void typesTreeView_MouseDown(object sender, MouseEventArgs e) { 403 if (e.Button == MouseButtons.Right) { 404 Point coordinates = typesTreeView.PointToClient(Cursor.Position); 405 toolStripMenuNode = typesTreeView.GetNodeAt(coordinates); 406 407 if (toolStripMenuNode != null && coordinates.X >= toolStripMenuNode.Bounds.Left && 408 coordinates.X <= toolStripMenuNode.Bounds.Right) { 409 typesTreeView.SelectedNode = toolStripMenuNode; 410 411 expandToolStripMenuItem.Enabled = 412 expandToolStripMenuItem.Visible = !toolStripMenuNode.IsExpanded && toolStripMenuNode.Nodes.Count > 0; 413 collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = toolStripMenuNode.IsExpanded; 414 } else { 415 expandToolStripMenuItem.Enabled = expandToolStripMenuItem.Visible = false; 416 collapseToolStripMenuItem.Enabled = collapseToolStripMenuItem.Visible = false; 417 } 418 expandAllToolStripMenuItem.Enabled = 419 expandAllToolStripMenuItem.Visible = 420 !typesTreeView.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x)); 421 collapseAllToolStripMenuItem.Enabled = 422 collapseAllToolStripMenuItem.Visible = typesTreeView.Nodes.OfType<TreeNode>().Any(x => x.IsExpanded); 423 if (contextMenuStrip.Items.Cast<ToolStripMenuItem>().Any(item => item.Enabled)) 424 contextMenuStrip.Show(Cursor.Position); 425 } 426 } 427 private bool TreeNodeIsFullyExpanded(TreeNode node) { 428 return (node.Nodes.Count == 0) || (node.IsExpanded && node.Nodes.OfType<TreeNode>().All(x => TreeNodeIsFullyExpanded(x))); 429 } 430 private void expandToolStripMenuItem_Click(object sender, EventArgs e) { 431 typesTreeView.BeginUpdate(); 432 if (toolStripMenuNode != null) toolStripMenuNode.ExpandAll(); 433 typesTreeView.EndUpdate(); 434 } 435 private void expandAllToolStripMenuItem_Click(object sender, EventArgs e) { 436 typesTreeView.BeginUpdate(); 437 typesTreeView.ExpandAll(); 438 typesTreeView.EndUpdate(); 439 } 440 private void collapseToolStripMenuItem_Click(object sender, EventArgs e) { 441 typesTreeView.BeginUpdate(); 442 if (toolStripMenuNode != null) toolStripMenuNode.Collapse(); 443 typesTreeView.EndUpdate(); 444 } 445 private void collapseAllToolStripMenuItem_Click(object sender, EventArgs e) { 446 typesTreeView.BeginUpdate(); 447 typesTreeView.CollapseAll(); 448 typesTreeView.EndUpdate(); 449 } 357 450 #endregion 358 451 - Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.