private async void ChatWindow_KeyUp(object sender, Avalonia.Input.KeyEventArgs e) { if (e.Key == Avalonia.Input.Key.Enter) { await ViewModel.SendChatMessage(); } }
public virtual void MoveCharacter(Avalonia.Input.KeyEventArgs pressed, int newPositionX = 0, int newPositionY = 0) { Map[(int)PositionOnArray.X, (int)PositionOnArray.Y] = 0; Map[(int)PositionOnArray.X + newPositionX, (int)PositionOnArray.Y + newPositionY] = 1; /*DrawCharacter(new Point(PositionOnArray.X + newPositionX, PositionOnArray.Y + newPositionY));*/ }
private void UrlTextBox_KeyUp(object?sender, Avalonia.Input.KeyEventArgs e) { if (e.Key == Avalonia.Input.Key.Enter) { webView.Navigate(urlTextBox.Text); } }
private void TbxHand_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { try { if (e.Key == Avalonia.Input.Key.Up || e.Key == Avalonia.Input.Key.Down) { TextBox tbxSender = sender as TextBox; int v = Convert.ToInt32(tbxSender.Text); switch (e.Key) { case Avalonia.Input.Key.Up: v++; break; case Avalonia.Input.Key.Down: v--; break; default: return; } tbxSender.Text = v.ToString(); } } catch { } }
private void Search_KeyUp(object sender, Avalonia.Input.KeyEventArgs e) { if (e.Key == Avalonia.Input.Key.Enter) { filter = search.Text.ToLower(); ApplySearchFilter(); } }
private void TargetBox_KeyUp(object sender, Avalonia.Input.KeyEventArgs e) { var sourceCharCount = sourceBox.Text.Length; var targetCharCount = targetBox.Text.Length; var sourceWordCount = sourceBox.Text.Split(' ').Length; var targetWordCount = targetBox.Text.Split(' ').Length; statusBox.Text = "Source: " + sourceCharCount + " | " + sourceWordCount + " Target: " + targetCharCount + " | " + targetWordCount; }
private void MainWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { if (e.Key == Avalonia.Input.Key.Escape) { slideTimer.Stop(); clock.Stop(); this.Close(); server.Stop(); (Application.Current as IControlledApplicationLifetime).Shutdown(); } }
private void MainWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { if (e.Key == Avalonia.Input.Key.Down) { var items = scrollPanel.Children.Cast <PacketListItem>().ToList(); if (seletedItem == null && items.Count() != 0) { items.First().Select(); } else if (seletedItem != null) { for (int i = 0; i < items.Count(); i++) { if (items[i] == seletedItem) { i++; if (i >= items.Count()) { break; } items[i].Select(); seletedItem.BringIntoView(); break; } } } } else if (e.Key == Avalonia.Input.Key.Up) { var items = scrollPanel.Children.Cast <PacketListItem>().ToList(); if (seletedItem == null && items.Count() != 0) { items.First().Select(); } else if (seletedItem != null) { for (int i = 0; i < items.Count(); i++) { if (items[i] == seletedItem) { i--; if (i < 0) { break; } items[i].Select(); seletedItem.BringIntoView(); break; } } } } }
private void TextBoxTextInput(object sender, Avalonia.Input.KeyEventArgs e) { string widthResolutionTextBoxText = widthResolutionTextBox.Text; string heightResolutionTextBoxText = heightResolutionTextBox.Text; Regex rgx = new Regex("[^0-9]"); widthResolutionTextBoxText = rgx.Replace(widthResolutionTextBoxText, ""); heightResolutionTextBoxText = rgx.Replace(heightResolutionTextBoxText, ""); Settings.Instance.SetResolution(Convert.ToInt32(widthResolutionTextBoxText), Convert.ToInt32(heightResolutionTextBoxText)); }
public override void HandleKeyPress(KeyEventArgs args) { if (hotkeyEntering) { if (args.Key != 0 && args.Key != Key.LeftAlt && args.Key != Key.RightAlt && args.Key != Key.RightCtrl && args.Key != Key.LeftCtrl && args.Key != Key.RightShift && args.Key != Key.LeftShift && args.Key != Key.LWin && args.Key != Key.RWin) { hotkeyEntering = false; ClientHotkey.Key = args.Key; model.SetClientHotkey(SelectedClient, ClientHotkey); ClientHotkey = new ISHotkeyModel(SelectedClient.ClientHotkey); this.RaisePropertyChanged(nameof(ClientHotkey)); } } }
public static void OnKeyDown(Avalonia.Input.KeyEventArgs e, bool down) { Key key; switch (e.Key) { case Avalonia.Input.Key.Q: key = Key.L; break; case Avalonia.Input.Key.W: key = Key.R; break; case Avalonia.Input.Key.A: key = Key.X; break; case Avalonia.Input.Key.S: key = Key.Y; break; case Avalonia.Input.Key.Z: key = Key.B; break; case Avalonia.Input.Key.X: key = Key.A; break; case Avalonia.Input.Key.Left: key = Key.Left; break; case Avalonia.Input.Key.Right: key = Key.Right; break; case Avalonia.Input.Key.Down: key = Key.Down; break; case Avalonia.Input.Key.Up: key = Key.Up; break; case Avalonia.Input.Key.Enter: key = Key.Start; break; case Avalonia.Input.Key.RightShift: key = Key.Select; break; default: return; } KeyDownData p = _pressed[key]; if (down) { p.PressTime++; } else { p.PressChecked = false; p.PressTime = 0; } e.Handled = true; }
private void OnKeyDown(object?sender, KeyEventArgs e) { if (!_recording || Hotkeys == null) { Hotkeys = null; Hotkeys = new List <Key>(); } if (Hotkeys.Contains(e.Key)) { return; } Hotkeys.Add(e.Key); _recording = true; _keyLabel.Text = Hotkeys.AsAvaloniaHotkeyString(); e.Handled = true; }
/// <summary> /// While Move control has focus, user can use the arrow keys to move the preview. /// </summary> private void Move_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { try { int x = Convert.ToInt32(tbxHandX.Text); int y = Convert.ToInt32(tbxHandY.Text); switch (e.Key) { case Avalonia.Input.Key.Left: tbxHandX.Text = (--x).ToString(); break; case Avalonia.Input.Key.Right: tbxHandX.Text = (++x).ToString(); break; case Avalonia.Input.Key.Up: tbxHandY.Text = (++y).ToString(); break; case Avalonia.Input.Key.Down: tbxHandY.Text = (--y).ToString(); break; default: return; } this.x = x; this.y = y; } catch { tbxHandX.Text = "0"; tbxHandX.InvalidateVisual(); tbxHandY.Text = "0"; tbxHandY.InvalidateVisual(); } }
private void FolderNavigation_KeyDown(object?sender, Avalonia.Input.KeyEventArgs e) { // Register key bindings to improve file navigation. // These are inspired by common shortcuts for Windows Explorer, Finder, etc. switch (e.Key) { case Avalonia.Input.Key.Right: case Avalonia.Input.Key.Enter: ViewModel?.EnterSelectedFolder(); break; case Avalonia.Input.Key.Left: ViewModel?.ExitFolder(); break; case Avalonia.Input.Key.Up: if (e.KeyModifiers == Avalonia.Input.KeyModifiers.Alt) { ViewModel?.ExitFolder(); } else { ViewModel?.SelectPreviousFile(); } break; case Avalonia.Input.Key.Down: ViewModel?.SelectNextFile(); break; default: break; } e.Handled = true; }
private void MainWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { // Exit on Escape or Control X (Windows and Linux Friendly) if ((e.Key == Avalonia.Input.Key.Escape) || ((e.KeyModifiers == Avalonia.Input.KeyModifiers.Control) && (e.Key == Avalonia.Input.Key.X))) { slideTimer.Stop(); this.Close(); server.Stop(); } if (e.Key == Avalonia.Input.Key.T) { if (mainWindow.Opacity != 1) { mainWindow.Opacity = 1; } else { mainWindow.Opacity = 0; } } if (e.Key == Avalonia.Input.Key.U) { if (mainPanel.Opacity != 1) { mainPanel.Opacity = 1; } else { mainPanel.Opacity = 0; } } if (e.Key == Avalonia.Input.Key.F) { AppSettings.Default.InfoBarState = AppSettings.InfoBar.FileInfo; } if (e.Key == Avalonia.Input.Key.I) { AppSettings.Default.InfoBarState = AppSettings.InfoBar.IP; } if (e.Key == Avalonia.Input.Key.C) { AppSettings.Default.InfoBarState = AppSettings.InfoBar.DateTime; } if (e.Key == Avalonia.Input.Key.H) { tb.Opacity = 0; AppSettings.Default.InfoBarState = AppSettings.InfoBar.OFF; } if (e.Key == Avalonia.Input.Key.Right) { GoToNextImage(); } if (e.Key == Avalonia.Input.Key.Left) { GoToPreviousImage(); } if (e.Key == Avalonia.Input.Key.P) { Pause(); } UpdateInfoBar(); }
private void MainWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { (DataContext as MainWindowViewModel).CurrentView.HandleKeyPress(e); }
private void QuizScreenUserControl_KeyUp(object sender, Avalonia.Input.KeyEventArgs e) { e.Route = Avalonia.Interactivity.RoutingStrategies.Tunnel; UserControl quizUserControl = (UserControl)sender; QuizScreenViewModel dataContext = (QuizScreenViewModel)quizUserControl.DataContext; Avalonia.Input.Key pressedKey = e.Key; int pressedKeyIntCode = (int)pressedKey; if (pressedKey == Avalonia.Input.Key.Space || pressedKey == Avalonia.Input.Key.NumPad0) { dataContext.ShowAnswers(); } else if (pressedKey == Avalonia.Input.Key.Right || pressedKey == Avalonia.Input.Key.Enter) { dataContext.NextQuestion(); } else if (pressedKey == Avalonia.Input.Key.Escape) { dataContext.TerminateQuiz(); } else { // Select answer based on what number I pressed on the keyboard // CHECK: Is the quiz ended? if (dataContext.CurrentQuiz.GetUnansweredQuestion() is null) { return; } // 35 - "1" on keyboard, 43 - "9" on keyboard bool keyboardNumberPressed = (pressedKeyIntCode >= 35 && pressedKeyIntCode <= 43); // 75 - "1" on numeric keypad, 83 - "9" on numeric keypad bool numpadNumberPressed = (pressedKeyIntCode >= 75 && pressedKeyIntCode <= 83); if (keyboardNumberPressed || numpadNumberPressed) { // int choosedAnswerNumber = keyboardNumberPressed ? pressedKeyIntCode - 34 : pressedKeyIntCode - 74; ListBox answersListbox = this.FindControl <ListBox>("lst_answers"); List <AnswerSheet> answerList = (List <AnswerSheet>)answersListbox.Items; if (!(choosedAnswerNumber > answerList.Count)) { int choosedAnswerListIndex = choosedAnswerNumber - 1; AnswerSheet choosedAnswerSheet = answerList[choosedAnswerListIndex]; if (answersListbox.SelectedItems.Contains(choosedAnswerSheet)) { answersListbox.SelectedItems.Remove(choosedAnswerSheet); } else { answersListbox.SelectedItems.Add(choosedAnswerSheet); UncheckOverreplies(); } dataContext.SelectedAnswers = answersListbox.SelectedItems; } } } // Got focus again on the whole UserControl UserControl quizScreenUserControl = this.FindControl <UserControl>("quizScreenUserControl"); quizScreenUserControl.Focus(); e.Handled = true; }
private void OnKeyUp(object?sender, KeyEventArgs e) { _recording = false; e.Handled = true; }
public virtual void DrawCharacter(Point newPoint, Avalonia.Input.KeyEventArgs pressed) { DrawChar.SetPosition(Image, newPoint.X * 72, newPoint.Y * 72); PositionOnArray = newPoint; }
protected override void OnKeyUp(Avalonia.Input.KeyEventArgs e) { InputManager.OnKeyDown(e, false); base.OnKeyUp(e); }
private void MainWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e) { tb.Transitions.Clear(); // Exit on Escape or Control X (Windows and Linux Friendly) if ((e.Key == Avalonia.Input.Key.Escape) || ((e.KeyModifiers == Avalonia.Input.KeyModifiers.Control) && (e.Key == Avalonia.Input.Key.X))) { slideTimer.Stop(); this.Close(); server.Stop(); } if (e.Key == Avalonia.Input.Key.T) { if (mainWindow.Opacity != 1) { mainWindow.Opacity = 1; } else { mainWindow.Opacity = 0; } } if (e.Key == Avalonia.Input.Key.U) { if (mainPanel.Opacity != 1) { mainPanel.Opacity = 1; } else { mainPanel.Opacity = 0; } } if (e.Key == Avalonia.Input.Key.F) { infoBar = InfoBar.FileInfo; } if (e.Key == Avalonia.Input.Key.I) { infoBar = InfoBar.IP; } if (e.Key == Avalonia.Input.Key.C) { infoBar = InfoBar.Clock; } if (e.Key == Avalonia.Input.Key.Right) { frontImage.Transitions.Clear(); backImage.Transitions.Clear(); playListEngine.GoToNext(); PlayImageFile(true); lastUpdated = DateTime.Now; frontImage.Transitions.Add(fadeTransition); backImage.Transitions.Add(fadeTransition); } if (e.Key == Avalonia.Input.Key.Left) { frontImage.Transitions.Clear(); backImage.Transitions.Clear(); playListEngine.GoToPrevious(); PlayImageFile(true); lastUpdated = DateTime.Now; frontImage.Transitions.Add(fadeTransition); backImage.Transitions.Add(fadeTransition); } if (e.Key == Avalonia.Input.Key.H) { tb.Opacity = 0; infoBar = InfoBar.OFF; } UpdateInfoBar(); tb.Transitions.Add(fadeTransition); }
private void Filter_Changed(object sender, Avalonia.Input.KeyEventArgs e) { ShowDataPacket(); }