public void GoToLastGame() { try { int i = 0; if (FavoritesMode == FavoritesMode.Favorites) { Game game = _search.FindGameByName(Settings.Default.last_game, out i); if (game != null && game.IsFavorite) SelectedGame = game; } else { Game game = _search.FindGameByName(Settings.Default.last_game, out i); SelectedGame = game ?? Games.First().Value; } } catch (Exception) { SelectedGame = null; } }
protected override void OnKeyDown(KeyEventArgs e) { if (e.Control) { ControlKeyPressed = true; } Invalidate(); base.OnKeyDown(e); switch (e.KeyCode) { case Keys.R: if (e.Control) { Random rand = new Random(DateTime.Now.Millisecond); int iRand = rand.Next(0, Games.Count); SelectedGame = GetNodeAtRow(iRand); } break; case Keys.Back: if (e.Control && Filter.Length != 0) { Filter = ""; } break; case Keys.Down: if (e.Control) { ScrollInfoText(3, InfoScrollMode.Line); } else { NavigateForward(1); } break; case Keys.Up: if (e.Control) { ScrollInfoText(-3, InfoScrollMode.Line); } else { NavigateBackward(1); } break; case Keys.PageDown: if (e.Control) { ScrollInfoText(1, InfoScrollMode.Page); } else { NavigateForward(ClientRectangle.Height / RowHeight); } break; case Keys.PageUp: if (e.Control) { ScrollInfoText(-1, InfoScrollMode.Page); } else { NavigateBackward(ClientRectangle.Height / RowHeight); } break; case Keys.Home: if (e.Control) { ScrollInfoText(-1, InfoScrollMode.All); } else if (SelectedGame != null && FavoritesMode == FavoritesMode.FavoritesAndGames) { Game lastFavorite = GetNodeAtRow(CountFavorites); if (SelectedGame.IsFavorite || SelectedGame == lastFavorite) { SelectedGame = Games.First().Value; } else { SelectedGame = lastFavorite; } } else { SelectedGame = Games.First().Value; } break; case Keys.End: if (e.Control) { ScrollInfoText(1, InfoScrollMode.All); } else if (SelectedGame != null && FavoritesMode == FavoritesMode.FavoritesAndGames) { Game lastFavorite = GetNodeAtRow(CountFavorites - 1); if (!SelectedGame.IsFavorite || SelectedGame == lastFavorite) { SelectedGame = Games.Last().Value; } else { SelectedGame = lastFavorite; } } else { SelectedGame = Games.Last().Value; } break; case Keys.Enter: if (Focused) { StartGame(); } break; case Keys.D0: case Keys.D1: case Keys.D2: case Keys.D3: case Keys.D4: case Keys.D5: case Keys.D6: case Keys.D7: case Keys.D8: case Keys.D9: if (e.Alt) { int artType = e.KeyValue - (int)Keys.D0; if (artType < SettingsManager.ArtPaths.Count) { Settings.Default.art_type = artType; ArtType = Settings.Default.art_type; RefreshImage(); } e.SuppressKeyPress = true; } break; } }