void TrayWindow_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { this.Close(); } }
private void OnKeyDownHandler(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { Label_results.Content = solve.Results(TextBox_input.Text); } }
private void Login_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Button_Click(sender, null); } }
private void TimeLimit_KeyUp(object sender, KeyEventArgs e) { if(e.Key == Key.Enter) { TimeLimit_LostFocus(null, null); } }
private async void PasswordTxb_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { await LoadContacts(); } }
/// <summary> /// Provides class handling for the KeyDown event that occurs when a /// key is pressed while the control has focus. /// </summary> /// <param name="e">The event data.</param> protected override void OnPreviewKeyDown(KeyEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } base.OnPreviewKeyDown(e); if (e.Handled || !IsEnabled) { return; } // TODO: CONSIDER: What about the Adapter interface: should it // offer the ability to always handle events from the text box // key down? if (IsDropDownOpen) { OnDropDownKeyDown(e); } else { OnTextBoxKeyDown(e); } }
/// <summary> /// Occurs when the KeyDown event fires and the drop down is not open. /// </summary> /// <param name="e">The key event data.</param> protected void OnTextBoxKeyDown(KeyEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } else if (e.Handled) { return; } switch (e.Key) { case Key.Down: if (!IsDropDownOpen) { ToggleDropDown(this, e); e.Handled = true; } break; case Key.F4: ToggleDropDown(this, e); e.Handled = true; break; case Key.Enter: OnAdapterSelectionComplete(this, new RoutedEventArgs()); e.Handled = true; break; default: break; } }
protected override void OnKeyDown(KeyEventArgs e) { switch (e.Key) { case Key.Enter: //if (Application.Current.IsRunningOutOfBrowser == false) break; // Enterキー フォーカス移動 if (Keyboard.Modifiers == ModifierKeys.Shift) { OnBeforeControl(); } else { OnNextControl(); } break; case Key.Tab: //if (Application.Current.IsRunningOutOfBrowser == false) break; if (IsTabDefualMove == true) break; if (Keyboard.Modifiers == ModifierKeys.Shift) { OnBeforeControl(); } else { OnNextControl(); } e.Handled = true; return; default: break; } base.OnKeyDown(e); }
private void CommonTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { base.Focus(); } }
/// <summary> /// When added to the PreviewKeyUp event of any control, it checks whether the key pressed was Tab. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="KeyEventArgs" /> instance containing the event data. /// </param> public static void Any_PreviewKeyUp_CheckTab(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { _isTabPressed = false; } }
private void textBoxMessage_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { ButtonSend_Click(sender, e); } }
private void textBoxAcc_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { } }
private void itemList_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && itemList.SelectedItems.Count == 1) { editButton_Click(sender, null); } }
public static void Alphanumeric(KeyEventArgs e, TextBox tb) { if ((e.Key < Key.D0 || e.Key > Key.D9) && ((e.Key < Key.NumPad0) || (e.Key > Key.NumPad9)) && ((e.Key < Key.A) || (e.Key > Key.Z)) && (e.Key != Key.OemMinus)) { e.Handled = true; } }
public void TextBox1_KeyDown(object sender, KeyEventArgs e) { e.Handled = false; System.Windows.Controls.TextBox textBox = TextBox1; if (e.Key == Key.Enter) { if (!Keyboard.IsKeyDown(Key.LeftShift)) textBox.MoveFocus(traversalRequest); else { int i = textBox.CaretIndex; textBox.Text = textBox.Text.Substring(0, i) + "\n" + textBox.Text.Substring(i, textBox.Text.Length - i); textBox.CaretIndex = i + 1; } } else if (e.Key == Key.Subtract) { System.Windows.Controls.TextBox box = (System.Windows.Controls.TextBox)sender; int caret = box.CaretIndex; box.Text = box.Text.Insert(box.CaretIndex, "-"); box.CaretIndex = caret + 1; e.Handled = true; } textBox.AppendText(String.Empty); }
public static void OnlyNumbers(KeyEventArgs e, TextBox textBox) { if ((e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9)) { e.Handled = true; } }
public static void OnlyNumbersAndCommas(KeyEventArgs e, TextBox tb) { if (e.Key != Key.Decimal && e.Key != Key.OemComma && (e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9)) { e.Handled = true; } }
private void SearchBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { SearchStart_Click(sender, e); } }
//Interaction clavier utilisateur private void HandleKeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Left: if (Timer.IsEnabled) monPlateau.PieceMovLeft(); break; case Key.Right: if (Timer.IsEnabled) monPlateau.PieceMovRight(); break; case Key.Down: if (Timer.IsEnabled) monPlateau.PieceMovDown(); break; case Key.Up: if (Timer.IsEnabled) monPlateau.PieceRotation(); break; case Key.F2: GameStart(); break; case Key.F3: GamePause(); break; case Key.Escape: Application Tetris = Application.Current; Tetris.Shutdown(); break; default: break; } }
private void TaskEditorView_OnPreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && DataContext is TaskEditorViewModel && (DataContext as TaskEditorViewModel).AddTaskCommand.CanExecute("")) { (DataContext as TaskEditorViewModel).AddTaskCommand.Execute(""); } }
private void LanguageNameTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { OK_Click(sender, e); } }
void panel_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Insert) { AddNewWatch(); e.Handled = true; } }
private void method_3(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { this.method_1(); } }
// When the user presses a key, determine whether to add a new student to a class, remove a student from a class, or modify the details of a student private void studentsList_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { // If the user pressed Enter, edit the details for the currently selected student case Key.Enter: Student student = this.studentsList.SelectedItem as Student; // Use the StudentsForm to display and edit the details of the student StudentForm sf = new StudentForm(); // Set the title of the form and populate the fields on the form with the details of the student sf.Title = "Edit Student Details"; sf.firstName.Text = student.FirstName; sf.lastName.Text = student.LastName; sf.dateOfBirth.Text = student.DateOfBirth.ToString("d"); // Format the date to omit the time element // Display the form if (sf.ShowDialog().Value) { // When the user closes the form, copy the details back to the student student.FirstName = sf.firstName.Text; student.LastName = sf.lastName.Text; student.DateOfBirth = DateTime.Parse(sf.dateOfBirth.Text); // Enable saving (changes are not made permanent until they are written back to the database) saveChanges.IsEnabled = true; } break; // If the user pressed Insert, add a new student case Key.Insert: // Use the StudentsForm to get the details of the student from the user sf = new StudentForm(); // Set the title of the form to indicate which class the student will be added to (the class for the currently selected teacher) sf.Title = "New Student for Class " + teacher.Class; // Display the form and get the details of the new student if (sf.ShowDialog().Value) { // When the user closes the form, retrieve the details of the student from the form // and use them to create a new Student object Student newStudent = new Student(); newStudent.FirstName = sf.firstName.Text; newStudent.LastName = sf.lastName.Text; newStudent.DateOfBirth = DateTime.Parse(sf.dateOfBirth.Text); // Assign the new student to the current teacher this.teacher.Students.Add(newStudent); // Add the student to the list displayed on the form this.studentsInfo.Add(newStudent); // Enable saving (changes are not made permanent until they are written back to the database) saveChanges.IsEnabled = true; } break; } }
public void KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.K: foreach (var label in Dane.tablica) { label.BorderThickness = (label.BorderThickness == new Thickness(1)) ? label.BorderThickness = new Thickness(0) : label.BorderThickness = new Thickness(1); } break; case Key.Left: if (Wunsz.kierunek != Kierunek.right) Wunsz.kierunek = Kierunek.left; break; case Key.Up: if (Wunsz.kierunek != Kierunek.down) Wunsz.kierunek = Kierunek.up; break; case Key.Right: if (Wunsz.kierunek != Kierunek.left) Wunsz.kierunek = Kierunek.right; break; case Key.Down: if (Wunsz.kierunek != Kierunek.up) Wunsz.kierunek = Kierunek.down; break; } }
private void SearchTermTextBox_KeyDown(object sender, KeyEventArgs e) { if(e.Key == Key.Enter && EnterCommand!=null) { EnterCommand(this, e); } }
/// <summary> /// Close the window when the Esc key is pressed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DoKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { Hide(); } }
private void FindSearchText_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Return) { this.FindNextButton.Command.Execute(null); } }
private void DecimalIpAddressTextBox_KeyUp(object sender, KeyEventArgs e) { string RawInput; RawInput = DecimalIpAddressTextBox.Text.Trim(); // CIDR regex string pattern = @"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"; Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase); if (rgx.IsMatch(RawInput) == true) { try { IpAddress Address = new IpAddress(RawInput); BinaryIpAddressTextBox.Text = Address.ToBinaryString(); } catch (Exception) { BinaryIpAddressTextBox.Text = "Invalid Address"; } } else { BinaryIpAddressTextBox.Text = ""; } }
void watchList_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this }; cmd.Run(); } }
private void PUPasswordBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { //禁止任何与Control键有关的事(除了全选) if (Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.A)) { e.Handled = true; return; } var currentCursor = SelectionStart; switch (e.Key) { case Key.Back: if (Text.Length > 0 && currentCursor > 0 && SelectionLength == 0) { Text = Text.Remove(currentCursor - 1, 1); Password = Password.Remove(currentCursor - 1, 1); if (currentCursor > 0) { Select(currentCursor - 1, 0); } } else if (SelectionLength > 0) { var length = SelectionLength; Text = Text.Remove(currentCursor, length); Password = Password.Remove(currentCursor, length); if (currentCursor - length > 0) { Select(currentCursor - length + 1, 0); } } //批量选择情况下 break; case Key.Delete: if (currentCursor < Text.Length) { Text = Text.Remove(currentCursor, 1); Password = Password.Remove(currentCursor, 1); Select(currentCursor, 0); } break; case Key.Space: if (SelectionLength != 0) { Text = Text.Remove(currentCursor, SelectionLength); Password = Password.Remove(currentCursor, SelectionLength); } Text = Text.Insert(currentCursor, PasswordChar.ToString()); Password = Password.Insert(currentCursor, " "); Select(currentCursor + 1, 0); break; default: return; } e.Handled = true; }
private void OnThisKeyDown(object sender, KeyEventArgs e) { checkFlowDocumentCommands(sender, e, InputBindings); checkSpaceKeyButtonActivation(sender, e, InputBindings); checkEnterKeyButtonActivation(sender, e, InputBindings); }
private void TextBoxDBFilter_PreviewKeyDown(object sender, KeyEventArgs e) { var index = ListViewDB.SelectedIndex; Card card = null; switch (e.Key) { case Key.Enter: if (ListViewDB.SelectedItem != null) { card = (Card)ListViewDB.SelectedItem; } else if (ListViewDB.Items.Count > 0) { card = (Card)ListViewDB.Items[0]; } break; case Key.D1: if (ListViewDB.Items.Count > 0) { card = (Card)ListViewDB.Items[0]; } break; case Key.D2: if (ListViewDB.Items.Count > 1) { card = (Card)ListViewDB.Items[1]; } break; case Key.D3: if (ListViewDB.Items.Count > 2) { card = (Card)ListViewDB.Items[2]; } break; case Key.D4: if (ListViewDB.Items.Count > 3) { card = (Card)ListViewDB.Items[3]; } break; case Key.D5: if (ListViewDB.Items.Count > 4) { card = (Card)ListViewDB.Items[4]; } break; case Key.Down: if (index < ListViewDB.Items.Count - 1) { ListViewDB.SelectedIndex += 1; } break; case Key.Up: if (index > 0) { ListViewDB.SelectedIndex -= 1; } break; } if (card != null) { AddCardToDeck((Card)card.Clone()); e.Handled = true; } }
// zoom in 3d display public void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs args) { m_transformMatrix.OnKeyDown(args); TransformChart(); }
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { Console.WriteLine(e.Key); //Lorsque l'on appuie sur = pour afficher le résultat if (e.Key == Key.Enter) { //calcul de _vm.SumCalcul et _vm.Resultat //Affichage du resultat dans _vm.Resultat _vm.SumCalcul += _vm.Resultat; List <string> liste = new List <string>(); liste = Decoupage((_vm.SumCalcul).ToString()); _vm.Resultat = (Calcul(liste)).ToString(); } //Chiffres if (e.Key == Key.NumPad0) { _vm.Resultat += "0"; } if (e.Key == Key.NumPad1) { _vm.Resultat += "1"; } if (e.Key == Key.NumPad2) { _vm.Resultat += "2"; } if (e.Key == Key.NumPad3) { _vm.Resultat += "3"; } if (e.Key == Key.NumPad4) { _vm.Resultat += "4"; } if (e.Key == Key.NumPad5) { _vm.Resultat += "5"; } if (e.Key == Key.NumPad6) { _vm.Resultat += "6"; } if (e.Key == Key.NumPad7) { _vm.Resultat += "7"; } if (e.Key == Key.NumPad8) { _vm.Resultat += "8"; } if (e.Key == Key.NumPad9) { _vm.Resultat += "9"; } //Opérations basiques if (e.Key == Key.Add) { _vm.Resultat += "+"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; } if (e.Key == Key.Subtract) { _vm.Resultat += "-"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; } if (e.Key == Key.Multiply) { _vm.Resultat += "*"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; } if (e.Key == Key.Divide) { _vm.Resultat += "/"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; } if (e.Key == Key.OemComma) { _vm.Resultat += ","; } if (e.Key == Key.D6) { _vm.Resultat += "-"; } //Opérations complexes if (e.Key == Key.Oem3) { _vm.Resultat += "%"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.D) { _vm.Resultat += "÷"; _vm.SumCalcul += _vm.Resultat; _vm.Resultat = ""; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.E) { _vm.Resultat += "^"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.V) { _vm.Resultat += "√"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.L) { _vm.Resultat += "㏒"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.T) { _vm.Resultat += "tan"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.C) { _vm.Resultat += "cos"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } if (e.Key == Key.S) { _vm.Resultat += "sin"; System.Windows.MessageBox.Show("Ce calcul n'est pas implementée encore."); _vm.Resultat = ""; _vm.SumCalcul = ""; } }
// Обработка комбобоксов вводом текста private void ComboBox_TextChanged(object sender, System.Windows.Input.KeyEventArgs e) { ComboBox_TextChanged(sender); }
private void keyUpEvent(object sender, System.Windows.Input.KeyEventArgs e) { Console.WriteLine("KeyUp: {0}", e.Key); KeyboardCommandHandler.keyUp(e.Key); }
private void MainWindow_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { sCAD.OnKeyUp2(e); }
public static void checkFlowDocumentCommands(object sender, KeyEventArgs e, InputBindingCollection InputBindings) { if ( !( Keyboard.Modifiers == ModifierKeys.Control && (e.Key == Key.P || e.Key == Key.A || e.Key == Key.C || e.Key == Key.X || e.Key == Key.V) || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down //|| e.Key == Key.Space ) ) { return; } if ( !( e.OriginalSource is FlowDocumentScrollViewer && ((UIElement)e.OriginalSource).IsFocused ) ) { return; } e.Handled = true; var commandsToExecute = new List <ICommand>(1); foreach (var inputBinding in InputBindings) { if (!(inputBinding is KeyBinding)) { continue; } if (!(((KeyBinding)inputBinding).Gesture is KeyGesture)) { continue; } if (((KeyGesture)((KeyBinding)inputBinding).Gesture).Key != e.Key) { continue; } var modifiers = ((KeyGesture)((KeyBinding)inputBinding).Gesture).Modifiers; if (!modifiersMatch(modifiers)) { continue; } if (((KeyBinding)inputBinding).Command != null && ((KeyBinding)inputBinding).Command.CanExecute(null)) { commandsToExecute.Add(((KeyBinding)inputBinding).Command); } } foreach (var command in commandsToExecute) { command.Execute(null); } }
//侦听键盘 private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { SoundPlayer sound = new SoundPlayer("Audio/1.wav"); sound.Play(); if (CheckFalse()) { MessageBox.Show("您已经走投无路!"); return; } ImageButton[,] bbegin = new ImageButton[4, 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { bbegin[i, j] = new ImageButton(); bbegin[i, j].Text = board[i, j].Text; } } int indexone, indextwo; for (int i = 0; i < 4; i++) { if (e.Key.ToString() == "Up") { indexone = 0; indextwo = 1; while (indextwo < 4) { Excute(board[indexone, i], board[indextwo, i], ref indexone, ref indextwo, true); } } else if (e.Key.ToString() == "Down") { indexone = 3; indextwo = 2; while (indextwo >= 0) { Excute(board[indexone, i], board[indextwo, i], ref indexone, ref indextwo, false); } } else if (e.Key.ToString() == "Left") { indexone = 0; indextwo = 1; while (indextwo < 4) { Excute(board[i, indexone], board[i, indextwo], ref indexone, ref indextwo, true); } } else if (e.Key.ToString() == "Right") { indexone = 3; indextwo = 2; while (indextwo >= 0) { Excute(board[i, indexone], board[i, indextwo], ref indexone, ref indextwo, false); } } } ImageButton[,] eend = new ImageButton[4, 4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { eend[i, j] = new ImageButton(); eend[i, j].Text = board[i, j].Text; } } bool judge = false; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (bbegin[i, j].Text != eend[i, j].Text) { judge = true; break; } } } if (judge) //只有当数据有改动时才产生新的数据 { CreateNew(); } }
private void txtRGlobalVariables_KeyUp(object sender, KeyEventArgs e) { main.property.RulePrpt.txtRVariables_KeyUp(sender, e); }
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { // Ignore all of this please if (e.Key == Key.Enter) { AddBarcode(); return; } if (CurrentBarcode is null) { if (HistoryStackpanel.Children.Count > 0) { CurrentBarcode = (BarcodeHistoryUserControl)HistoryStackpanel.Children[0]; ScrollToTarget(CurrentBarcode); return; } else { return; } } int currentIndex = HistoryStackpanel.Children.IndexOf(CurrentBarcode); if (currentIndex == -1) { return; } BarcodeHistoryUserControl temp; switch (e.Key) { case Key.Up: if (currentIndex < 1) { return; } temp = (BarcodeHistoryUserControl)HistoryStackpanel.Children[currentIndex - 1]; ScrollToTarget(temp); break; case Key.Down: if (currentIndex >= HistoryStackpanel.Children.Count - 1) { return; } temp = (BarcodeHistoryUserControl)HistoryStackpanel.Children[currentIndex + 1]; ScrollToTarget(temp); break; case Key.Delete: if (currentIndex == -1) { return; } DeleteHistory((BarcodeHistoryUserControl)HistoryStackpanel.Children[currentIndex]); CurrentBarcode = null; ScanTextBox.Text = ""; BarcodeTypeComboBox.SelectedItem = BarcodeFormat.CODE_128; break; } }
private void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { //Defining the Color of a button: Brush keyDownFG = new SolidColorBrush(Color.FromRgb(44, 47, 51)); //Pressed Foreground Brush keyDownBG = new SolidColorBrush(Color.FromRgb(114, 137, 218)); //Pressed Background Brush keyUpFG = new SolidColorBrush(Color.FromRgb(114, 137, 218)); //Released Foreground Brush keyUpBG = new SolidColorBrush(Color.FromRgb(35, 39, 42)); //Released Background switch (e.Key) { //Number Row case Key.OemTilde: { if (Keyboard.IsKeyDown(Key.OemTilde)) { Tilde_Button.Foreground = keyDownFG; Tilde_Button.Background = keyDownBG; } else { Tilde_Button.Foreground = keyUpFG; Tilde_Button.Background = keyUpBG; } break; } case Key.D1: { if (Keyboard.IsKeyDown(Key.D1)) { D1_Button.Foreground = keyDownFG; D1_Button.Background = keyDownBG; } else { D1_Button.Foreground = keyUpFG; D1_Button.Background = keyUpBG; } break; } case Key.D2: { if (Keyboard.IsKeyDown(Key.D2)) { D2_Button.Foreground = keyDownFG; D2_Button.Background = keyDownBG; } else { D2_Button.Foreground = keyUpFG; D2_Button.Background = keyUpBG; } break; } case Key.D3: { if (Keyboard.IsKeyDown(Key.D3)) { D3_Button.Foreground = keyDownFG; D3_Button.Background = keyDownBG; } else { D3_Button.Foreground = keyUpFG; D3_Button.Background = keyUpBG; } break; } case Key.D4: { if (Keyboard.IsKeyDown(Key.D4)) { D4_Button.Foreground = keyDownFG; D4_Button.Background = keyDownBG; } else { D4_Button.Foreground = keyUpFG; D4_Button.Background = keyUpBG; } break; } case Key.D5: { if (Keyboard.IsKeyDown(Key.D5)) { D5_Button.Foreground = keyDownFG; D5_Button.Background = keyDownBG; } else { D5_Button.Foreground = keyUpFG; D5_Button.Background = keyUpBG; } break; } case Key.D6: { if (Keyboard.IsKeyDown(Key.D6)) { D6_Button.Foreground = keyDownFG; D6_Button.Background = keyDownBG; } else { D6_Button.Foreground = keyUpFG; D6_Button.Background = keyUpBG; } break; } case Key.D7: { if (Keyboard.IsKeyDown(Key.D7)) { D7_Button.Foreground = keyDownFG; D7_Button.Background = keyDownBG; } else { D7_Button.Foreground = keyUpFG; D7_Button.Background = keyUpBG; } break; } case Key.D8: { if (Keyboard.IsKeyDown(Key.D8)) { D8_Button.Foreground = keyDownFG; D8_Button.Background = keyDownBG; } else { D8_Button.Foreground = keyUpFG; D8_Button.Background = keyUpBG; } break; } case Key.D9: { if (Keyboard.IsKeyDown(Key.D9)) { D9_Button.Foreground = keyDownFG; D9_Button.Background = keyDownBG; } else { D9_Button.Foreground = keyUpFG; D9_Button.Background = keyUpBG; } break; } case Key.D0: { if (Keyboard.IsKeyDown(Key.D0)) { D0_Button.Foreground = keyDownFG; D0_Button.Background = keyDownBG; } else { D0_Button.Foreground = keyUpFG; D0_Button.Background = keyUpBG; } break; } case Key.OemMinus: { if (Keyboard.IsKeyDown(Key.OemMinus)) { Subtract_Button.Foreground = keyDownFG; Subtract_Button.Background = keyDownBG; } else { Subtract_Button.Foreground = keyUpFG; Subtract_Button.Background = keyUpBG; } break; } case Key.OemPlus: { if (Keyboard.IsKeyDown(Key.OemPlus)) { Plus_Button.Foreground = keyDownFG; Plus_Button.Background = keyDownBG; } else { Plus_Button.Foreground = keyUpFG; Plus_Button.Background = keyUpBG; } break; } case Key.Back: { if (Keyboard.IsKeyDown(Key.Back)) { Backspace_Button.Foreground = keyDownFG; Backspace_Button.Background = keyDownBG; } else { Backspace_Button.Foreground = keyUpFG; Backspace_Button.Background = keyUpBG; } break; } //Top Key Row case Key.Tab: { if (Keyboard.IsKeyDown(Key.Tab)) { Tab_Button.Foreground = keyDownFG; Tab_Button.Background = keyDownBG; } else { Tab_Button.Foreground = keyUpFG; Tab_Button.Background = keyUpBG; } break; } case Key.Q: { if (Keyboard.IsKeyDown(Key.Q)) { Q_Button.Foreground = keyDownFG; Q_Button.Background = keyDownBG; } else { Q_Button.Foreground = keyUpFG; Q_Button.Background = keyUpBG; } break; } case Key.W: { if (Keyboard.IsKeyDown(Key.W)) { W_Button.Foreground = keyDownFG; W_Button.Background = keyDownBG; } else { W_Button.Foreground = keyUpFG; W_Button.Background = keyUpBG; } break; } case Key.E: { if (Keyboard.IsKeyDown(Key.E)) { E_Button.Foreground = keyDownFG; E_Button.Background = keyDownBG; } else { E_Button.Foreground = keyUpFG; E_Button.Background = keyUpBG; } break; } case Key.R: { if (Keyboard.IsKeyDown(Key.R)) { R_Button.Foreground = keyDownFG; R_Button.Background = keyDownBG; } else { R_Button.Foreground = keyUpFG; R_Button.Background = keyUpBG; } break; } case Key.T: { if (Keyboard.IsKeyDown(Key.T)) { T_Button.Foreground = keyDownFG; T_Button.Background = keyDownBG; } else { T_Button.Foreground = keyUpFG; T_Button.Background = keyUpBG; } break; } case Key.Y: { if (Keyboard.IsKeyDown(Key.Y)) { Y_Button.Foreground = keyDownFG; Y_Button.Background = keyDownBG; } else { Y_Button.Foreground = keyUpFG; Y_Button.Background = keyUpBG; } break; } case Key.U: { if (Keyboard.IsKeyDown(Key.U)) { U_Button.Foreground = keyDownFG; U_Button.Background = keyDownBG; } else { U_Button.Foreground = keyUpFG; U_Button.Background = keyUpBG; } break; } case Key.I: { if (Keyboard.IsKeyDown(Key.I)) { I_Button.Foreground = keyDownFG; I_Button.Background = keyDownBG; } else { I_Button.Foreground = keyUpFG; I_Button.Background = keyUpBG; } break; } case Key.O: { if (Keyboard.IsKeyDown(Key.O)) { O_Button.Foreground = keyDownFG; O_Button.Background = keyDownBG; } else { O_Button.Foreground = keyUpFG; O_Button.Background = keyUpBG; } break; } case Key.P: { if (Keyboard.IsKeyDown(Key.P)) { P_Button.Foreground = keyDownFG; P_Button.Background = keyDownBG; } else { P_Button.Foreground = keyUpFG; P_Button.Background = keyUpBG; } break; } case Key.OemOpenBrackets: { if (Keyboard.IsKeyDown(Key.OemOpenBrackets)) { OpenBracket_Button.Foreground = keyDownFG; OpenBracket_Button.Background = keyDownBG; } else { OpenBracket_Button.Foreground = keyUpFG; OpenBracket_Button.Background = keyUpBG; } break; } case Key.OemCloseBrackets: { if (Keyboard.IsKeyDown(Key.OemCloseBrackets)) { CloseBracket_Button.Foreground = keyDownFG; CloseBracket_Button.Background = keyDownBG; } else { CloseBracket_Button.Foreground = keyUpFG; CloseBracket_Button.Background = keyUpBG; } break; } case Key.OemBackslash: { if (Keyboard.IsKeyDown(Key.OemBackslash)) { Backslash1_Button.Foreground = keyDownFG; Backslash1_Button.Background = keyDownBG; } else { Backslash1_Button.Foreground = keyUpFG; Backslash1_Button.Background = keyUpBG; } break; } // Home Row Keys case Key.A: { if (Keyboard.IsKeyDown(Key.A)) { A_Button.Foreground = keyDownFG; A_Button.Background = keyDownBG; } else { A_Button.Foreground = keyUpFG; A_Button.Background = keyUpBG; } break; } case Key.S: { if (Keyboard.IsKeyDown(Key.S)) { S_Button.Foreground = keyDownFG; S_Button.Background = keyDownBG; } else { S_Button.Foreground = keyUpFG; S_Button.Background = keyUpBG; } break; } case Key.D: { if (Keyboard.IsKeyDown(Key.D)) { D_Button.Foreground = keyDownFG; D_Button.Background = keyDownBG; } else { D_Button.Foreground = keyUpFG; D_Button.Background = keyUpBG; } break; } case Key.F: { if (Keyboard.IsKeyDown(Key.F)) { F_Button.Foreground = keyDownFG; F_Button.Background = keyDownBG; } else { F_Button.Foreground = keyUpFG; F_Button.Background = keyUpBG; } break; } case Key.G: { if (Keyboard.IsKeyDown(Key.G)) { G_Button.Foreground = keyDownFG; G_Button.Background = keyDownBG; } else { G_Button.Foreground = keyUpFG; G_Button.Background = keyUpBG; } break; } case Key.H: { if (Keyboard.IsKeyDown(Key.H)) { H_Button.Foreground = keyDownFG; H_Button.Background = keyDownBG; } else { H_Button.Foreground = keyUpFG; H_Button.Background = keyUpBG; } break; } case Key.J: { if (Keyboard.IsKeyDown(Key.J)) { J_Button.Foreground = keyDownFG; J_Button.Background = keyDownBG; } else { J_Button.Foreground = keyUpFG; J_Button.Background = keyUpBG; } break; } case Key.K: { if (Keyboard.IsKeyDown(Key.K)) { K_Button.Foreground = keyDownFG; K_Button.Background = keyDownBG; } else { K_Button.Foreground = keyUpFG; K_Button.Background = keyUpBG; } break; } case Key.L: { if (Keyboard.IsKeyDown(Key.L)) { L_Button.Foreground = keyDownFG; L_Button.Background = keyDownBG; } else { L_Button.Foreground = keyUpFG; L_Button.Background = keyUpBG; } break; } case Key.OemSemicolon: { if (Keyboard.IsKeyDown(Key.OemSemicolon)) { SemiCol_Button.Foreground = keyDownFG; SemiCol_Button.Background = keyDownBG; } else { SemiCol_Button.Foreground = keyUpFG; SemiCol_Button.Background = keyUpBG; } break; } case Key.OemQuotes: { if (Keyboard.IsKeyDown(Key.OemQuotes)) { Quote_Button.Foreground = keyDownFG; Quote_Button.Background = keyDownBG; } else { Quote_Button.Foreground = keyUpFG; Quote_Button.Background = keyUpBG; } break; } // Bottom Row Keybed case Key.Z: { if (Keyboard.IsKeyDown(Key.Z)) { Z_Button.Foreground = keyDownFG; Z_Button.Background = keyDownBG; } else { Z_Button.Foreground = keyUpFG; Z_Button.Background = keyUpBG; } break; } case Key.X: { if (Keyboard.IsKeyDown(Key.X)) { X_Button.Foreground = keyDownFG; X_Button.Background = keyDownBG; } else { X_Button.Foreground = keyUpFG; X_Button.Background = keyUpBG; } break; } case Key.C: { if (Keyboard.IsKeyDown(Key.C)) { C_Button.Foreground = keyDownFG; C_Button.Background = keyDownBG; } else { C_Button.Foreground = keyUpFG; C_Button.Background = keyUpBG; } break; } case Key.V: { if (Keyboard.IsKeyDown(Key.V)) { V_Button.Foreground = keyDownFG; V_Button.Background = keyDownBG; } else { V_Button.Foreground = keyUpFG; V_Button.Background = keyUpBG; } break; } case Key.B: { if (Keyboard.IsKeyDown(Key.B)) { B_Button.Foreground = keyDownFG; B_Button.Background = keyDownBG; } else { B_Button.Foreground = keyUpFG; B_Button.Background = keyUpBG; } break; } case Key.N: { if (Keyboard.IsKeyDown(Key.N)) { N_Button.Foreground = keyDownFG; N_Button.Background = keyDownBG; } else { N_Button.Foreground = keyUpFG; N_Button.Background = keyUpBG; } break; } case Key.M: { if (Keyboard.IsKeyDown(Key.M)) { M_Button.Foreground = keyDownFG; M_Button.Background = keyDownBG; } else { M_Button.Foreground = keyUpFG; M_Button.Background = keyUpBG; } break; } case Key.OemComma: { if (Keyboard.IsKeyDown(Key.OemComma)) { Comma_Button.Foreground = keyDownFG; Comma_Button.Background = keyDownBG; } else { Comma_Button.Foreground = keyUpFG; Comma_Button.Background = keyUpBG; } break; } case Key.OemPeriod: { if (Keyboard.IsKeyDown(Key.OemPeriod)) { Period_Button.Foreground = keyDownFG; Period_Button.Background = keyDownBG; } else { Period_Button.Foreground = keyUpFG; Period_Button.Background = keyUpBG; } break; } case Key.OemQuestion: { if (Keyboard.IsKeyDown(Key.OemQuestion)) { Question_Button.Foreground = keyDownFG; Question_Button.Background = keyDownBG; } else { Question_Button.Foreground = keyUpFG; Question_Button.Background = keyUpBG; } break; } //Function Keys // Enter Key case Key.Enter: { if (Keyboard.IsKeyDown(Key.Enter)) { Enter_Button.Foreground = keyDownFG; Enter_Button.Background = keyDownBG; } else { Enter_Button.Foreground = keyUpFG; Enter_Button.Background = keyUpBG; } break; } // Space Key case Key.Space: { if (Keyboard.IsKeyDown(Key.Space)) { Space_Button.Foreground = keyDownFG; Space_Button.Background = keyDownBG; } else { Space_Button.Foreground = keyUpFG; Space_Button.Background = keyUpBG; } break; } // Caps Lock Button case Key.CapsLock: { if (Keyboard.IsKeyToggled(Key.CapsLock)) { Caps_Button.Foreground = keyDownFG; Caps_Button.Background = keyDownBG; } else { Caps_Button.Foreground = keyUpFG; Caps_Button.Background = keyUpBG; } break; } case Key.LeftShift: { if (Keyboard.IsKeyDown(Key.LeftShift)) { LShift_Button.Foreground = keyDownFG; LShift_Button.Background = keyDownBG; } else { LShift_Button.Foreground = keyUpFG; LShift_Button.Background = keyUpBG; } break; } case Key.RightShift: { if (Keyboard.IsKeyDown(Key.RightShift)) { RShift_Button.Foreground = keyDownFG; RShift_Button.Background = keyDownBG; } else { RShift_Button.Foreground = keyUpFG; RShift_Button.Background = keyUpBG; } break; } case Key.LeftCtrl: { if (Keyboard.IsKeyDown(Key.LeftCtrl)) { LControl_Button.Foreground = keyDownFG; LControl_Button.Background = keyDownBG; } else { LControl_Button.Foreground = keyUpFG; LControl_Button.Background = keyUpBG; } break; } case Key.RightCtrl: { if (Keyboard.IsKeyDown(Key.RightCtrl)) { RControl_Button.Foreground = keyDownFG; RControl_Button.Background = keyDownBG; } else { RControl_Button.Foreground = keyUpFG; RControl_Button.Background = keyUpBG; } break; } case Key.LWin: { if (Keyboard.IsKeyDown(Key.LWin)) { LWindow_Button.Foreground = keyDownFG; LWindow_Button.Background = keyDownBG; } else { LWindow_Button.Foreground = keyUpFG; LWindow_Button.Background = keyUpBG; } break; } case Key.RWin: { if (Keyboard.IsKeyDown(Key.RWin)) { RWindow_Button.Foreground = keyDownFG; RWindow_Button.Background = keyDownBG; } else { RWindow_Button.Foreground = keyUpFG; RWindow_Button.Background = keyUpBG; } break; } case Key.LeftAlt: { if (Keyboard.IsKeyDown(Key.LeftAlt)) { LAlt_Button.Foreground = keyDownFG; LAlt_Button.Background = keyDownBG; } else { LAlt_Button.Foreground = keyUpFG; LAlt_Button.Background = keyUpBG; } break; } case Key.RightAlt: { if (Keyboard.IsKeyDown(Key.RightAlt)) { RAlt_Button.Foreground = keyDownFG; RAlt_Button.Background = keyDownBG; } else { RAlt_Button.Foreground = keyUpFG; RAlt_Button.Background = keyUpBG; } break; } case Key.Escape: { this.Close(); break; } default: { break; } } }
/// <summary> /// Hides the login warning. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.Input.KeyEventArgs"/> instance containing the event data.</param> private void HideLoginWarning(object sender, System.Windows.Input.KeyEventArgs e) { lblLoginWarning.Visibility = Visibility.Hidden; }
private void FilterBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { filterText = FilterBox.Text; }
private void txtLastName_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { }
private void EditorKeyUp(object sender, System.Windows.Input.KeyEventArgs e) { switch (e.Key) { case Key.NumPad5: offset_x_ = offset_y_ = 0; this.UpdateMatrix(); break; case Key.Left: case Key.NumPad4: { float step = 128; if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { step *= 4; } offset_x_ -= step; this.UpdateMatrix(); } break; case Key.Right: case Key.NumPad6: { float step = 128; if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { step *= 4; } offset_x_ += step; this.UpdateMatrix(); } break; case Key.Up: case Key.NumPad8: { float step = 128; if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { step *= 4; } offset_y_ -= step; this.UpdateMatrix(); } break; case Key.Down: case Key.NumPad2: { float step = 128; if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { step *= 4; } offset_y_ += step; this.UpdateMatrix(); } break; case Key.Add: if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { old_zoom_index_ = zoom_index_; ++zoom_index_; } else if ((Keyboard.Modifiers & ModifierKeys.Shift) > 0) { stops_ += 0.1f; } else { ++stops_; } this.UpdateTextureProperties(); break; case Key.Subtract: if ((Keyboard.Modifiers & ModifierKeys.Control) > 0) { old_zoom_index_ = zoom_index_; --zoom_index_; } else if ((Keyboard.Modifiers & ModifierKeys.Shift) > 0) { stops_ -= 0.1f; } else { --stops_; } this.UpdateTextureProperties(); break; } }
//老板键 private void Se_BossKey_Key_KeyDown(Object sender, System.Windows.Input.KeyEventArgs e) { byte PressAlt = 0; //Alt byte PressCtrl = 0; //Ctrl byte PressShift = 0; //Shift int ControlKeys = 0; //Alt + Ctrl + Shift的值 string PreString = ""; //前面的值 string MainKey = ""; //主值 //字母 || F1-F12 || 小键盘区的数字 || 空格? if ((e.Key >= Key.A && e.Key <= Key.Z) || (e.Key >= Key.F1 && e.Key <= Key.F12) || (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || (e.Key == Key.Space)) { e.Handled = true; MainKey = e.Key.ToString(); } //字母区上面的数字 if (e.Key >= Key.D0 && e.Key <= Key.D9) { e.Handled = true; MainKey = e.Key.ToString().Replace("D", ""); } //Alt Ctrl Shift键判断 if ((System.Windows.Forms.Control.ModifierKeys & Keys.Alt) == Keys.Alt) { PressAlt = 1; } else { PressAlt = 0; } if ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) == Keys.Control) { PressCtrl = 2; } else { PressCtrl = 0; } if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift) { PressShift = 4; } else { PressShift = 0; } ControlKeys = PressAlt + PressCtrl + PressShift; switch (ControlKeys) { case 1: PreString = "Alt + "; break; case 2: PreString = "Ctrl + "; break; case 3: PreString = "Ctrl + Alt + "; break; case 4: PreString = "Shift + "; break; case 5: PreString = "Alt + Shift + "; break; case 6: PreString = "Ctrl + Shift + "; break; case 7: PreString = "Ctrl + Alt + Shift + "; break; default: PreString = ""; break; } //输出值 if (MainKey != "") { Se_BossKey_Key.Content = PreString + MainKey; } else { Se_BossKey_Key.Content = "Ctrl + Alt + B"; } }
private void txtPassword_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { }
protected override void OnKeyUp(KeyEventArgs e) => _ttl.Input?.Invoke(new RawKeyEventArgs(_keyboard, (uint)e.Timestamp, _inputRoot, RawKeyEventType.KeyUp, (Key)e.Key, GetModifiers(null)));
private void KeyDownCheckIfNotNumber(object sender, System.Windows.Input.KeyEventArgs e) { Data.NumericCheck(sender, e); }
private void Column_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { var txt = sender as TextBox; }
protected override void OnPreviewKeyDown(System.Windows.Input.KeyEventArgs e) { this.cellChangeEvent = (e.Key == Key.Tab) ? InputEventType.TabKey : InputEventType.None; base.OnPreviewKeyDown(e); }
private void PreNotifyInput(object sender, NotifyInputEventArgs e) { RawKeyboardInputReport keyboardInput = ExtractRawKeyboardInputReport(e, InputManager.PreviewInputReportEvent); if (keyboardInput != null) { CheckForDisconnectedFocus(); // Activation // // MITIGATION: KEYBOARD_STATE_OUT_OF_SYNC // // It is very important that we allow multiple activate events. // This is how we deal with the fact that Win32 sometimes sends // us a WM_SETFOCUS message BEFORE it has updated it's internal // internal keyboard state information. When we get the // WM_SETFOCUS message, we activate the keyboard with the // keyboard state (even though it could be wrong). Then when // we get the first "real" keyboard input event, we activate // the keyboard again, since Win32 will have updated the // keyboard state correctly by then. // if ((keyboardInput.Actions & RawKeyboardActions.Activate) == RawKeyboardActions.Activate) { //if active source is null, no need to do special-case handling if (_activeSource == null) { // we are now active. _activeSource = new SecurityCriticalDataClass <PresentationSource>(keyboardInput.InputSource); } else if (_activeSource.Value != keyboardInput.InputSource) { IKeyboardInputProvider toDeactivate = _activeSource.Value.GetInputProvider(typeof(KeyboardDevice)) as IKeyboardInputProvider; // we are now active. _activeSource = new SecurityCriticalDataClass <PresentationSource>(keyboardInput.InputSource); if (toDeactivate != null) { toDeactivate.NotifyDeactivate(); } } } // Generally, we need to check against redundant actions. // We never prevet the raw event from going through, but we // will only generate the high-level events for non-redundant // actions. We store the set of non-redundant actions in // the dictionary of this event. // If the input is reporting a key down, the action is never // considered redundant. if ((keyboardInput.Actions & RawKeyboardActions.KeyDown) == RawKeyboardActions.KeyDown) { RawKeyboardActions actions = GetNonRedundantActions(e); actions |= RawKeyboardActions.KeyDown; e.StagingItem.SetData(_tagNonRedundantActions, actions); // Pass along the key that was pressed, and update our state. Key key = KeyInterop.KeyFromVirtualKey(keyboardInput.VirtualKey); e.StagingItem.SetData(_tagKey, key); e.StagingItem.SetData(_tagScanCode, new ScanCode(keyboardInput.ScanCode, keyboardInput.IsExtendedKey)); // Tell the InputManager that the MostRecentDevice is us. if (_inputManager != null) { _inputManager.Value.MostRecentInputDevice = this; } } // We are missing detection for redundant ups if ((keyboardInput.Actions & RawKeyboardActions.KeyUp) == RawKeyboardActions.KeyUp) { RawKeyboardActions actions = GetNonRedundantActions(e); actions |= RawKeyboardActions.KeyUp; e.StagingItem.SetData(_tagNonRedundantActions, actions); // Pass along the key that was pressed, and update our state. Key key = KeyInterop.KeyFromVirtualKey(keyboardInput.VirtualKey); e.StagingItem.SetData(_tagKey, key); e.StagingItem.SetData(_tagScanCode, new ScanCode(keyboardInput.ScanCode, keyboardInput.IsExtendedKey)); // Tell the InputManager that the MostRecentDevice is us. if (_inputManager != null) { _inputManager.Value.MostRecentInputDevice = this; } } } // On KeyDown, we might need to set the Repeat flag if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent) { CheckForDisconnectedFocus(); KeyEventArgs args = (KeyEventArgs)e.StagingItem.Input; // Is this the same as the previous key? (Look at the real key, e.g. TextManager // might have changed args.Key it to Key.TextInput.) if (_previousKey == args.RealKey) { // Yes, this is a repeat (we got the keydown for it twice, with no KeyUp in between) args.SetRepeat(true); } // Otherwise, keep this key to check against next time. else { _previousKey = args.RealKey; args.SetRepeat(false); } } // On KeyUp, we clear Repeat flag else if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent) { CheckForDisconnectedFocus(); KeyEventArgs args = (KeyEventArgs)e.StagingItem.Input; args.SetRepeat(false); // Clear _previousKey, so that down/up/down/up doesn't look like a repeat _previousKey = Key.None; } }
// Handle Alt+F4.. protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e) { e.Handled = true; //General Hooks CAN'T ban Ctrl+Alt+Del }
private void onKeyPress(Object sender, System.Windows.Input.KeyEventArgs e) { userStatsLbl.Visibility = Visibility.Visible; switch (e.Key) { case Key.Escape: Close(); break; case Key.W: if (this.WindowState == WindowState.Minimized) { //this happens in the one screen situation this.WindowState = WindowState.Maximized; return; } if (this.Height == 1000) { maxWindow(); } else { this.Height = 1000; this.Width = 1000; this.WindowState = WindowState.Normal; this.WindowStyle = WindowStyle.SingleBorderWindow; } break; case Key.M: mvPlaying = !mvPlaying; if (mvPlaying) { maleSpiderVideo.Play(); } else { maleSpiderVideo.Stop(); } break; case Key.V: if (secondWindow) { fvPlaying = !fvPlaying; if (fvPlaying) { window1.femaleSpiderVideo.Play(); } else { window1.femaleSpiderVideo.Stop(); } } break; case Key.F: stopFubi = !stopFubi; Console.WriteLine("Fubi state:" + stopDepthVideo); break; case Key.S: stopDepthVideo = !stopDepthVideo; Console.WriteLine("Depth video state:" + stopDepthVideo); break; case Key.L: filterActive = !filterActive; Console.WriteLine("Filter state:" + filterActive); break; case Key.Space: setProgress(gameStage + 1); break; case Key.Tab: testMode = 1 - testMode; break; // case Key.P: // Console.WriteLine("Pos1:" + window1.femaleSpiderVideo.Position); // if (window1.femaleSpiderVideo.IsLoaded) // { // //window1.femaleSpiderVideo.Stop(); // //window1.femaleSpiderVideo.Play(); // } // Console.WriteLine("Pos2:" + window1.femaleSpiderVideo.Position); // Console.WriteLine("Duration:" + window1.femaleSpiderVideo.NaturalDuration); // int seconds = (int)(window1.femaleSpiderVideo.NaturalDuration.TimeSpan.TotalSeconds / 10.0); // window1.femaleSpiderVideo.Position += new TimeSpan(0, 0, seconds); // Console.WriteLine("Pos3:" + window1.femaleSpiderVideo.Position); // break; } }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { // PreviewKeyDown --> KeyDown if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { KeyEventArgs previewKeyDown = (KeyEventArgs)e.StagingItem.Input; // Dig out the real key. bool isSystemKey = false; bool isImeProcessed = false; bool isDeadCharProcessed = false; Key key = previewKeyDown.Key; if (key == Key.System) { isSystemKey = true; key = previewKeyDown.RealKey; } else if (key == Key.ImeProcessed) { isImeProcessed = true; key = previewKeyDown.RealKey; } else if (key == Key.DeadCharProcessed) { isDeadCharProcessed = true; key = previewKeyDown.RealKey; } KeyEventArgs keyDown = new KeyEventArgs(this, previewKeyDown.UnsafeInputSource, previewKeyDown.Timestamp, key); keyDown.SetRepeat(previewKeyDown.IsRepeat); // Mark the new event as SystemKey as appropriate. if (isSystemKey) { keyDown.MarkSystem(); } else if (isImeProcessed) { // Mark the new event as ImeProcessed as appropriate. keyDown.MarkImeProcessed(); } else if (isDeadCharProcessed) { keyDown.MarkDeadCharProcessed(); } keyDown.RoutedEvent = Keyboard.KeyDownEvent; keyDown.ScanCode = previewKeyDown.ScanCode; keyDown.IsExtendedKey = previewKeyDown.IsExtendedKey; e.PushInput(keyDown, e.StagingItem); } } // PreviewKeyUp --> KeyUp if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { KeyEventArgs previewKeyUp = (KeyEventArgs)e.StagingItem.Input; // Dig out the real key. bool isSystemKey = false; bool isImeProcessed = false; bool isDeadCharProcessed = false; Key key = previewKeyUp.Key; if (key == Key.System) { isSystemKey = true; key = previewKeyUp.RealKey; } else if (key == Key.ImeProcessed) { isImeProcessed = true; key = previewKeyUp.RealKey; } else if (key == Key.DeadCharProcessed) { isDeadCharProcessed = true; key = previewKeyUp.RealKey; } KeyEventArgs keyUp = new KeyEventArgs(this, previewKeyUp.UnsafeInputSource, previewKeyUp.Timestamp, key); // Mark the new event as SystemKey as appropriate. if (isSystemKey) { keyUp.MarkSystem(); } else if (isImeProcessed) { // Mark the new event as ImeProcessed as appropriate. keyUp.MarkImeProcessed(); } else if (isDeadCharProcessed) { keyUp.MarkDeadCharProcessed(); } keyUp.RoutedEvent = Keyboard.KeyUpEvent; keyUp.ScanCode = previewKeyUp.ScanCode; keyUp.IsExtendedKey = previewKeyUp.IsExtendedKey; e.PushInput(keyUp, e.StagingItem); } } RawKeyboardInputReport keyboardInput = ExtractRawKeyboardInputReport(e, InputManager.InputReportEvent); if (keyboardInput != null) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { // In general, this is where we promote the non-redundant // reported actions to our premier events. RawKeyboardActions actions = GetNonRedundantActions(e); // Raw --> PreviewKeyDown if ((actions & RawKeyboardActions.KeyDown) == RawKeyboardActions.KeyDown) { Key key = (Key)e.StagingItem.GetData(_tagKey); if (key != Key.None) { KeyEventArgs previewKeyDown = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key); ScanCode scanCode = (ScanCode)e.StagingItem.GetData(_tagScanCode); previewKeyDown.ScanCode = scanCode.Code; previewKeyDown.IsExtendedKey = scanCode.IsExtended; if (keyboardInput.IsSystemKey) { previewKeyDown.MarkSystem(); } previewKeyDown.RoutedEvent = Keyboard.PreviewKeyDownEvent; e.PushInput(previewKeyDown, e.StagingItem); } } // Raw --> PreviewKeyUp if ((actions & RawKeyboardActions.KeyUp) == RawKeyboardActions.KeyUp) { Key key = (Key)e.StagingItem.GetData(_tagKey); if (key != Key.None) { KeyEventArgs previewKeyUp = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key); ScanCode scanCode = (ScanCode)e.StagingItem.GetData(_tagScanCode); previewKeyUp.ScanCode = scanCode.Code; previewKeyUp.IsExtendedKey = scanCode.IsExtended; if (keyboardInput.IsSystemKey) { previewKeyUp.MarkSystem(); } previewKeyUp.RoutedEvent = Keyboard.PreviewKeyUpEvent; e.PushInput(previewKeyUp, e.StagingItem); } } } // Deactivate if ((keyboardInput.Actions & RawKeyboardActions.Deactivate) == RawKeyboardActions.Deactivate) { if (IsActive) { _activeSource = null; // Even if handled, a keyboard deactivate results in a lost focus. ChangeFocus(null, e.StagingItem.Input.Timestamp); } } } }