Example #1
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     if (IsFullscreen)
     {
         return(Invoke(() => PlayniteMessageBoxFullscreen.Show(messageBoxText, caption, button, icon, defaultResult, options)));
     }
     else
     {
         return(Invoke(() => PlayniteMessageBox.Show(messageBoxText, caption, button, icon, defaultResult, options)));
     }
 }
Example #2
0
 private void Link_RequestNavigate(object sender, RequestNavigateEventArgs e)
 {
     try
     {
         Process.Start(e.Uri.AbsoluteUri);
     }
     catch
     {
         PlayniteMessageBox.Show("Cannot open link. URL is not in valid Format.\nURL: " + e.Uri.ToString(), "Invalid URL", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button)
 {
     if (IsFullscreen)
     {
         return(Invoke(() => PlayniteMessageBoxFullscreen.Show(messageBoxText, caption, button)));
     }
     else
     {
         return(Invoke(() => PlayniteMessageBox.Show(messageBoxText, caption, button)));
     }
 }
 public MessageBoxResult ShowMessage(string messageBoxText)
 {
     if (IsFullscreen)
     {
         return(Invoke(() => PlayniteMessageBoxFullscreen.Show(messageBoxText)));
     }
     else
     {
         return(Invoke(() => PlayniteMessageBox.Show(messageBoxText)));
     }
 }
Example #5
0
        public void PlayGame(IGame game)
        {
            // Set parent for message boxes in this method
            // because this method can be invoked from tray icon which otherwise bugs the dialog
            if (database.GamesCollection.FindOne(a => a.ProviderId == game.ProviderId) == null)
            {
                PlayniteMessageBox.Show(
                    Application.Current.MainWindow,
                    string.Format(resources.FindString("GameStartErrorNoGame"), game.Name),
                    resources.FindString("GameError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
                UpdateJumpList();
                return;
            }

            try
            {
                if (game.IsInstalled)
                {
                    game.PlayGame(database.EmulatorsCollection.FindAll().ToList());
                }
                else
                {
                    game.InstallGame();
                }

                database.UpdateGameInDatabase(game);
            }
            catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                logger.Error(exc, "Cannot start game: ");
                PlayniteMessageBox.Show(
                    Application.Current.MainWindow,
                    string.Format(resources.FindString("GameStartError"), exc.Message),
                    resources.FindString("GameError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                UpdateJumpList();
            }
            catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                logger.Error(exc, "Failed to set jump list data: ");
            }

            if (Settings.Instance.MinimizeAfterLaunch)
            {
                Application.Current.MainWindow.WindowState = WindowState.Minimized;
            }
        }
Example #6
0
 public void UnInstallGame(IGame game)
 {
     try
     {
         game.UninstallGame();
         GameDatabase.Instance.UpdateGameInDatabase(game);
     }
     catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
     {
         logger.Error(exc, "Cannot un-install game: ");
         PlayniteMessageBox.Show("Cannot un-install game: " + exc.Message, "Game Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #7
0
        public void RemoveGame(IGame game)
        {
            if (PlayniteMessageBox.Show(
                    resources.FindString("GameRemoveAskMessage"),
                    resources.FindString("GameRemoveAskTitle"),
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            database.DeleteGame(game);
        }
Example #8
0
        public void RemoveGames(List <IGame> games)
        {
            if (PlayniteMessageBox.Show(
                    string.Format(resources.FindString("GamesRemoveAskMessage"), games.Count()),
                    resources.FindString("GameRemoveAskTitle"),
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            database.DeleteGames(games);
        }
Example #9
0
 public void OpenGameLocation(IGame game)
 {
     try
     {
         Process.Start(game.InstallDirectory);
     }
     catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
     {
         PlayniteMessageBox.Show(
             string.Format(resources.FindString("GameOpenLocationError"), exc.Message),
             resources.FindString("GameError"),
             MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #10
0
 public void ActivateAction(IGame game, GameTask action)
 {
     try
     {
         GameHandler.ActivateTask(action, game as Game, database.EmulatorsCollection.FindAll().ToList());
     }
     catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
     {
         PlayniteMessageBox.Show(
             string.Format(resources.FindString("GameStartActionError"), exc.Message),
             resources.FindString("GameError"),
             MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #11
0
 public void UnInstallGame(IGame game)
 {
     try
     {
         game.UninstallGame();
         database.UpdateGameInDatabase(game);
     }
     catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
     {
         logger.Error(exc, "Cannot un-install game: ");
         PlayniteMessageBox.Show(
             string.Format(resources.FindString("GameUninstallError"), exc.Message),
             resources.FindString("GameError"),
             MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #12
0
        private void DiagButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog()
            {
                Filter = "ZIP Archive (*.zip)|*.zip"
            };

            if (dialog.ShowDialog(this) == true)
            {
                try
                {
                    Diagnostic.CreateDiagPackage(dialog.FileName);
                    PlayniteMessageBox.Show("Diagnostics package created successfully.");
                }
                catch (Exception exc)
                {
                    logger.Error(exc, "Faild to created diagnostics package.");
                    PlayniteMessageBox.Show("Failed to create diagnostics package.");
                }
            }
        }
        private void DoMetadataLookup(MetadataProvider provider)
        {
            if (string.IsNullOrEmpty(TextName.Text))
            {
                PlayniteMessageBox.Show("Game name cannot be empty.", "", MessageBoxButton.OK);
                return;
            }

            var window = new MetadataLookupWindow()
            {
                DataContext           = Game,
                ShowInTaskbar         = false,
                Owner                 = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            if (window.LookupData(TextName.Text, provider) == true)
            {
                PreviewGameData(window.MetadataData);
                CheckBoxesVisible = true;
            }
        }
Example #14
0
        public void CreateShortcut(IGame game)
        {
            try
            {
                var    path = Environment.ExpandEnvironmentVariables(Path.Combine("%userprofile%", "Desktop", FileSystem.GetSafeFilename(game.Name) + ".lnk"));
                string icon = string.Empty;

                if (!string.IsNullOrEmpty(game.Icon) && Path.GetExtension(game.Icon) == ".ico")
                {
                    FileSystem.CreateFolder(Path.Combine(Paths.DataCachePath, "icons"));
                    icon = Path.Combine(Paths.DataCachePath, "icons", game.Id + ".ico");
                    database.SaveFile(game.Icon, icon);
                }
                else if (game.PlayTask?.Type == GameTaskType.File)
                {
                    if (Path.IsPathRooted(game.ResolveVariables(game.PlayTask.Path)))
                    {
                        icon = game.ResolveVariables(game.PlayTask.Path);
                    }
                    else
                    {
                        icon = Path.Combine(game.ResolveVariables(game.PlayTask.WorkingDir), game.ResolveVariables(game.PlayTask.Path));
                    }
                }

                Programs.CreateShortcut(Paths.ExecutablePath, "-command launch:" + game.Id, icon, path);
            }
            catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors)
            {
                logger.Error(exc, "Failed to create shortcut: ");
                PlayniteMessageBox.Show(
                    string.Format(resources.FindString("GameShortcutError"), exc.Message),
                    resources.FindString("GameError"),
                    MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #15
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button)
 {
     return(Invoke(() => PlayniteMessageBox.Show(messageBoxText, caption, button)));
 }
        private async void LoadGames(bool downloadLibUpdates)
        {
            if (GamesLoaderHandler.ProgressTask != null && GamesLoaderHandler.ProgressTask.Status == TaskStatus.Running)
            {
                GamesLoaderHandler.CancelToken.Cancel();
                await GamesLoaderHandler.ProgressTask;
            }

            GameAdditionAllowed = false;

            try
            {
                if (string.IsNullOrEmpty(Config.DatabasePath))
                {
                    return;
                }

                var database = GameDatabase.Instance;

                try
                {
                    database.OpenDatabase(Config.DatabasePath);
                }
                catch (Exception exc)
                {
                    GameAdditionAllowed = false;
                    PlayniteMessageBox.Show("Failed to open library database: " + exc.Message, "Database Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                LiteDBImageToImageConverter.ClearCache();
                GamesView?.Dispose();
                GamesView = new GamesCollectionView(database, Config);
                BindingOperations.EnableCollectionSynchronization(GamesView.Items, gamesLock);

                try
                {
                    GamesEditor.Instance.UpdateJumpList();
                }
                catch (Exception exc)
                {
                    logger.Error(exc, "Failed to set update JumpList data: ");
                }

                ListGamesView.ItemsSource   = GamesView.CollectionView;
                ImagesGamesView.ItemsSource = GamesView.CollectionView;
                GridGamesView.ItemsSource   = GamesView.CollectionView;

                if (downloadLibUpdates)
                {
                    GamesLoaderHandler.CancelToken  = new CancellationTokenSource();
                    GamesLoaderHandler.ProgressTask = Task.Factory.StartNew(() =>
                    {
                        ProgressControl.Visible       = Visibility.Visible;
                        ProgressControl.ProgressValue = 0;
                        ProgressControl.Text          = "Importing installed games...";

                        try
                        {
                            if (Config.UplaySettings.IntegrationEnabled)
                            {
                                database.UpdateInstalledGames(Provider.Uplay);
                                NotificationsWin.RemoveMessage(NotificationCodes.UplayInstalledImportError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to import installed Uplay games.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.UplayInstalledImportError, "Failed to import installed Uplay games:" + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        try
                        {
                            if (Config.GOGSettings.IntegrationEnabled)
                            {
                                database.UpdateInstalledGames(Provider.GOG);
                                NotificationsWin.RemoveMessage(NotificationCodes.GOGLInstalledImportError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to import installed GOG games.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.GOGLInstalledImportError, "Failed to import installed GOG games:" + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        try
                        {
                            if (Config.SteamSettings.IntegrationEnabled)
                            {
                                database.UpdateInstalledGames(Provider.Steam);
                                NotificationsWin.RemoveMessage(NotificationCodes.SteamInstalledImportError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to import installed Steam games.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.SteamInstalledImportError, "Failed to import installed Steam games: " + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        try
                        {
                            if (Config.OriginSettings.IntegrationEnabled)
                            {
                                database.UpdateInstalledGames(Provider.Origin);
                                NotificationsWin.RemoveMessage(NotificationCodes.OriginInstalledImportError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to import installed Origin games.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.OriginInstalledImportError, "Failed to import installed Origin games: " + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        ProgressControl.Text = "Downloading GOG library updates...";

                        try
                        {
                            if (Config.GOGSettings.IntegrationEnabled && Config.GOGSettings.LibraryDownloadEnabled)
                            {
                                database.UpdateOwnedGames(Provider.GOG);
                                NotificationsWin.RemoveMessage(NotificationCodes.GOGLibDownloadError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to download GOG library updates.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.GOGLibDownloadError, "Failed to download GOG library updates: " + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        ProgressControl.Text = "Downloading Steam library updates...";

                        try
                        {
                            if (Config.SteamSettings.IntegrationEnabled && Config.SteamSettings.LibraryDownloadEnabled)
                            {
                                if (config.SteamSettings.IdSource == SteamIdSource.Name)
                                {
                                    database.SteamUserName = Config.SteamSettings.AccountName;
                                }
                                else
                                {
                                    database.SteamUserName = Config.SteamSettings.AccountId.ToString();
                                }

                                database.UpdateOwnedGames(Provider.Steam);
                                NotificationsWin.RemoveMessage(NotificationCodes.SteamLibDownloadError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to download Steam library updates.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.SteamLibDownloadError, "Failed to download Steam library updates: " + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        if (importSteamCatWizard && importSteamCatWizardId != 0)
                        {
                            ProgressControl.Text = "Importing Steam categories...";

                            try
                            {
                                var steamLib = new SteamLibrary();
                                GameDatabase.Instance.ImportCategories(steamLib.GetCategorizedGames(importSteamCatWizardId));
                            }
                            catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                            {
                                logger.Error(e, "Failed to import Steam categories.");
                                NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.SteamLibDownloadError, "Failed to import Steam categories: " + e.Message, NotificationType.Error, () =>
                                {
                                }));
                            }
                        }

                        ProgressControl.Text = "Downloading Origin library updates...";

                        try
                        {
                            if (Config.OriginSettings.IntegrationEnabled && Config.OriginSettings.LibraryDownloadEnabled)
                            {
                                database.UpdateOwnedGames(Provider.Origin);
                                NotificationsWin.RemoveMessage(NotificationCodes.OriginLibDownloadError);
                            }
                        }
                        catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors)
                        {
                            logger.Error(e, "Failed to download Origin library updates.");
                            NotificationsWin.AddMessage(new NotificationMessage(NotificationCodes.OriginLibDownloadError, "Failed to download Origin library updates: " + e.Message, NotificationType.Error, () =>
                            {
                            }));
                        }

                        ProgressControl.Text        = "Downloading images and game details...";
                        ProgressControl.ProgressMin = 0;

                        var gamesCount = 0;
                        gamesCount     = database.GamesCollection.Count(a => a.Provider != Provider.Custom && !a.IsProviderDataUpdated);
                        if (gamesCount > 0)
                        {
                            gamesCount -= 1;
                        }

                        ProgressControl.ProgressMax = gamesCount;

                        var tasks = new List <Task>
                        {
                            // Steam metada download thread
                            Task.Factory.StartNew(() =>
                            {
                                DownloadMetadata(database, Provider.Steam, ProgressControl, GamesLoaderHandler.CancelToken.Token);
                            }),

                            // Origin metada download thread
                            Task.Factory.StartNew(() =>
                            {
                                DownloadMetadata(database, Provider.Origin, ProgressControl, GamesLoaderHandler.CancelToken.Token);
                            }),

                            // GOG metada download thread
                            Task.Factory.StartNew(() =>
                            {
                                DownloadMetadata(database, Provider.GOG, ProgressControl, GamesLoaderHandler.CancelToken.Token);
                            }),

                            // Uplay metada download thread
                            Task.Factory.StartNew(() =>
                            {
                                DownloadMetadata(database, Provider.Uplay, ProgressControl, GamesLoaderHandler.CancelToken.Token);
                            })
                        };

                        Task.WaitAll(tasks.ToArray());

                        ProgressControl.Text = "Library update finished";

                        Thread.Sleep(1500);
                        ProgressControl.Visible = Visibility.Collapsed;
                    });

                    await GamesLoaderHandler.ProgressTask;
                }
            }
            finally
            {
                GamesEditor.Instance.OnPropertyChanged("LastGames");
                GameAdditionAllowed = true;
            }
        }
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            if (Games == null)
            {
                if (string.IsNullOrWhiteSpace(TextName.Text))
                {
                    PlayniteMessageBox.Show("Name cannot be empty.", "Invalid game data", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            if (!string.IsNullOrEmpty(TextReleaseDate.Text) && !DateTime.TryParseExact(TextReleaseDate.Text, Playnite.Constants.DateUiFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
            {
                PlayniteMessageBox.Show("Release date in is not valid format.", "Invalid game data", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (IsNameBindingDirty && CheckName.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextName, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Name = Game.Name;
                    }
                }
            }

            if (IsGenreBindingDirty && CheckGenres.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextGenres, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Genres = Game.Genres;
                    }
                }
            }

            if (IsReleaseDateBindingDirty && CheckReleaseDate.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextReleaseDate, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.ReleaseDate = Game.ReleaseDate;
                    }
                }
            }

            if (IsDeveloperBindingDirty && CheckDeveloper.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextDeveloper, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Developers = Game.Developers;
                    }
                }
            }

            if (IsPublisherBindingDirty && CheckPublisher.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextPublisher, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Publishers = Game.Publishers;
                    }
                }
            }

            if (IsCategoriesBindingDirty && CheckCategories.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextCategories, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Categories = Game.Categories;
                    }
                }
            }

            if (IsDescriptionBindingDirty && CheckDescription.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(TextDescription, TextBox.TextProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.Description = Game.Description;
                    }
                }
            }

            if (IsInstallDirBindingDirty)
            {
                BindingOperations.GetBindingExpression(TextInstallDir, TextBox.TextProperty).UpdateSource();
            }

            if (IsIsoPathBindingDirty)
            {
                BindingOperations.GetBindingExpression(TextIso, TextBox.TextProperty).UpdateSource();
            }

            if (IsPlatformBindingDirty && CheckPlatform.IsChecked == true)
            {
                BindingOperations.GetBindingExpression(ComboPlatforms, ComboBox.SelectedValueProperty).UpdateSource();
                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        game.PlatformId = Game.PlatformId;
                    }
                }
            }

            if (IsIconBindingDirty && CheckIcon.IsChecked == true)
            {
                var iconPath = ((BitmapImage)ImageIcon.Source).UriSource.OriginalString;
                var fileName = Guid.NewGuid().ToString() + Path.GetExtension(iconPath);
                var iconId   = "images/custom/" + fileName;
                GameDatabase.Instance.AddImage(iconId, fileName, File.ReadAllBytes(iconPath));

                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        if (!string.IsNullOrEmpty(game.Icon))
                        {
                            GameDatabase.Instance.DeleteImageSafe(game.Icon, game);
                        }

                        game.Icon = iconId;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(Game.Icon))
                    {
                        GameDatabase.Instance.DeleteImageSafe(Game.Icon, Game);
                    }

                    Game.Icon = iconId;
                }

                if (Path.GetDirectoryName(iconPath) == Paths.TempPath)
                {
                    File.Delete(iconPath);
                }
            }

            if (IsImageBindingDirty && CheckImage.IsChecked == true)
            {
                var imagePath = ((BitmapImage)ImageImage.Source).UriSource.OriginalString;
                var fileName  = Guid.NewGuid().ToString() + Path.GetExtension(imagePath);
                var imageId   = "images/custom/" + fileName;
                GameDatabase.Instance.AddImage(imageId, fileName, File.ReadAllBytes(imagePath));

                if (Games != null)
                {
                    foreach (var game in Games)
                    {
                        if (!string.IsNullOrEmpty(game.Image))
                        {
                            GameDatabase.Instance.DeleteImageSafe(game.Image, game);
                        }

                        game.Image = imageId;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(Game.Image))
                    {
                        GameDatabase.Instance.DeleteImageSafe(Game.Image, Game);
                    }

                    Game.Image = imageId;
                }

                if (Path.GetDirectoryName(imagePath) == Paths.TempPath)
                {
                    File.Delete(imagePath);
                }
            }

            if (Games == null)
            {
                if (!Game.PlayTask.IsEqualJson(TempPlayTask))
                {
                    Game.PlayTask = TempPlayTask;
                }

                if (!Game.OtherTasks.IsEqualJson(TempOtherTasks))
                {
                    Game.OtherTasks = TempOtherTasks;
                }

                if (!Game.Links.IsEqualJson(TempLinks) && CheckLinks.IsChecked == true)
                {
                    Game.Links = TempLinks;
                }
            }

            if (Games != null)
            {
                foreach (var game in Games)
                {
                    GameDatabase.Instance.UpdateGameInDatabase(game);
                }
            }
            else
            {
                GameDatabase.Instance.UpdateGameInDatabase(Game);
            }

            DialogResult = true;
            Close();
        }
Example #18
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return(PlayniteMessageBox.Show(messageBoxText, caption, button, icon, defaultResult, options));
 }
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            if ((RadioLibrarySteam.IsChecked == true && RadioSteamLibName.IsChecked == true) && string.IsNullOrEmpty(TextSteamAccountName.Text))
            {
                PlayniteMessageBox.Show(FindResource("SettingsInvalidSteamAccountName") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (RadioLibrarySteam.IsChecked == true && RadioSteamLibAccount.IsChecked == true && ((ulong)ComboSteamAccount.SelectedValue) == 0)
            {
                PlayniteMessageBox.Show(FindResource("SettingsInvalidSteamAccountLibImport") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (!Paths.GetValidFilePath(TextDatabase.Text))
            {
                PlayniteMessageBox.Show(FindResource("SettingsInvalidDBLocation") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var databasePath = TextDatabase.GetBindingExpression(TextBox.TextProperty);

            if (databasePath.IsDirty)
            {
                databaseLocationChanged = true;
                databasePath.UpdateSource();
            }

            var steamEnabled = CheckSteamEnabled.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (steamEnabled.IsDirty)
            {
                providerIntegrationChanged = true;
                steamEnabled.UpdateSource();
            }

            var steamDownloadLib = RadioLibrarySteam.GetBindingExpression(RadioButton.IsCheckedProperty);

            if (steamDownloadLib.IsDirty)
            {
                providerIntegrationChanged = true;
                steamDownloadLib.UpdateSource();
            }

            RadioButton radioSteam    = RadioSteamLibName.IsChecked == true ? RadioSteamLibName : RadioSteamLibAccount;
            var         steamIdSource = radioSteam.GetBindingExpression(RadioButton.IsCheckedProperty);

            if (steamIdSource.IsDirty)
            {
                providerIntegrationChanged = true;
                steamIdSource.UpdateSource();
            }

            var steamAccount = ComboSteamAccount.GetBindingExpression(ComboBox.SelectedValueProperty);

            if (steamAccount.IsDirty)
            {
                providerIntegrationChanged = true;
                steamAccount.UpdateSource();
            }

            var steamAccountName = TextSteamAccountName.GetBindingExpression(TextBox.TextProperty);

            if (steamAccountName.IsDirty)
            {
                providerIntegrationChanged = true;
                steamAccountName.UpdateSource();
            }

            var gogEnabled = CheckGogEnabled.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (gogEnabled.IsDirty)
            {
                providerIntegrationChanged = true;
                gogEnabled.UpdateSource();
            }

            var gogRunGalaxy = CheckGogRunGalaxy.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (gogRunGalaxy.IsDirty)
            {
                gogRunGalaxy.UpdateSource();
            }

            var gogIcons = CheckGogIcons.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (gogIcons.IsDirty)
            {
                gogIcons.UpdateSource();
            }

            var gogDownloadLib = RadioLibraryGOG.GetBindingExpression(RadioButton.IsCheckedProperty);

            if (gogDownloadLib.IsDirty)
            {
                providerIntegrationChanged = true;
                gogDownloadLib.UpdateSource();
            }

            var originEnabled = CheckOriginEnabled.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (originEnabled.IsDirty)
            {
                providerIntegrationChanged = true;
                originEnabled.UpdateSource();
            }

            var originDownloadLib = RadioLibraryOrigin.GetBindingExpression(RadioButton.IsCheckedProperty);

            if (originDownloadLib.IsDirty)
            {
                providerIntegrationChanged = true;
                originDownloadLib.UpdateSource();
            }

            var uplayEnabled = CheckUplayEnabled.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (uplayEnabled.IsDirty)
            {
                providerIntegrationChanged = true;
                uplayEnabled.UpdateSource();
            }

            var trayMinimize = CheckMinimizeToTray.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (trayMinimize.IsDirty)
            {
                trayMinimize.UpdateSource();
            }

            var trayClose = CheckCloseToTray.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (trayClose.IsDirty)
            {
                trayClose.UpdateSource();
            }

            var trayEnable = CheckEnableTray.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (trayEnable.IsDirty)
            {
                trayEnable.UpdateSource();
            }

            var updateLibStartupEnable = CheckUpdateLibStartup.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (updateLibStartupEnable.IsDirty)
            {
                updateLibStartupEnable.UpdateSource();
            }

            var language = ComboLanguage.GetBindingExpression(ComboBox.SelectedValueProperty);

            if (language.IsDirty)
            {
                language.UpdateSource();
            }

            var minimizeLaunch = CheckMinimizeLaunch.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (minimizeLaunch.IsDirty)
            {
                minimizeLaunch.UpdateSource();
            }

            var asyncImageLoad = CheckAsyncImages.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (asyncImageLoad.IsDirty)
            {
                asyncImageLoad.UpdateSource();
            }

            var nameCoverArt = CheckNameEmptyCover.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (nameCoverArt.IsDirty)
            {
                nameCoverArt.UpdateSource();
            }

            var showIcons = CheckShowIcons.GetBindingExpression(CheckBox.IsCheckedProperty);

            if (showIcons.IsDirty)
            {
                showIcons.UpdateSource();
            }

            Playnite.Settings.Instance.SaveSettings();
            Close();
        }
Example #20
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
 {
     return(PlayniteMessageBox.Show(messageBoxText, caption, button, icon));
 }
Example #21
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     return(Invoke(() => PlayniteMessageBox.Show(messageBoxText, caption, button, icon, defaultResult)));
 }
Example #22
0
 public MessageBoxResult ShowMessage(string messageBoxText)
 {
     return(PlayniteMessageBox.Show(messageBoxText));
 }
Example #23
0
 public MessageBoxResult ShowMessage(string messageBoxText, string caption)
 {
     return(PlayniteMessageBox.Show(messageBoxText, caption));
 }