void process_Click(object sender, RoutedEventArgs e) { ProgramControl curProcess = sender as ProgramControl; if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { if (SelectedPrograms.Contains(curProcess)) { curProcess.SetFocus(false); SelectedPrograms.Remove(curProcess); } else { curProcess.SetFocus(true); SelectedPrograms.Add(curProcess); } } else { foreach (ProgramControl curProg in SelectedPrograms) { curProg.SetFocus(false); } SelectedPrograms.Clear(); SelectedPrograms.Add(curProcess); curProcess.SetFocus(true); } SelectionChanged?.Invoke(this, new EventArgs()); }
void process_KeyEventHandler(object sender, KeyEventArgs e) { if ((e.Key == Key.Up || e.Key == Key.Down) /*&& !((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)*/) { ProgramControl curProcess = null; if (SelectedPrograms.Count > 0) { foreach (ProgramControl curProg in SelectedPrograms) { curProg.SetFocus(false); } curProcess = SelectedPrograms[SelectedPrograms.Count - 1]; SelectedPrograms.Clear(); } e.Handled = true; int curRow = Grid.GetRow(curProcess); if (e.Key == Key.Up) { while (curRow > 0) { curRow--; ProgramControl curProg = this.processGrid.Children.Cast <ProgramControl>().First((c) => Grid.GetRow(c) == curRow); if (curProg.Visibility == Visibility.Visible) { curProcess = curProg; this.processScroll.ScrollToVerticalOffset(this.processScroll.VerticalOffset - (curProcess.ActualHeight + 2)); break; } } } else if (e.Key == Key.Down) { while (curRow < this.processGrid.Children.Count - 1) { curRow++; ProgramControl curProg = this.processGrid.Children.Cast <ProgramControl>().First((c) => Grid.GetRow(c) == curRow); if (curProg.Visibility == Visibility.Visible) { curProcess = curProg; this.processScroll.ScrollToVerticalOffset(this.processScroll.VerticalOffset + (curProcess.ActualHeight + 2)); break; } } } if (curProcess == null) { return; } curProcess.SetFocus(true); SelectedPrograms.Add(curProcess); SelectionChanged?.Invoke(this, new EventArgs()); } }