Changeset 12234 for branches/NewItemDialog
- Timestamp:
- 03/23/15 10:01:26 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/NewItemDialog/HeuristicLab.Optimizer/3.3/NewItemDialog.cs
r12217 r12234 130 130 return parentNode; 131 131 } 132 133 132 private void CreateItemNodes(TreeNode node, IEnumerable<IGrouping<string, Type>> categories) { 134 133 foreach (var category in categories) { … … 141 140 } 142 141 } 143 144 142 private TreeNode CreateItemNode(Type creatable) { 145 143 string name = ItemAttribute.GetName(creatable); … … 387 385 388 386 private void searchTextBox_KeyDown(object sender, KeyEventArgs e) { 387 if (typesTreeView.Nodes.Count == 0) 388 return; 389 389 390 if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) { 390 391 int? idx = typesTreeView.SelectedNode != null 392 ? (int?)typesTreeView.SelectedNode.Index 393 : null; 394 395 TreeNode newNode = null; 396 if (e.KeyCode == Keys.Down) { 397 if (idx.HasValue && idx < typesTreeView.Nodes.Count - 1) { 398 newNode = typesTreeView.Nodes[idx.Value + 1]; 399 } else if (typesTreeView.Nodes.Count > 0) { 400 newNode = typesTreeView.Nodes[0]; 401 } 402 } else if (e.KeyCode == Keys.Up && idx.HasValue && idx > 0) { 403 newNode = typesTreeView.Nodes[idx.Value - 1]; 404 } 405 406 if (newNode != null) 407 typesTreeView.SelectedNode = newNode; 391 var selectedNode = typesTreeView.SelectedNode; 392 393 if (selectedNode == null) { // nothing selected => select first or last 394 if (e.KeyCode == Keys.Down) typesTreeView.SelectedNode = FirstVisibleNode; 395 if (e.KeyCode == Keys.Up) typesTreeView.SelectedNode = LastVisibleNode; 396 } else { 397 if (e.KeyCode == Keys.Down) 398 typesTreeView.SelectedNode = selectedNode.NextVisibleNode ?? FirstVisibleNode; // select next or cycle to first 399 if (e.KeyCode == Keys.Up) 400 typesTreeView.SelectedNode = selectedNode.PrevVisibleNode ?? LastVisibleNode; // select prev or cycle to last 401 } 408 402 e.Handled = true; 403 } 404 } 405 406 private TreeNode FirstVisibleNode { 407 get { 408 return typesTreeView.Nodes[0]; 409 } 410 } 411 private TreeNode LastVisibleNode { 412 get { 413 var node = FirstVisibleNode; 414 while (node.NextVisibleNode != null) node = node.NextVisibleNode; 415 return node; 409 416 } 410 417 }
Note: See TracChangeset
for help on using the changeset viewer.