private void Keyboard_KeyPressed(Keys pressedKey) { if (currentWindow == mainWindow) { switch (pressedKey) { case Keys.Escape: Suspend(); Quit(); break; case Keys.Up: lbKuaidis.SelectPrevious(); currentWindow.Draw(); XingKongScreen.FreshScreen(); break; case Keys.Down: lbKuaidis.SelectNext(); currentWindow.Draw(); XingKongScreen.FreshScreen(); break; case Keys.Enter: int selectedIndex = lbKuaidis.SelectedIndex; ShowInfoWindow(KuaidiItemList[selectedIndex]); break; default: break; } } else if (currentWindow == kuaidiInfoWindow) { switch (pressedKey) { case Keys.Escape: ShowMainWindow(); break; default: break; } } }
private void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey) { if (pressedKey == Keys.Left) { isListHasFocus = true; switchFocus(); } else if (pressedKey == Keys.Right) { isListHasFocus = false; switchFocus(); } else if (pressedKey == Keys.Up) { if (isListHasFocus) { lbApps.SelectPrevious(); } else { btLaunch.IsChecked = true; btBack.IsChecked = false; } } else if (pressedKey == Keys.Down) { if (isListHasFocus) { lbApps.SelectNext(); } else { btLaunch.IsChecked = false; btBack.IsChecked = true; } } else if (pressedKey == Keys.Enter) { if (!isListHasFocus) { if (btBack.IsChecked) { Suspend(); QuitAction?.Invoke(); return; } if ((btLaunch.IsChecked && (lbApps.SelectedIndex >= 0)) && (lbApps.SelectedIndex <= apps.Count)) { Suspend(); LoadAppAction?.Invoke(apps[lbApps.SelectedIndex].MoudlePath); return; } } else if ((lbApps.SelectedIndex >= 0) && (lbApps.SelectedIndex <= apps.Count)) { Suspend(); Console.WriteLine(apps[lbApps.SelectedIndex].MoudlePath); LoadAppAction?.Invoke(apps[lbApps.SelectedIndex].MoudlePath); return; } } thisWindow.Draw(); XingKongScreen.FreshScreen(); }