public GameMenu(GamesEditor editor) { this.editor = editor; resources = new ResourceProvider(); DataContextChanged += GameMenu_DataContextChanged; InitializeItems(); }
public PlayniteAPI( IGameDatabaseAPI databaseApi, IDialogsFactory dialogs, IMainViewAPI mainViewApi, IPlayniteInfoAPI infoApi, IPlaynitePathsAPI pathsApi, IWebViewFactory webViewFactory, IResourceProvider resources, INotificationsAPI notifications, GamesEditor gameEditor, IUriHandlerAPI uriHandler, IPlayniteSettingsAPI settingsApi, IAddons addonsApi, IEmulationAPI emulation, ExtensionFactory extensions) { WebViews = webViewFactory; Paths = pathsApi; ApplicationInfo = infoApi; MainView = mainViewApi; Dialogs = dialogs; Database = databaseApi; Resources = resources; Notifications = notifications; this.gameEditor = gameEditor; UriHandler = uriHandler; ApplicationSettings = settingsApi; Addons = addonsApi; Emulation = emulation; this.extensions = extensions; SDK.API.Instance = this; }
public PlayniteAPI( IGameDatabaseAPI databaseApi, IDialogsFactory dialogs, IMainViewAPI mainViewApi, IPlayniteInfoAPI infoApi, IPlaynitePathsAPI pathsApi, IWebViewFactory webViewFactory, IResourceProvider resources, INotificationsAPI notifications, GamesEditor gameEditor, IUriHandlerAPI uriHandler, IPlayniteSettingsAPI settingsApi) { WebViews = webViewFactory; Paths = pathsApi; ApplicationInfo = infoApi; MainView = mainViewApi; Dialogs = dialogs; Database = databaseApi; Resources = resources; Notifications = notifications; this.gameEditor = gameEditor; UriHandler = uriHandler; ApplicationSettings = settingsApi; }
public void ExecuteScriptActionTest(ScriptLanguage language, string script) { using (var tempDir = TempDirectory.Create()) { var game = new Game() { InstallDirectory = tempDir.TempPath }; var editor = new GamesEditor(null, new GameControllerFactory(null), null, null, null, null); editor.ExecuteScriptAction(language, script, game); var testPath = Path.Combine(tempDir.TempPath, executeScriptActionTestFileName); var content = File.ReadAllText(testPath); Assert.AreEqual(language.ToString(), content.Trim()); } }
public void ExecuteScriptActionTest(PowerShellRuntime runtime, string script) { using (var tempDir = TempDirectory.Create()) { var game = new Game() { InstallDirectory = tempDir.TempPath }; var editor = new GamesEditor(null, new GameControllerFactory(null), new PlayniteSettings(), null, null, new TestPlayniteApplication()); editor.ExecuteScriptAction(runtime, script, game, true, false, GameScriptType.None); var testPath = Path.Combine(tempDir.TempPath, executeScriptActionTestFileName); var content = File.ReadAllText(testPath); Assert.AreEqual("PowerShell", content.Trim()); } }
public GameMenu(GamesEditor editor) { startIcon = Images.GetImageFromResource("Images/MenuIcons/start.png"); removeIcon = Images.GetImageFromResource("Images/MenuIcons/remove.png"); linksIcon = Images.GetImageFromResource("Images/MenuIcons/link.png"); favoriteIcon = Images.GetImageFromResource("Images/MenuIcons/favorite.png"); unFavoriteIcon = Images.GetImageFromResource("Images/MenuIcons/favoriteEmpty.png"); hideIcon = Images.GetImageFromResource("Images/MenuIcons/hideCrosed.png"); unHideIcon = Images.GetImageFromResource("Images/MenuIcons/hide.png"); browseIcon = Images.GetImageFromResource("Images/MenuIcons/folder.png"); shortcutIcon = Images.GetImageFromResource("Images/MenuIcons/shortcut.png"); installIcon = Images.GetImageFromResource("Images/MenuIcons/install.png"); editIcon = Images.GetImageFromResource("Images/MenuIcons/edit.png"); context = SynchronizationContext.Current; this.editor = editor; resources = new ResourceProvider(); DataContextChanged += GameMenu_DataContextChanged; InitializeItems(); }
private void InitializeCommands() { OpenSearchCommand = new RelayCommand <object>((game) => { if (SearchOpened) { // The binding sometimes breaks when main window is restored from minimized state. // This fixes it. SearchOpened = false; } SearchOpened = true; }, new KeyGesture(Key.F, ModifierKeys.Control)); ToggleExplorerPanelCommand = new RelayCommand <object>((game) => { AppSettings.ExplorerPanelVisible = !AppSettings.ExplorerPanelVisible; }, new KeyGesture(Key.E, ModifierKeys.Control)); ToggleFilterPanelCommand = new RelayCommand <object>((game) => { AppSettings.FilterPanelVisible = !AppSettings.FilterPanelVisible; }, new KeyGesture(Key.G, ModifierKeys.Control)); OpenFilterPanelCommand = new RelayCommand <object>((game) => { AppSettings.FilterPanelVisible = true; }); CloseFilterPanelCommand = new RelayCommand <object>((game) => { AppSettings.FilterPanelVisible = false; }); CloseNotificationPanelCommand = new RelayCommand <object>((game) => { AppSettings.NotificationPanelVisible = false; }); ThirdPartyToolOpenCommand = new RelayCommand <ThirdPartyTool>((tool) => { StartThirdPartyTool(tool); }); UpdateGamesCommand = new RelayCommand <object>((a) => { #pragma warning disable CS4014 UpdateLibrary(AppSettings.DownloadMetadataOnImport, true); #pragma warning restore CS4014 }, (a) => GameAdditionAllowed, new KeyGesture(Key.F5)); OpenSteamFriendsCommand = new RelayCommand <object>((a) => { OpenSteamFriends(); }); ReportIssueCommand = new RelayCommand <object>((a) => { ReportIssue(); }); ShutdownCommand = new RelayCommand <object>((a) => { if (GlobalTaskHandler.IsActive) { if (Dialogs.ShowMessage( Resources.GetString("LOCBackgroundProgressCancelAskExit"), Resources.GetString("LOCCrashClosePlaynite"), MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } } ignoreCloseActions = true; ShutdownApp(); }, new KeyGesture(Key.Q, ModifierKeys.Alt)); ShowWindowCommand = new RelayCommand <object>((a) => { RestoreWindow(); }); WindowClosingCommand = new RelayCommand <CancelEventArgs>((args) => { OnClosing(args); }); FileDroppedCommand = new RelayCommand <DragEventArgs>((args) => { OnFileDropped(args); }); OpenAboutCommand = new RelayCommand <object>((a) => { OpenAboutWindow(new AboutViewModel(new AboutWindowFactory(), Dialogs, Resources, App.ServicesClient)); }, new KeyGesture(Key.F1)); OpenEmulatorsCommand = new RelayCommand <object>((a) => { ConfigureEmulators( new EmulatorsViewModel(Database, new EmulatorsWindowFactory(), Dialogs, Resources)); }, (a) => Database?.IsOpen == true, new KeyGesture(Key.T, ModifierKeys.Control)); OpenSoftwareToolsCommand = new RelayCommand <object>((a) => { ConfigureSoftwareTools(new ToolsConfigViewModel( Database, new ToolsConfigWindowFactory(), Dialogs, Resources)); }, (a) => Database?.IsOpen == true); AddCustomGameCommand = new RelayCommand <object>((a) => { AddCustomGame(new GameEditWindowFactory()); }, (a) => Database?.IsOpen == true, new KeyGesture(Key.Insert)); AddInstalledGamesCommand = new RelayCommand <object>((a) => { ImportInstalledGames( new InstalledGamesViewModel( new InstalledGamesWindowFactory(), Dialogs), null); }, (a) => Database?.IsOpen == true); AddEmulatedGamesCommand = new RelayCommand <object>((a) => { ImportEmulatedGames( new EmulatedGamesImportViewModel( Database, new EmulatedGameImportWindowFactory(), Dialogs, Resources)); }, (a) => Database?.IsOpen == true, new KeyGesture(Key.Q, ModifierKeys.Control)); AddWindowsStoreGamesCommand = new RelayCommand <object>((a) => { ImportWindowsStoreGames( new InstalledGamesViewModel( new InstalledGamesWindowFactory(), Dialogs)); }, (a) => Database?.IsOpen == true); OpenFullScreenCommand = new RelayCommand <object>((a) => { SwitchToFullscreenMode(); }, new KeyGesture(Key.F11)); OpenFullScreenFromControllerCommand = new RelayCommand <object>((a) => { if (AppSettings.GuideButtonOpensFullscreen) { SwitchToFullscreenMode(); } }, new KeyGesture(Key.F11)); ClearMessagesCommand = new RelayCommand <object>((a) => { ClearMessages(); }, (a) => PlayniteApi?.Notifications?.Count > 0); DownloadMetadataCommand = new RelayCommand <object>((a) => { DownloadMetadata(new MetadataDownloadViewModel(new MetadataDownloadWindowFactory())); }, (a) => GameAdditionAllowed, new KeyGesture(Key.D, ModifierKeys.Control)); ClearFiltersCommand = new RelayCommand <object>((a) => { ClearFilters(); }); CheckForUpdateCommand = new RelayCommand <object>((a) => { CheckForUpdate(); }); OpenDbFieldsManagerCommand = new RelayCommand <object>((a) => { ConfigureDatabaseFields( new DatabaseFieldsManagerViewModel( Database, new DatabaseFieldsManagerWindowFactory(), Dialogs, Resources)); }, (a) => GameAdditionAllowed, new KeyGesture(Key.W, ModifierKeys.Control)); OpenLibraryIntegrationsConfigCommand = new RelayCommand <object>((a) => { OpenIntegrationSettings( new LibraryIntegrationsViewModel( new LibraryIntegrationsWindowFactory(), Dialogs, Resources, Extensions)); }); UpdateLibraryCommand = new RelayCommand <LibraryPlugin>((a) => { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed UpdateLibrary(a); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }, (a) => GameAdditionAllowed); RemoveGameSelectionCommand = new RelayCommand <object>((a) => { RemoveGameSelection(); }); InvokeExtensionFunctionCommand = new RelayCommand <ExtensionFunction>((f) => { if (!Extensions.InvokeExtension(f, out var error)) { Dialogs.ShowMessage( error.Message, Resources.GetString("LOCScriptError"), MessageBoxButton.OK, MessageBoxImage.Error); } }); ReloadScriptsCommand = new RelayCommand <object>((f) => { Extensions.LoadScripts(PlayniteApi, AppSettings.DisabledPlugins, App.CmdLine.SafeStartup, AppSettings.DevelExtenions.Where(a => a.Selected == true).Select(a => a.Item).ToList()); }, new KeyGesture(Key.F12)); ShowGameSideBarCommand = new RelayCommand <GamesCollectionViewEntry>((f) => { AppSettings.GridViewSideBarVisible = true; SelectedGame = f; }); CloseGameSideBarCommand = new RelayCommand <object>((f) => { AppSettings.GridViewSideBarVisible = false; }); OpenSettingsCommand = new RelayCommand <object>((a) => { OpenSettings( new SettingsViewModel(Database, AppSettings, new SettingsWindowFactory(), Dialogs, Resources, Extensions, App)); }, new KeyGesture(Key.F4)); OpenAddonsCommand = new RelayCommand <object>((a) => { new AddonsViewModel( new AddonsWindowFactory(), PlayniteApi, Dialogs, Resources, App.ServicesClient, Extensions, AppSettings, App).OpenView(); }, new KeyGesture(Key.F9)); StartGameCommand = new RelayCommand <Game>((game) => { if (game != null) { GamesEditor.PlayGame(game); } else if (SelectedGame != null) { GamesEditor.PlayGame(SelectedGame.Game); } }); StartSoftwareToolCommand = new RelayCommand <AppSoftware>((app) => { StartSoftwareTool(app); }); InstallGameCommand = new RelayCommand <Game>((game) => { if (game != null) { GamesEditor.InstallGame(game); } else if (SelectedGame != null) { GamesEditor.InstallGame(SelectedGame.Game); } }); UninstallGameCommand = new RelayCommand <Game>((game) => { if (game != null) { GamesEditor.UnInstallGame(game); } else if (SelectedGame != null) { GamesEditor.UnInstallGame(SelectedGame.Game); } }); EditSelectedGamesCommand = new RelayCommand <object>((a) => { if (SelectedGames?.Count() > 1) { ignoreSelectionChanges = true; try { GamesEditor.EditGames(SelectedGames.Select(g => g.Game).ToList()); } finally { ignoreSelectionChanges = false; } } else { GamesEditor.EditGame(SelectedGame.Game); } }, (a) => SelectedGame != null, new KeyGesture(Key.F3)); StartSelectedGameCommand = new RelayCommand <object>((a) => { GamesEditor.PlayGame(SelectedGame.Game); }, (a) => SelectedGames?.Count() == 1, new KeyGesture(Key.Enter)); RemoveSelectedGamesCommand = new RelayCommand <object>((a) => { if (SelectedGames?.Count() > 1) { GamesEditor.RemoveGames(SelectedGames.Select(g => g.Game).Distinct().ToList()); } else { GamesEditor.RemoveGame(SelectedGame.Game); } }, (a) => SelectedGame != null, new KeyGesture(Key.Delete)); EditGameCommand = new RelayCommand <Game>((a) => { if (GamesEditor.EditGame(a) == true) { SelectedGame = GamesView.Items.FirstOrDefault(g => g.Id == a.Id); } }); EditGamesCommand = new RelayCommand <IEnumerable <Game> >((a) => { ignoreSelectionChanges = true; try { GamesEditor.EditGames(a.ToList()); } finally { ignoreSelectionChanges = false; } }); OpenGameLocationCommand = new RelayCommand <Game>((a) => { GamesEditor.OpenGameLocation(a); }); CreateDesktopShortcutCommand = new RelayCommand <Game>((a) => { GamesEditor.CreateDesktopShortcut(a); }); CreateDesktopShortcutsCommand = new RelayCommand <List <Game> >((a) => { GamesEditor.CreateDesktopShortcut(a); }); OpenManualCommand = new RelayCommand <Game>((a) => { GamesEditor.OpenManual(a); }); ToggleFavoritesCommand = new RelayCommand <Game>((a) => { GamesEditor.ToggleFavoriteGame(a); }); ToggleVisibilityCommand = new RelayCommand <Game>((a) => { GamesEditor.ToggleHideGame(a); }); AssignGameCategoryCommand = new RelayCommand <Game>((a) => { if (GamesEditor.SetGameCategories(a) == true) { SelectedGame = GamesView.Items.FirstOrDefault(g => g.Id == a.Id); } }); AssignGamesCategoryCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.SetGamesCategories(a.ToList()); }); SetGameCompletionStatusCommand = new RelayCommand <Tuple <Game, CompletionStatus> >((a) => { GamesEditor.SetCompletionStatus(a.Item1, a.Item2); }); SetGamesCompletionStatusCommand = new RelayCommand <Tuple <IEnumerable <Game>, CompletionStatus> >((a) => { GamesEditor.SetCompletionStatus(a.Item1.ToList(), a.Item2); }); RemoveGameCommand = new RelayCommand <Game>((a) => { GamesEditor.RemoveGame(a); }, new KeyGesture(Key.Delete)); RemoveGamesCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.RemoveGames(a.Distinct().ToList()); }, new KeyGesture(Key.Delete)); SetAsFavoritesCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.SetFavoriteGames(a.ToList(), true); }); RemoveAsFavoritesCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.SetFavoriteGames(a.ToList(), false); }); SetAsHiddensCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.SetHideGames(a.ToList(), true); }); RemoveAsHiddensCommand = new RelayCommand <IEnumerable <Game> >((a) => { GamesEditor.SetHideGames(a.ToList(), false); }); SelectRandomGameCommand = new RelayCommand <object>((a) => { PlayRandomGame(); }, (a) => Database?.IsOpen == true, new KeyGesture(Key.F6)); RestartInSafeMode = new RelayCommand <object>((a) => { RestartAppSafe(); }); SelectSidebarViewCommand = new RelayCommand <SidebarWrapperItem>((a) => { a.Command.Execute(null); }); SwitchDetailsViewCommand = new RelayCommand <object>((_) => AppSettings.ViewSettings.GamesViewType = ViewType.Details); SwitchGridViewCommand = new RelayCommand <object>((_) => AppSettings.ViewSettings.GamesViewType = ViewType.Grid); SwitchListViewCommand = new RelayCommand <object>((_) => AppSettings.ViewSettings.GamesViewType = ViewType.List); UpdateEmulationDirCommand = new RelayCommand <GameScannerConfig>((a) => { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed UpdateEmulationLibrary(a); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }, (a) => GameAdditionAllowed); UpdateEmulationDirsCommand = new RelayCommand(() => { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed UpdateEmulationLibrary(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }, () => GameAdditionAllowed); }
private void InitializeCommands() { WindowClosingCommand = new RelayCommand <CancelEventArgs>((a) => { if (!ignoreCloseActions) { Dispose(); App.Quit(); } }); WindowGotFocusCommand = new RelayCommand <EventArgs>((a) => { if (Keyboard.FocusedElement == Window.Window && isInitialized && !ignoreCloseActions) { Logger.Warn("Lost keyboard focus from known controls, trying to focus something."); foreach (var child in ElementTreeHelper.FindVisualChildren <FrameworkElement>(Window.Window)) { if (child.Focusable && child.IsVisible) { Logger.Debug($"Focusing {child}"); child.Focus(); return; } } } }); ToggleFullscreenCommand = new RelayCommand <object>((a) => { ToggleFullscreen(); }); OpenGameMenuCommand = new RelayCommand <object>((a) => { OpenGameMenu(); }, (a) => SelectedGameDetails != null); ToggleGameDetailsCommand = new RelayCommand <object>((a) => { GameDetailsVisible = !GameDetailsVisible; GameListVisible = !GameListVisible; if (!GameDetailsVisible) { GameDetailsFocused = false; GameListFocused = true; } else { GameDetailsFocused = true; GameListFocused = false; } }, (a) => SelectedGame != null); LoadSubFilterCommand = new RelayCommand <GameField>((gameField) => { switch (gameField) { case GameField.PluginId: OpenSubFilter("LOCLibrary", nameof(DatabaseFilter.Libraries), nameof(FilterSettings.Library), true); break; case GameField.Categories: OpenSubFilter("LOCCategoryLabel", nameof(DatabaseFilter.Categories), nameof(FilterSettings.Category), true); break; case GameField.Platforms: OpenSubFilter("LOCPlatformTitle", nameof(DatabaseFilter.Platforms), nameof(FilterSettings.Platform), true); break; case GameField.CompletionStatus: OpenSubFilter("LOCCompletionStatus", nameof(DatabaseFilter.CompletionStatuses), nameof(FilterSettings.CompletionStatuses)); break; case GameField.ReleaseYear: OpenSubStringFilter("LOCGameReleaseYearTitle", nameof(DatabaseFilter.ReleaseYears), nameof(FilterSettings.ReleaseYear)); break; case GameField.Genres: OpenSubFilter("LOCGenreLabel", nameof(DatabaseFilter.Genres), nameof(FilterSettings.Genre)); break; case GameField.Developers: OpenSubFilter("LOCDeveloperLabel", nameof(DatabaseFilter.Developers), nameof(FilterSettings.Developer)); break; case GameField.Publishers: OpenSubFilter("LOCPublisherLabel", nameof(DatabaseFilter.Publishers), nameof(FilterSettings.Publisher)); break; case GameField.Features: OpenSubFilter("LOCFeatureLabel", nameof(DatabaseFilter.Features), nameof(FilterSettings.Feature)); break; case GameField.Tags: OpenSubFilter("LOCTagLabel", nameof(DatabaseFilter.Tags), nameof(FilterSettings.Tag)); break; case GameField.Playtime: OpenSubEnumFilter("LOCTimePlayed", typeof(PlaytimeCategory), nameof(FilterSettings.PlayTime)); break; case GameField.Series: OpenSubFilter("LOCSeriesLabel", nameof(DatabaseFilter.Series), nameof(FilterSettings.Series)); break; case GameField.Regions: OpenSubFilter("LOCRegionLabel", nameof(DatabaseFilter.Regions), nameof(FilterSettings.Region)); break; case GameField.Source: OpenSubFilter("LOCSourceLabel", nameof(DatabaseFilter.Sources), nameof(FilterSettings.Source)); break; case GameField.AgeRatings: OpenSubFilter("LOCAgeRatingLabel", nameof(DatabaseFilter.AgeRatings), nameof(FilterSettings.AgeRating)); break; case GameField.UserScore: OpenSubEnumFilter("LOCUserScore", typeof(ScoreGroup), nameof(FilterSettings.UserScore)); break; case GameField.CommunityScore: OpenSubEnumFilter("LOCCommunityScore", typeof(ScoreGroup), nameof(FilterSettings.CommunityScore)); break; case GameField.CriticScore: OpenSubEnumFilter("LOCCriticScore", typeof(ScoreGroup), nameof(FilterSettings.CriticScore)); break; case GameField.LastActivity: OpenSubEnumFilter("LOCGameLastActivityTitle", typeof(PastTimeSegment), nameof(FilterSettings.LastActivity)); break; case GameField.Added: OpenSubEnumFilter("LOCAddedLabel", typeof(PastTimeSegment), nameof(FilterSettings.Added)); break; case GameField.Modified: OpenSubEnumFilter("LOCModifiedLabel", typeof(PastTimeSegment), nameof(FilterSettings.Modified)); break; } }); OpenAdditionalFiltersCommand = new RelayCommand <object>((a) => { FilterPanelVisible = false; FilterAdditionalPanelVisible = true; }); CloseAdditionalFiltersCommand = new RelayCommand <object>((a) => { FilterAdditionalPanelVisible = false; FilterPanelVisible = true; }); CloseAdditionalFilterCommand = new RelayCommand <object>((a) => { ((IDisposable)SubFilterControl).Dispose(); SubFilterControl = null; FilterAdditionalPanelVisible = true; }); CloseSubFilterCommand = new RelayCommand <object>((a) => { if (SubFilterControl != null) { FilterPanelVisible = true; ((IDisposable)SubFilterControl).Dispose(); SubFilterControl = null; } }); ToggleFiltersCommand = new RelayCommand <object>((a) => { if (SubFilterVisible) { ((IDisposable)SubFilterControl).Dispose(); SubFilterControl = null; FilterPanelVisible = false; } else if (FilterAdditionalPanelVisible) { FilterAdditionalPanelVisible = false; } else { FilterPanelVisible = !FilterPanelVisible; } if (FilterPanelVisible) { GameListFocused = false; } else { GameListFocused = true; } }); ClearFiltersCommand = new RelayCommand <object>((a) => { AppSettings.Fullscreen.FilterSettings.ClearFilters(); ActiveFilterPreset = null; }); ActivateSelectedCommand = new RelayCommand <object>((a) => { if (SelectedGame?.IsInstalled == true) { GamesEditor.PlayGame(SelectedGame.Game); } else if (SelectedGame?.IsInstalled == false) { GamesEditor.InstallGame(SelectedGame.Game); } }, (a) => Database?.IsOpen == true); OpenSearchCommand = new RelayCommand <object>((a) => { GameListFocused = false; var oldSearch = AppSettings.Fullscreen.FilterSettings.Name; var input = new Windows.TextInputWindow(); input.PropertyChanged += SearchText_PropertyChanged; var res = input.ShowInput(WindowManager.CurrentWindow, "", "", AppSettings.Fullscreen.FilterSettings.Name); input.PropertyChanged -= SearchText_PropertyChanged; if (res.Result != true) { AppSettings.Fullscreen.FilterSettings.Name = oldSearch; } GameListFocused = true; }); NextFilterViewCommand = new RelayCommand <object>((a) => { var presets = SortedFilterFullscreenPresets; if (!presets.HasItems()) { return; } if (ActiveFilterPreset == null) { ActiveFilterPreset = presets[0]; } else { var curIndex = presets.IndexOf(ActiveFilterPreset); if (curIndex < (presets.Count - 1)) { ActiveFilterPreset = presets[curIndex + 1]; } } }, (a) => Database?.IsOpen == true); PrevFilterViewCommand = new RelayCommand <object>((a) => { var presets = SortedFilterFullscreenPresets; if (!presets.HasItems()) { return; } if (ActiveFilterPreset == null) { ActiveFilterPreset = presets[0]; } else { var curIndex = presets.IndexOf(ActiveFilterPreset); if (curIndex > 0) { ActiveFilterPreset = presets[curIndex - 1]; } } }, (a) => Database?.IsOpen == true); SelectPrevGameCommand = new RelayCommand <object>((a) => { var currIndex = GamesView.CollectionView.IndexOf(SelectedGame); var prevIndex = currIndex - 1; if (prevIndex >= 0) { SelectedGame = GamesView.CollectionView.GetItemAt(prevIndex) as GamesCollectionViewEntry; } }, (a) => Database?.IsOpen == true); SelectNextGameCommand = new RelayCommand <object>((a) => { var currIndex = GamesView.CollectionView.IndexOf(SelectedGame); var nextIndex = currIndex + 1; if (nextIndex < GamesView.CollectionView.Count) { SelectedGame = GamesView.CollectionView.GetItemAt(nextIndex) as GamesCollectionViewEntry; } }, (a) => Database?.IsOpen == true); FileDroppedCommand = new RelayCommand <DragEventArgs>((args) => { OnFileDropped(args); }); OpenMainMenuCommand = new RelayCommand <object>((_) => OpenMainMenu()); OpenNotificationsMenuCommand = new RelayCommand <object>((_) => OpenNotificationsMenu()); CloseGameStatusCommand = new RelayCommand <object>((_) => { GameStatusVisible = false; GameListFocused = true; }); SwitchToDesktopCommand = new RelayCommand(() => SwitchToDesktopMode()); }