private void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (DataContext == null)
            {
                return;
            }

            if (PlayniteMessageBox.Show(
                    FindResource("GameRemoveAskMessage") as string,
                    FindResource("GameRemoveAskTitle") as string,
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            var game = (DataContext as IGame);

            if (game is Game)
            {
                GameDatabase.Instance.DeleteGame(game);
            }

            IsOpen = false;
        }
        private void ButtonNext_Click(object sender, RoutedEventArgs e)
        {
            if (Model.ViewTabIndex == 2)
            {
                if (Model.EmulatorList == null || Model.EmulatorList.Count == 0 || Model.EmulatorList.Where(a => a.Import).Count() == 0)
                {
                    if (PlayniteMessageBox.Show(FindResource("EmuWizardNoEmulatorWarning") as string, "", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    {
                        return;
                    }
                    else
                    {
                        DialogResult = true;
                        Close();
                    }
                }
            }

            Model.ViewTabIndex++;

            if (Model.ViewTabIndex == 3)
            {
                Model.AddSelectedEmulatorsToDB();
            }
        }
        public FirstTimeStartupWindow()
        {
            InitializeComponent();
            SteamEnabled        = true;
            GOGEnabled          = true;
            OriginEnabled       = true;
            UplayEnabled        = true;
            SteamImportLibrary  = false;
            SteamAccountName    = string.Empty;
            GogImportLibrary    = false;
            OriginImportLibrary = false;

            pageValidators.Add("Steam", (window) =>
            {
                if (window.SteamImportLibrary)
                {
                    if (window.SteamImportLibByName && string.IsNullOrEmpty(window.SteamAccountName))
                    {
                        PlayniteMessageBox.Show(FindResource("SettingsInvalidSteamAccountName") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }

                    if (!window.SteamImportLibByName && window.SteamIdLibImport == 0)
                    {
                        PlayniteMessageBox.Show(FindResource("SettingsInvalidSteamAccountLibImport") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                }

                if (window.SteamImportCategories && window.SteamIdCategoryImport == 0)
                {
                    PlayniteMessageBox.Show(FindResource("SettingsInvalidSteamAccountCatImport") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }

                return(true);
            });

            pageValidators.Add("Database", (window) =>
            {
                if (window.DatabaseLocation == DbLocation.Custom)
                {
                    if (!Paths.GetValidFilePath(window.DatabasePath))
                    {
                        PlayniteMessageBox.Show(FindResource("SettingsInvalidDBLocation") as string, FindResource("InvalidDataTitle") as string, MessageBoxButton.OK, MessageBoxImage.Error);
                        return(false);
                    }
                }

                return(true);
            });
        }
        private void OpenLocation_Click(object sender, RoutedEventArgs e)
        {
            var game = (IGame)(sender as FrameworkElement).DataContext;

            try
            {
                Process.Start(game.InstallDirectory);
            }
            catch (Exception exc)
            {
                PlayniteMessageBox.Show("Cannot open game location: " + exc.Message, "Game Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                IsOpen = false;
            }
        }
        private void Task_Click(object sender, RoutedEventArgs e)
        {
            var gameTask = (GameTask)(sender as FrameworkElement).DataContext;
            var game     = DataContext as Game;

            try
            {
                GameHandler.ActivateTask(gameTask, game, GameDatabase.Instance.EmulatorsCollection.FindAll().ToList());
            }
            catch (Exception exc)
            {
                PlayniteMessageBox.Show("Cannot start action: " + exc.Message, "Action Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                IsOpen = false;
            }
        }
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            var games = (List <IGame>)DataContext;

            if (PlayniteMessageBox.Show(
                    string.Format((FindResource("GamesRemoveAskMessage") as string), games.Count),
                    FindResource("GameRemoveAskTitle") as string,
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            foreach (var game in games)
            {
                GameDatabase.Instance.DeleteGame(game);
            }
        }
Exemple #7
0
        private void ButtonSaveDiag_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 ButtonScanGames_Click(object sender, RoutedEventArgs e)
        {
            if (Model.AvailableEmulators == null || Model.AvailableEmulators.Count == 0)
            {
                if (Model.EmulatorList == null || Model.EmulatorList.Count == 0 || Model.EmulatorList.Where(a => a.Import).Count() == 0)
                {
                    if (PlayniteMessageBox.Show(FindResource("EmuWizardNoEmulatorForGamesWarning") as string, "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                    {
                        return;
                    }
                    else
                    {
                        ButtonConfigEmulator_Click(this, null);
                    }
                }
            }

            var button = (Button)sender;

            button.ContextMenu.PlacementTarget = button;
            button.ContextMenu.Placement       = System.Windows.Controls.Primitives.PlacementMode.Top;
            button.ContextMenu.IsOpen          = true;
        }
Exemple #9
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            var id = ((SearchResult)ListSearch.SelectedItem).Id;

            Task.Factory.StartNew(() =>
            {
                TextDownloading.Dispatcher.Invoke(() =>
                {
                    ListSearch.Visibility      = Visibility.Hidden;
                    TextDownloading.Visibility = Visibility.Visible;
                    ButtonOK.IsEnabled         = false;
                    ButtonCancel.IsEnabled     = false;
                });

                try
                {
                    switch (provider)
                    {
                    case MetadataProvider.Wiki:
                        var wiki     = new Wikipedia();
                        var page     = wiki.GetPage(id);
                        MetadataData = wiki.ParseGamePage(page, searchTerm);
                        break;

                    case MetadataProvider.IGDB:
                        var igdb     = new IGDB();
                        MetadataData = igdb.GetParsedGame(UInt64.Parse(id));
                        break;
                    }
                }
                catch (Exception exc)
                {
#if DEBUG
                    logger.Error(exc, "Failed to download metadata from meta page.");
#else
                    logger.Warn(exc, "Failed to download metadata from meta page.");
#endif

                    Dispatcher.Invoke(() =>
                    {
                        PlayniteMessageBox.Show("Didn't found any relevant information about game \"" + searchTerm + "\" on specified page.");
                    });

                    TextDownloading.Dispatcher.Invoke(() =>
                    {
                        ListSearch.Visibility      = Visibility.Visible;
                        TextDownloading.Visibility = Visibility.Hidden;
                        ButtonOK.IsEnabled         = true;
                        ButtonCancel.IsEnabled     = true;
                    });

                    return;
                }

                Dispatcher.Invoke(() =>
                {
                    DialogResult = true;
                    Close();
                });
            });
        }