void ReleaseDesignerOutlets() { if (AddRecipeButton != null) { AddRecipeButton.Dispose(); AddRecipeButton = null; } if (RecipeTableView != null) { RecipeTableView.Dispose(); RecipeTableView = null; } }
private void RecipeFilterTextBox_KeyDown(object sender, KeyEventArgs e) { if (RecipeListView.Items.Count == 0) { return; } int currentSelection; if (RecipeListView.SelectedIndices.Count == 0) { currentSelection = -1; } else { currentSelection = RecipeListView.SelectedIndices[0]; } if (e.KeyCode == Keys.Down) { int newSelection = currentSelection + 1; if (newSelection >= RecipeListView.Items.Count) { newSelection = RecipeListView.Items.Count - 1; } if (newSelection <= 0) { newSelection = 0; } RecipeListView.SelectedIndices.Clear(); RecipeListView.SelectedIndices.Add(newSelection); e.Handled = true; } else if (e.KeyCode == Keys.Up) { int newSelection = currentSelection - 1; if (newSelection == -1) { newSelection = 0; } RecipeListView.SelectedIndices.Clear(); RecipeListView.SelectedIndices.Add(newSelection); e.Handled = true; } else if (e.KeyCode == Keys.Enter) { AddRecipeButton.PerformClick(); } }
private void RecipeFilterTextBox_KeyDown(object sender, KeyEventArgs e) { if (RecipeListView.Items.Count == 0) { return; } if (e.Key == Key.Down) { RecipeListView.SelectedIndex = Math.Min( RecipeListView.SelectedIndex + 1, RecipeListView.Items.Count); e.Handled = true; } else if (e.Key == Key.Up) { RecipeListView.SelectedIndex = Math.Max( RecipeListView.SelectedIndex - 1, 0); e.Handled = true; } else if (e.Key == Key.Enter) { AddRecipeButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, this)); } }