Пример #1
0
        /*
         *
         * public async void StartGameScrape(ProgressDialogController controller)
         * {
         *   if (controller == null)
         *   {
         *       // create UI dialog
         *       var mySettings = new MetroDialogSettings()
         *       {
         *           NegativeButtonText = "Cancel Scraping",
         *           AnimateShow = false,
         *           AnimateHide = false
         *       };
         *       controller = await mw.ShowProgressAsync("Scraping Data", "Initialising...", true, settings: mySettings);
         *       controller.SetCancelable(true);
         *       await Task.Delay(100);
         *   }
         *
         *   await Task.Run(() =>
         *   {
         *       ScrapeGame(controller);
         *   });
         */
        /*
         * await controller.CloseAsync();
         *
         * if (controller.IsCanceled)
         * {
         *  await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Cancelled");
         * }
         * else
         * {
         *  await mw.ShowMessageAsync("MedLaunch Scraper", "Scraping Completed");
         * }
         *
         * await Task.Delay(300);
         */
        //GamesLibraryVisualHandler.RefreshGamesLibrary();

        // }
        /// <summary>
        /// Extension method to handle no controller being passed
        /// </summary>
        ///

        /*
         * public void StartGameScrape()
         * {
         *  StartGameScrape(null);
         * }
         */



        /// <summary>
        /// Creates a new entry in the GDBLink table (linking MedLaunch gameId to scraped data (thegamesdb.net) ID)
        /// also deletes any rows that have the same GameId (so that duplicates are not possible)
        /// </summary>
        /// <param name="gameId"></param>
        /// <param name="gamesDbId"></param>
        ///

        /*
         * public static void CreateDatabaseLink(int gameId, int gamesDbId)
         * {
         *  GDBLink link = new GDBLink();
         *  link.GameId = gameId;
         *  link.GdbId = gamesDbId;
         *  // delete any existing links with the same GameId
         *  GDBLink l = GDBLink.GetRecord(gameId);
         *  if (l != null)
         *  {
         *      GDBLink.DeleteRecord(l);
         *  }
         *  GDBLink.SaveToDatabase(link);
         *  PopulateLibraryData(link);
         *  GameListBuilder.UpdateFlag();
         * }
         */

        /// <summary>
        /// create data in the LibraryDataGDBLink table
        /// </summary>
        /// <param name="link"></param>
        public static void PopulateLibraryData(int gameId, int gdbId)
        {
            var data = LibraryDataGDBLink.GetLibraryData(gdbId);

            if (data == null)
            {
                data = new LibraryDataGDBLink();
            }

            GamesLibraryScrapedContent gd = new GamesLibraryScrapedContent();
            ScrapedGameObject          o  = gd.GetScrapedGameObject(gameId, gdbId);

            data.GDBId     = o.GdbId;
            data.Coop      = o.Data.Coop;
            data.Developer = o.Data.Developer;
            data.ESRB      = o.Data.ESRB;
            data.Players   = o.Data.Players;
            data.Publisher = o.Data.Publisher;
            data.Year      = o.Data.Released;

            // save library data
            LibraryDataGDBLink.SaveToDataBase(data);

            // set isScraped flag in Game table
            Game ga = Game.GetGame(gameId);

            ga.isScraped = true;
            ga.gdbId     = gdbId;
            Game.SetGame(ga);
        }
