Changeset 12397
- Timestamp:
- 05/26/15 12:09:33 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.Designer.cs
r12012 r12397 152 152 this.toolTip.SetToolTip(this.searchTextBox, "Enter string to search for types"); 153 153 this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged); 154 this.searchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchTextBox_KeyDown); 154 155 // 155 156 // typeParametersGroupBox -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs
r12012 r12397 192 192 // remove nodes 193 193 typesTreeView.BeginUpdate(); 194 var searchTokens = searchString.Split(' '); 195 194 196 int i = 0; 195 197 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++; 198 var node = typesTreeView.Nodes[i]; 199 bool remove = FilterNode(node, searchTokens); 200 if (remove) 201 typesTreeView.Nodes.RemoveAt(i); 202 else i++; 209 203 } 210 204 typesTreeView.EndUpdate(); 211 205 currentSearchString = searchString; 212 206 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 } 207 // select first item 208 typesTreeView.BeginUpdate(); 209 var firstNode = typesTreeView.Nodes.Count > 0 ? typesTreeView.Nodes[0] : null; 210 while (firstNode != null && !(firstNode.Tag is Type)) 211 firstNode = firstNode.NextVisibleNode; 212 if (firstNode != null) 213 typesTreeView.SelectedNode = firstNode; 219 214 220 215 if (typesTreeView.Nodes.Count == 0) { … … 225 220 typesTreeView.Enabled = true; 226 221 } 222 typesTreeView.EndUpdate(); 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 } 357 396 #endregion 358 397 -
trunk/sources/HeuristicLab.Optimizer/3.3/NewItemDialog.cs
r12393 r12397 202 202 203 203 // select first item 204 typesTreeView.BeginUpdate(); 204 205 var firstNode = FirstVisibleNode; 205 206 while (firstNode != null && !(firstNode.Tag is Type)) … … 215 216 typesTreeView.Enabled = true; 216 217 } 218 typesTreeView.EndUpdate(); 217 219 UpdateDescription(); 218 220 }
Note: See TracChangeset
for help on using the changeset viewer.