Ejemplo n.º 1
0
        private void AddEmulatedGames_Click(object sender, RoutedEventArgs e)
        {
            var window = new EmulatorImportWindow(DialogType.GameImport)
            {
                Owner = this
            };

            if (window.ShowDialog() == true)
            {
                window.Model.AddSelectedGamesToDB();
            }
        }
Ejemplo n.º 2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BringToForeground();
            NotificationsWin.AutoOpen = true;
            positionManager.RestoreSizeAndLocation(Config);

            Config.PropertyChanged += Config_PropertyChanged;
            Config.FilterSettings.PropertyChanged += FilterSettings_PropertyChanged;

            gamesStats = new GamesStats(GameDatabase.Instance);
            MenuMainMenu.DataContext     = this;
            MenuViewSettings.DataContext = Config;
            FilterSelector.DataContext   = new FilterSelectorConfig(gamesStats, Config.FilterSettings);
            CheckFilterView.DataContext  = Config.FilterSettings;
            GridGamesView.AppSettings    = Config;

            if (!Config.FirstTimeWizardComplete)
            {
                var window = new FirstTimeStartupWindow()
                {
                    Owner = this
                };

                if (window.ShowDialog() == true)
                {
                    config.SteamSettings.IdSource                = window.SteamImportLibByName ? SteamIdSource.Name : SteamIdSource.LocalUser;
                    Config.SteamSettings.AccountId               = window.SteamIdLibImport;
                    Config.SteamSettings.IntegrationEnabled      = window.SteamEnabled;
                    Config.SteamSettings.LibraryDownloadEnabled  = window.SteamImportLibrary;
                    Config.SteamSettings.AccountName             = window.SteamAccountName;
                    Config.GOGSettings.IntegrationEnabled        = window.GOGEnabled;
                    Config.GOGSettings.LibraryDownloadEnabled    = window.GogImportLibrary;
                    Config.OriginSettings.IntegrationEnabled     = window.OriginEnabled;
                    Config.OriginSettings.LibraryDownloadEnabled = window.OriginImportLibrary;
                    Config.UplaySettings.IntegrationEnabled      = window.UplayEnabled;
                    importSteamCatWizard   = window.SteamImportCategories;
                    importSteamCatWizardId = window.SteamIdCategoryImport;

                    if (window.DatabaseLocation == FirstTimeStartupWindow.DbLocation.Custom)
                    {
                        Config.DatabasePath = window.DatabasePath;
                    }
                    else
                    {
                        FileSystem.CreateFolder(Paths.UserProgramDataPath);
                        Config.DatabasePath = System.IO.Path.Combine(Paths.UserProgramDataPath, "games.db");
                    }

                    GameDatabase.Instance.OpenDatabase(Config.DatabasePath);
                    AddInstalledGames(window.ImportedGames);

                    Config.FirstTimeWizardComplete = true;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Config"));
                }
            }

            if (!Config.EmulatorWizardComplete)
            {
                GameDatabase.Instance.OpenDatabase(Config.DatabasePath);
                var window = new EmulatorImportWindow(DialogType.Wizard)
                {
                    Owner = this
                };

                if (window.ShowDialog() == true)
                {
                    Config.EmulatorWizardComplete = true;
                }
            }

            if (!Config.MigrationV2PcPlatformAdded)
            {
                GameDatabase.Instance.OpenDatabase(Config.DatabasePath);
                var db = GameDatabase.Instance;
                foreach (var game in db.GamesCollection.Find(a => a.Provider != Provider.Custom).ToList())
                {
                    db.AssignPcPlatform(game);
                    db.UpdateGameInDatabase(game);
                }

                Config.MigrationV2PcPlatformAdded = true;
            }

            LoadGames(Config.UpdateLibStartup);
            CheckUpdate();
            SendUsageData();
            Focus();

            pipeService = new PipeService();
            pipeService.CommandExecuted += PipeService_CommandExecuted;
            pipeServer = new PipeServer(Settings.GetAppConfigValue("PipeEndpoint"));
            pipeServer.StartServer(pipeService);

            var args = Environment.GetCommandLineArgs();

            if (args.Count() > 0 && args.Contains("-command"))
            {
                var commandArgs = args[2].Split(new char[] { ':' });
                var command     = commandArgs[0];
                var cmdArgs     = commandArgs.Count() > 1 ? commandArgs[1] : string.Empty;
                PipeService_CommandExecuted(this, new CommandExecutedEventArgs(command, cmdArgs));
            }
        }