private void PART_LveGames_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender == null) { return; } ListBox listBox = (ListBox)sender; LveGame lveGame = (LveGame)listBox.SelectedItem; if (lveGame == null) { return; } Task.Run(() => { GameScreenshots gameScreenshots = PluginDatabase.Get(lveGame.Id, true); List <Screenshot> Screenshots = gameScreenshots.Items; Screenshots.Sort((x, y) => y.Modifed.CompareTo(x.Modifed)); this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new ThreadStart(delegate { ((SsvScreenshotsManagerData)DataContext).Screenshots = Screenshots.ToObservable(); })); return(true); }); }
public override async Task Initialize() { Messenger.Publish(new ProgressBarActivator(this, true)); var fullGameModel = await _gameService.GetFullGameModel(GameModel.Id); Description = fullGameModel.Description; ReleaseDate = fullGameModel.ReleaseDate.HasValue ? fullGameModel.ReleaseDate.Value.ToShortDateString() : string.Empty; Title = fullGameModel.Title; UserHasGameInVault = fullGameModel.UserHasGameInVault; UserHasGameOnWishList = fullGameModel.UserHasGameOnWishList; GameCategoryText = GameModel.Category.ToString(); GeneralImage = BitmapFactory.DecodeByteArray(fullGameModel.GeneralImage.ToArray(), 0, fullGameModel.GeneralImage.Count); VideoUrl = await _gameService.GetVideoUrlForGame(GameModel.Id); Messenger.Publish(new OpenVideoCardView(this)); var screenshotList = await _gameService.GetScreenShotsForGame(GameModel.Id); foreach (var screenshot in screenshotList) { GameScreenshots.Add(new GameScreenshotRowModel(screenshot.ImageContent)); } ShouldShowGameScreenshots = true; ShouldShowGameVideo = false; Messenger.Publish(new ProgressBarActivator(this, false)); }
public SsvScreenshotsView(Game GameSelected) { InitializeComponent(); gameScreenshots = PluginDatabase.Get(GameSelected); var Items = gameScreenshots.Items; Items.Sort((x, y) => y.Modifed.CompareTo(x.Modifed)); PART_ListScreenshots.ItemsSource = Items; SetInfos(); }
// To add new game menu items override GetGameMenuItems public override IEnumerable <GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs args) { Game GameMenu = args.Games.First(); List <Guid> Ids = args.Games.Select(x => x.Id).ToList(); GameScreenshots gameScreenshots = PluginDatabase.Get(GameMenu); List <GameMenuItem> gameMenuItems = new List <GameMenuItem>(); if (gameScreenshots.HasData) { gameMenuItems.Add(new GameMenuItem { // Delete & download localizations data for the selected game MenuSection = resources.GetString("LOCSsv"), Description = resources.GetString("LOCSsvViewScreenshots"), Action = (gameMenuItem) => { WindowOptions windowOptions = new WindowOptions { ShowMinimizeButton = false, ShowMaximizeButton = true, ShowCloseButton = true }; var ViewExtension = new SsvScreenshotsView(PluginDatabase.GameContext); Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCSsvTitle"), ViewExtension, windowOptions); windowExtension.ResizeMode = ResizeMode.CanResize; windowExtension.ShowDialog(); } }); if (gameScreenshots.ScreenshotsFolders != null && gameScreenshots.ScreenshotsFolders.Count != 0 && gameScreenshots.FoldersExist) { gameMenuItems.Add(new GameMenuItem { // Open directory MenuSection = resources.GetString("LOCSsv"), Description = resources.GetString("LOCSsvOpenScreenshotsDirectory"), Action = (gameMenuItem) => { foreach (string Folder in gameScreenshots.ScreenshotsFolders) { Process.Start(Folder); } } }); } if (gameScreenshots.Items.Count > 0 && PluginDatabase.PluginSettings.Settings.EnableFolderToSave) { gameMenuItems.Add(new GameMenuItem { MenuSection = resources.GetString("LOCSsv"), Description = resources.GetString("LOCSsvMoveToSave"), Action = (gameMenuItem) => { if (Ids.Count == 1) { PluginDatabase.MoveToFolderToSave(GameMenu); } else { PluginDatabase.MoveToFolderToSave(Ids); } } }); } if (gameScreenshots.Items.Count > 0) { gameMenuItems.Add(new GameMenuItem { MenuSection = resources.GetString("LOCSsv"), Description = resources.GetString("LOCSsvConvertToJPG"), Action = (gameMenuItem) => { GlobalProgressOptions globalProgressOptions = new GlobalProgressOptions( $"{PluginDatabase.PluginName} - {resources.GetString("LOCCommonConverting")}", true ); globalProgressOptions.IsIndeterminate = Ids.Count == 1; PlayniteApi.Dialogs.ActivateGlobalProgress((activateGlobalProgress) => { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string CancelText = string.Empty; if (Ids.Count > 1) { activateGlobalProgress.ProgressMaxValue = Ids.Count; } try { Ids.ForEach(y => { GameScreenshots data = PluginDatabase.Get(y); if (data.HasData) { bool HasConvert = false; data.Items.ForEach(x => { if (activateGlobalProgress.CancelToken.IsCancellationRequested) { CancelText = " canceled"; return; } if (!x.IsVideo) { string oldFile = x.FileName; string newFile = ImageTools.ConvertToJpg(oldFile, PluginDatabase.PluginSettings.Settings.JpgQuality); if (!newFile.IsNullOrEmpty()) { DateTime dt = File.GetLastWriteTime(oldFile); File.SetLastWriteTime(newFile, dt); FileSystem.DeleteFileSafe(oldFile); HasConvert = true; } } }); if (HasConvert) { GameSettings gameSettings = PluginDatabase.GetGameSettings(y); if (gameSettings != null) { PluginDatabase.SetDataFromSettings(gameSettings); } } if (activateGlobalProgress.CancelToken.IsCancellationRequested) { CancelText = " canceled"; return; } if (Ids.Count > 1) { activateGlobalProgress.CurrentProgressValue++; } } }); } catch (Exception ex) { Common.LogError(ex, false, true, PluginDatabase.PluginName); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; logger.Info($"Task RefreshData(){CancelText} - {string.Format("{0:00}:{1:00}.{2:00}", ts.Minutes, ts.Seconds, ts.Milliseconds / 10)} for {activateGlobalProgress.CurrentProgressValue}/{Ids.Count} items"); }, globalProgressOptions); } }); } gameMenuItems.Add(new GameMenuItem { MenuSection = resources.GetString("LOCSsv"), Description = "-" }); } gameMenuItems.Add(new GameMenuItem { // Refresh data MenuSection = resources.GetString("LOCSsv"), Description = resources.GetString("LOCCommonRefreshGameData"), Action = (gameMenuItem) => { if (Ids.Count == 1) { PluginDatabase.RefreshData(GameMenu); } else { PluginDatabase.RefreshData(Ids); } } }); #if DEBUG gameMenuItems.Add(new GameMenuItem { MenuSection = resources.GetString("LOCSsv"), Description = "-" }); gameMenuItems.Add(new GameMenuItem { MenuSection = resources.GetString("LOCSsv"), Description = "Test", Action = (mainMenuItem) => { } }); #endif return(gameMenuItems); }