Пример #2
0
        private void ApplicationStart(object sender, StartupEventArgs e)
        {
            // unhandled exception events
            AppDomain.CurrentDomain.UnhandledException +=
                (s, exception) =>
                LogUnhandledException((Exception)exception.ExceptionObject, "AppDomain.CurrentDomain.UnhandledException");

            DispatcherUnhandledException +=
                (s, exception) =>
                LogUnhandledException(exception.Exception, "Application.Current.DispatcherUnhandledException");

            TaskScheduler.UnobservedTaskException +=
                (s, exception) =>
                LogUnhandledException(exception.Exception, "TaskScheduler.UnobservedException");



            var splashScreen = new SplashScreen(@"Data\Graphics\mediconsplash-new.png");

            splashScreen.Show(false);
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            // show the initialisation window and begin checks
            ShowInitWindow();
            Thread.Sleep(1000);
            // init should have completed - run MainWindow

            // instantiate GamesList object
            GamesList = new GameListBuilder();

            MainWindow mw = new MedLaunch.MainWindow();

            Current.ShutdownMode           = ShutdownMode.OnMainWindowClose;
            Application.Current.MainWindow = mw;



            mw.Show();

            // instantiate GamesList object
            //GamesList = new GameListBuilder();



            splashScreen.Close(TimeSpan.FromSeconds(1));

            // instantiate ScrapedContent Object
            ScrapedData = new GamesLibraryScrapedContent();



            // set color scheme from database
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Data\Settings\MedLaunch.db"))
            {
                // database already exists
                var gs = GlobalSettings.GetGlobals();
                ThemeManager.ChangeAppStyle(Application.Current,
                                            ThemeManager.GetAccent(gs.colorAccent),
                                            ThemeManager.GetAppTheme(gs.colorBackground));
            }
            else
            {
                // database hasnt been generated yet - set default
                ThemeManager.ChangeAppStyle(Application.Current,
                                            ThemeManager.GetAccent("Emerald"),
                                            ThemeManager.GetAppTheme("BaseDark"));
            }
        }
Пример #3
0
        /// <summary>
        /// Takes a finished ScrapedGameObject and downloads all media present in it
        /// </summary>
        /// <param name="o"></param>
        /// <param name="controller"></param>
        public static void ContentDownloadManager(ScrapedGameObjectWeb o, ProgressDialogController controller, GamesLibraryScrapedContent glsc, string message)
        {
            string baseDir = glsc.BaseContentDirectory + @"\" + o.GdbId.ToString() + @"\";
            int    total;
            int    count;

            // screenshots
            if (o.Screenshots != null && o.Screenshots.Count > 0)
            {
                total = o.Screenshots.Count;
                count = 1;
                controller.SetMessage(message + "Downloading Screenshots for: " + o.Data.Title);
                foreach (string s in o.Screenshots)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nScreenshot: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "Screenshots");
                    count++;
                }
            }

            // fanart
            if (o.FanArts != null && o.FanArts.Count > 0)
            {
                total = o.FanArts.Count;
                count = 1;
                controller.SetMessage(message + "Downloading FanArt for: " + o.Data.Title);
                foreach (string s in o.FanArts)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nFanart: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "FanArt");
                    count++;
                }
            }

            // medias
            if (o.Medias != null && o.Medias.Count > 0)
            {
                total = o.Medias.Count;
                count = 1;
                controller.SetMessage(message + "Downloading Media for: " + o.Data.Title);
                foreach (string s in o.Medias)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nMedia: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "Media");
                    count++;
                }
            }

            // front boxart
            if (o.FrontCovers != null && o.FrontCovers.Count > 0)
            {
                total = o.FrontCovers.Count;
                count = 1;
                controller.SetMessage(message + "Downloading Front Box Art for: " + o.Data.Title);
                foreach (string s in o.FrontCovers)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nFront Cover: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "FrontCover");
                    count++;
                }
            }

            // back boxart
            if (o.BackCovers != null && o.BackCovers.Count > 0)
            {
                controller.SetMessage(message + "Downloading Back Box Art for: " + o.Data.Title);
                total = o.BackCovers.Count;
                count = 1;
                foreach (string s in o.BackCovers)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nBack Cover: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "BackCover");
                    count++;
                }
            }

            // banners
            if (o.Banners != null && o.Banners.Count > 0)
            {
                total = o.Banners.Count;
                count = 1;
                controller.SetMessage(message + "Downloading Banners for: " + o.Data.Title);
                foreach (string s in o.Banners)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nBanner: " + count + " of " + total + "\n(" + s + ")");
                    DownloadFile(s, baseDir + "Banners");
                    count++;
                }
            }

            // manuals
            if (o.Manuals != null && o.Manuals.Count > 0)
            {
                total = o.Manuals.Count;
                count = 1;
                controller.SetMessage(message + "Downloading Manuals for: " + o.Data.Title);
                foreach (string s in o.Manuals)
                {
                    controller.SetMessage(message + "Downloading content for: " + o.Data.Title + "\nManual: " + count + " of " + total + "\n(" + s + ")");

                    DownloadFile(s, baseDir + "Manual");
                    count++;
                }
            }
        }