Example #1
0
		public MainWindow() {
			InitializeComponent();
			Instance = this;
			Model = MainWindowModel.Create();
			DataContext = Model;
			backgroundTask = new BackgroundTask(() => {
				bool b = Task.Run(async () => {
					GoSettings goSettings = new GoSettings();

					logger.Info("Setting up...");
					goSettings.AuthType = AuthType.Ptc;
					await txtUsername.SafeAccessAsync((t) => goSettings.PtcUsername = t.Text);
					await txtPassword.SafeAccessAsync((t) => goSettings.PtcPassword = t.Password);
					await dudLatitude.SafeAccessAsync((d) => goSettings.DefaultLatitude = d.Value ?? 0);
					await dudLongitude.SafeAccessAsync((d) => goSettings.DefaultLongitude = d.Value ?? 0);

					try {
						logger.Info("Beginning to farm...");
						PokemonGo.RocketAPI.Logger.SetLogger(new NLogLogger());
						await new GoLogic(goSettings).Execute();
					} catch (Exception e) {
						if (e is PtcOfflineException) {
							logger.Info("Could not log in (login servers may be down or invalid credentials)");
						} else {
							logger.Error(e);
						}
					}
					
					return true;
				}).Result;
			});
			SetupUI();
		}
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            Instance       = this;
            Model          = MainWindowModel.Create();
            DataContext    = Model;
            backgroundTask = new BackgroundTask(() => {
                bool b = Task.Run(async() => {
                    GoSettings goSettings = new GoSettings();

                    logger.Info("Setting up...");
                    goSettings.AuthType = AuthType.Ptc;
                    await txtUsername.SafeAccessAsync((t) => goSettings.PtcUsername       = t.Text);
                    await txtPassword.SafeAccessAsync((t) => goSettings.PtcPassword       = t.Password);
                    await dudLatitude.SafeAccessAsync((d) => goSettings.DefaultLatitude   = d.Value ?? 0);
                    await dudLongitude.SafeAccessAsync((d) => goSettings.DefaultLongitude = d.Value ?? 0);

                    try {
                        logger.Info("Beginning to farm...");
                        PokemonGo.RocketAPI.Logger.SetLogger(new NLogLogger());
                        await new GoLogic(goSettings).Execute();
                    } catch (Exception e) {
                        if (e is PtcOfflineException)
                        {
                            logger.Info("Could not log in (login servers may be down or invalid credentials)");
                        }
                        else
                        {
                            logger.Error(e);
                        }
                    }

                    return(true);
                }).Result;
            });
            SetupUI();
        }