Beispiel #1
0
        private void AccountSettingsForm_Load(object sender, EventArgs e)
        {
            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);

            foreach (AccountState state in Enum.GetValues(typeof(AccountState)))
            {
                if (state == AccountState.Good)
                {
                    continue;
                }

                comboBoxMinAccountState.Items.Add(state);
            }

            UpdateDetails(_manager.UserSettings);

            UpdateListViews();

            comboBoxLocationPresets.DataSource    = _manager.FarmLocations;
            comboBoxLocationPresets.DisplayMember = "Name";

            cbUseOnlyThisHashKey.Checked = _manager.UserSettings.UseOnlyOneKey;
            tbAuthHashKey.Text           = _manager.UserSettings.AuthAPIKey;

            //Location time zones
            var zones = new TimeZoneIds().GetTimeZoneIds();

            foreach (var tz in zones)
            {
                cbTimeZones.Items.Add(tz.Key);
            }

            cbTimeZones.Text = _manager.UserSettings.TimeZone;
        }
Beispiel #2
0
        public IActionResult Get()
        {
            List <string> result      = new List <string>();
            var           timeZoneIds = TimeZoneIds.GetAllTimeZoneInfo();

            foreach (TimeZoneInfo tzi in timeZoneIds)
            {
                result.Add(tzi.Id);
            }
            Console.WriteLine("TimeZone Ids fetched" + DateTime.UtcNow);
            return(Ok(result));
        }
Beispiel #3
0
        public static TimeZoneInfo GetStandardTimeZoneInfo(TimeZoneId timeZone)
        {
            if (!TimeZoneIds.TryGetValue(timeZone, out TimeZoneType timeZoneId))
            {
                throw new ArgumentOutOfRangeException(nameof(timeZoneId));
            }
            string id = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                            ? timeZoneId.Windows
                            : timeZoneId.NonWindows;
            TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(id);

            return(timeZoneInfo);
        }
Beispiel #4
0
        public IList <string> GetLocalTimes(IEnumerable <string> timeZoneIdsEnumerable)
        {
            TimeZoneIds timeZoneIds = new TimeZoneIds();

            foreach (string timeZoneId in timeZoneIdsEnumerable)
            {
                timeZoneIds.TimeZoneIds_.Add(timeZoneId);
            }

            _channel.WriteAndFlushAsync(timeZoneIds);

            LocalTimes localTimes = _answer.Take();

            IList <string> result = new List <string>();

            foreach (LocalTime lt in localTimes.LocalTimes_)
            {
                result.Add($"{lt.Year}-{lt.Month}-{lt.DayOfMonth} {lt.Hour}:{lt.Minute}:{lt.Second} {lt.DayOfWeek}");
            }

            return(result);
        }
Beispiel #5
0
        public IActionResult GetWorldTime(int id)
        {
            var utcTime    = DateTime.UtcNow;
            var serverTime = DateTime.Now;
            var ip         = HttpContext.Connection.RemoteIpAddress.ToString();
            var timeZones  = TimeZoneIds.GetAllTimeZoneInfo();

            if (id > timeZones.Count - 1)
            {
                return(StatusCode(404));
            }

            var requestedTimeZone = timeZones[id].Id.ToString();
            var convertedDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, timeZones[id]).ToShortTimeString();

            var returnVal = new WorldTimeQuery
            {
                ClientIp          = ip,
                UTCTime           = utcTime,
                RequestedTimeZone = requestedTimeZone,
                ConvertedDateTime = convertedDateTime
            };

            using (var db = new ClockworkContext())
            {
                db.WorldTimeQueries.Add(returnVal);
                var count = db.SaveChanges();
                Console.WriteLine("{0} records saved to database", count);

                Console.WriteLine();
                foreach (var WorldTimeQuery in db.WorldTimeQueries)
                {
                    Console.WriteLine($" - {WorldTimeQuery.RequestedTimeZone} : {WorldTimeQuery.ConvertedDateTime}");
                }
            }

            return(Ok(returnVal));
        }
Beispiel #6
0
        private bool SaveSettings()
        {
            Settings userSettings = _manager.UserSettings;

            ProxyEx proxyEx = null;

            int maxLevel;

            if (!Int32.TryParse(textBoxMaxLevel.Text, out maxLevel) || maxLevel < 0)
            {
                MessageBox.Show("Invalid Max level", "Warning");
                return(false);
            }

            int minPokemonBeforeEvolve;

            if (!Int32.TryParse(textBoxPokemonBeforeEvolve.Text, out minPokemonBeforeEvolve) || minPokemonBeforeEvolve < 0)
            {
                MessageBox.Show("Invalid pokemon before evolve", "Warning");
                return(false);
            }
            int walkingSpeed;

            if (!Int32.TryParse(textBoxWalkSpeed.Text, out walkingSpeed) || walkingSpeed <= 0)
            {
                MessageBox.Show("Invalid walking speed", "Warning");
                return(false);
            }
            int maxTravelDistance;

            if (!Int32.TryParse(textBoxMaxTravelDistance.Text, out maxTravelDistance) || maxTravelDistance <= 0)
            {
                MessageBox.Show("Invalid max travel distance", "Warning");
                return(false);
            }
            double defaultLat;

            if (!Double.TryParse(textBoxLat.Text.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out defaultLat))
            {
                MessageBox.Show("Invalid latitude", "Warning");
                return(false);
            }
            double defaultLong;

            if (!Double.TryParse(textBoxLong.Text.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out defaultLong))
            {
                MessageBox.Show("Invalid longitude", "Warning");
                return(false);
            }

            if (!String.IsNullOrEmpty(textBoxProxy.Text) && !ProxyEx.TryParse(textBoxProxy.Text, out proxyEx))
            {
                MessageBox.Show("Invalid proxy format", "Warning");
                return(false);
            }

            if (comboBoxMinAccountState.SelectedItem == null)
            {
                MessageBox.Show("Please select a valid min account state", "Warning");
                return(false);
            }

            if (walkingSpeed < (double)numericUpDownWalkingOffset.Value)
            {
                MessageBox.Show("Walking offset must be more than walking speed", "Warning");
                return(false);
            }

            if (String.IsNullOrEmpty(textBoxPtcUsername.Text))
            {
                MessageBox.Show("Invalid Username", "Warning");
                return(false);
            }
            if (String.IsNullOrEmpty(textBoxPtcPassword.Text))
            {
                MessageBox.Show("Invalid Password", "Warning");
                return(false);
            }

            userSettings.AuthType = textBoxPtcUsername.Text.Contains("@") ? AuthType.Google : AuthType.Ptc;

            userSettings.MimicWalking     = checkBoxMimicWalking.Checked;
            userSettings.ShufflePokestops = checkBoxShufflePokestops.Checked;

            userSettings.Username                = textBoxPtcUsername.Text.Trim();
            userSettings.Password                = textBoxPtcPassword.Text.Trim();
            userSettings.Latitude                = defaultLat;
            userSettings.Longitude               = defaultLong;
            userSettings.WalkingSpeed            = walkingSpeed;
            userSettings.MaxTravelDistance       = maxTravelDistance;
            userSettings.EncounterWhileWalking   = checkBoxEncounterWhileWalking.Checked;
            userSettings.AccountName             = textBoxName.Text;
            userSettings.TransferPokemon         = checkBoxTransfers.Checked;
            userSettings.TransferSlashPokemons   = checkBoxTransferSlashPokemons.Checked;
            userSettings.EvolvePokemon           = checkBoxEvolve.Checked;
            userSettings.RecycleItems            = checkBoxRecycle.Checked;
            userSettings.MinPokemonBeforeEvolve  = minPokemonBeforeEvolve;
            userSettings.UseLuckyEgg             = checkBoxUseLuckyEgg.Checked;
            userSettings.IncubateEggs            = checkBoxIncubateEggs.Checked;
            userSettings.OnlyUnlimitedIncubator  = checkBoxOnlyUnlimitedIncubator.Checked;
            userSettings.MaxLevel                = maxLevel;
            userSettings.CatchPokemon            = checkBoxCatchPokemon.Checked;
            userSettings.StopAtMinAccountState   = (AccountState)comboBoxMinAccountState.SelectedItem;
            userSettings.SearchFortBelowPercent  = (double)numericUpDownSearchFortBelow.Value;
            userSettings.CatchPokemonDayLimit    = (int)numericUpDownPokemonsDayLimit.Value;
            userSettings.SpinPokestopsDayLimit   = (int)numericUpDownStopsDayLimit.Value;
            userSettings.ForceEvolveAbovePercent = (double)numericUpDownForceEvolveAbove.Value;
            userSettings.ClaimLevelUpRewards     = checkBoxClaimLevelUp.Checked;
            userSettings.StopOnAPIUpdate         = checkBoxStopOnAPIUpdate.Checked;
            userSettings.SpinGyms                = checkBoxSpinGyms.Checked;
            userSettings.DeployPokemon           = checkBoxDeployToGym.Checked;
            AutoUpdate = cbAutoUpdate.Checked;
            userSettings.UseBerries         = checkBoxUseBerries.Checked;
            userSettings.DisableCatchDelay  = (int)numericUpDownDisableCatchDelay.Value;
            userSettings.UseIncense         = cbUseIncense.Checked;
            userSettings.RunForHours        = (double)numericUpDownRunForHours.Value;
            userSettings.MaxLogs            = (int)numericUpDownMaxLogs.Value;
            userSettings.StopOnIPBan        = checkBoxStopOnIPBan.Checked;
            userSettings.MaxFailBeforeReset = (int)numericUpDownMaxFailBeforeReset.Value;
            userSettings.AutoRotateProxies  = checkBoxAutoRotateProxies.Checked;
            userSettings.AutoRemoveOnStop   = checkBoxRemoveOnStop.Checked;

            //Humanization
            userSettings.EnableHumanization   = checkBoxHumanizeThrows.Checked;
            userSettings.InsideReticuleChance = (int)numericUpDownInsideReticuleChance.Value;

            userSettings.GeneralDelay       = (int)numericUpDownGeneralDelay.Value;
            userSettings.GeneralDelayRandom = (int)numericUpDownGeneralDelayRandom.Value;

            userSettings.DelayBetweenLocationUpdates = (int)numericUpDownLocationUpdateDelay.Value;
            userSettings.LocationupdateDelayRandom   = (int)numericUpDownLocationUpdateRandom.Value;

            userSettings.DelayBetweenPlayerActions = (int)numericUpDownPlayerActionDelay.Value;
            userSettings.PlayerActionDelayRandom   = (int)numericUpDownPlayerActionRandomiz.Value;

            userSettings.WalkingSpeedOffset = (double)numericUpDownWalkingOffset.Value;
            //End humanization

            //Device settings
            userSettings.DeviceId             = textBoxDeviceId.Text;
            userSettings.DeviceModel          = textBoxDeviceModel.Text;
            userSettings.DeviceBrand          = textBoxDeviceBrand.Text;
            userSettings.DeviceModelBoot      = textBoxDeviceModelBoot.Text;
            userSettings.HardwareManufacturer = textBoxHardwareManufacturer.Text;
            userSettings.HardwareModel        = textBoxHardwareModel.Text;
            userSettings.FirmwareBrand        = textBoxFirmwareBrand.Text;
            userSettings.FirmwareType         = textBoxFirmwareType.Text;
            //End device settings

            //Api config
            userSettings.HashHost      = new Uri(cbHashHost.Text);
            userSettings.HashEndpoint  = cbHashEndpoint.Text;
            userSettings.AuthAPIKey    = tbAuthHashKey.Text;
            userSettings.UseOnlyOneKey = cbUseOnlyThisHashKey.Checked;
            //End api config

            //Location time zones
            var x = new TimeZoneIds().GetTimeZoneIds();

            userSettings.TimeZone = cbTimeZones.Text;
            userSettings.Country  = x[cbTimeZones.Text].Item1;
            userSettings.Language = x[cbTimeZones.Text].Item2;
            userSettings.POSIX    = x[cbTimeZones.Text].Item3;
            //End location time zones

            userSettings.GetArBonus       = checkBoxGetARBonus.Checked;
            userSettings.CompleteTutorial = checkBoxCompleteTutorial.Checked;
            userSettings.TransferAtOnce   = checkBoxTransferAtOnce.Checked;

            if (proxyEx != null)
            {
                userSettings.ProxyIP       = proxyEx.Address;
                userSettings.ProxyPort     = proxyEx.Port;
                userSettings.ProxyUsername = proxyEx.Username;
                userSettings.ProxyPassword = proxyEx.Password;
            }
            else
            {
                userSettings.ProxyUsername = null;
                userSettings.ProxyPassword = null;
                userSettings.ProxyIP       = null;
                userSettings.ProxyPort     = 0;
            }

            userSettings.ARBonusProximity = numericUpDownProximity.Value;
            userSettings.ARBonusAwareness = numericUpDownAwareness.Value;

            // Developer options
            userSettings.ShowDebugLogs     = checkBoxShowDebugLogs.Checked;
            userSettings.DownloadResources = checkBoxDownloadResources.Checked;

            //Captcha Config
            userSettings.AllowManualCaptchaResolve = AllowManualCaptchaResolve.Checked;
            int manualCaptchaTimeout;

            if (!Int32.TryParse(ManualCaptchaTimeout.Text, out manualCaptchaTimeout) || maxLevel < 0)
            {
                MessageBox.Show("InvalidTimeOut", "Warning");
                return(false);
            }
            userSettings.ManualCaptchaTimeout = manualCaptchaTimeout;
            userSettings.PlaySoundOnCaptcha   = PlaySoundOnCaptcha.Checked;
            userSettings.DisplayOnTop         = DisplayOnTop.Checked;
            userSettings.Enable2Captcha       = Enable2Captcha.Checked;
            userSettings.EnableAntiCaptcha    = EnableAntiCaptcha.Checked;
            userSettings.AntiCaptchaAPIKey    = AntiCaptchaAPIKey.Text;
            userSettings.ProxyHostCaptcha     = ProxyHostCaptcha.Text;
            int proxyPortCaptcha;

            if (!Int32.TryParse(ProxyPortCaptcha.Text, out proxyPortCaptcha) || maxLevel < 0)
            {
                MessageBox.Show("InvalidProxyCaptchaPort", "Warning");
                return(false);
            }
            userSettings.ProxyPortCaptcha          = proxyPortCaptcha;
            userSettings.EnableCaptchaSolutions    = EnableCaptchaSolutions.Checked;
            userSettings.CaptchaSolutionAPIKey     = CaptchaSolutionAPIKey.Text;
            userSettings.CaptchaSolutionsSecretKey = CaptchaSolutionsSecretKey.Text;
            int autoCaptchaTimeout;

            if (!Int32.TryParse(AutoCaptchaTimeout.Text, out autoCaptchaTimeout) || maxLevel < 0)
            {
                MessageBox.Show("InvalidAutoCaptchaTimeout", "Warning");
                return(false);
            }
            userSettings.AutoCaptchaTimeout = autoCaptchaTimeout;
            int autoCaptchaRetries;

            if (!Int32.TryParse(AutoCaptchaRetries.Text, out autoCaptchaRetries) || maxLevel < 0)
            {
                MessageBox.Show("InvalidAutoCaptchaRetries", "Warning");
                return(false);
            }
            userSettings.AutoCaptchaRetries          = autoCaptchaRetries;
            userSettings.TwoCaptchaAPIKey            = TwoCaptchaAPIKey.Text;
            userSettings.DefaultTeam                 = (string)cbTeam.SelectedItem ?? "Neutral";
            userSettings.GoOnlyToGyms                = checkBoxGoToGymsOnly.Checked;
            userSettings.UpgradePokemon              = checkBoxUpgradePokemons.Checked;
            userSettings.AutoFavoritShiny            = checkBoxAutoFavShiny.Checked;
            userSettings.SnipeAllPokemonsNoInPokedex = checkBoxSniperNoInPokedex.Checked;

            return(true);
        }
Beispiel #7
0
        private void UpdateDetails(Settings settings)
        {
            textBoxPtcPassword.Text                = settings.Password;
            textBoxPtcUsername.Text                = settings.Username;
            textBoxLat.Text                        = settings.Latitude.ToString();
            textBoxLong.Text                       = settings.Longitude.ToString();
            textBoxName.Text                       = settings.AccountName;
            textBoxMaxTravelDistance.Text          = settings.MaxTravelDistance.ToString();
            textBoxWalkSpeed.Text                  = settings.WalkingSpeed.ToString();
            textBoxPokemonBeforeEvolve.Text        = settings.MinPokemonBeforeEvolve.ToString();
            textBoxMaxLevel.Text                   = settings.MaxLevel.ToString();
            textBoxProxy.Text                      = settings.Proxy.ToString();
            checkBoxMimicWalking.Checked           = settings.MimicWalking;
            checkBoxShufflePokestops.Checked       = settings.ShufflePokestops;
            checkBoxEncounterWhileWalking.Checked  = settings.EncounterWhileWalking;
            checkBoxRecycle.Checked                = settings.RecycleItems;
            checkBoxEvolve.Checked                 = settings.EvolvePokemon;
            checkBoxTransfers.Checked              = settings.TransferPokemon;
            checkBoxTransferSlashPokemons.Checked  = settings.TransferSlashPokemons;
            checkBoxUseLuckyEgg.Checked            = settings.UseLuckyEgg;
            checkBoxIncubateEggs.Checked           = settings.IncubateEggs;
            checkBoxOnlyUnlimitedIncubator.Checked = settings.OnlyUnlimitedIncubator;
            checkBoxCatchPokemon.Checked           = settings.CatchPokemon;
            numericUpDownRunForHours.Value         = new Decimal(settings.RunForHours);
            numericUpDownMaxLogs.Value             = settings.MaxLogs;
            numericUpDownMaxFailBeforeReset.Value  = settings.MaxFailBeforeReset;
            checkBoxStopOnIPBan.Checked            = settings.StopOnIPBan;
            checkBoxAutoRotateProxies.Checked      = settings.AutoRotateProxies;
            checkBoxRemoveOnStop.Checked           = settings.AutoRemoveOnStop;
            checkBoxClaimLevelUp.Checked           = settings.ClaimLevelUpRewards;
            numericUpDownSearchFortBelow.Value     = new Decimal(settings.SearchFortBelowPercent);
            numericUpDownPokemonsDayLimit.Value    = new Decimal(settings.CatchPokemonDayLimit);
            numericUpDownStopsDayLimit.Value       = new Decimal(settings.SpinPokestopsDayLimit);
            numericUpDownForceEvolveAbove.Value    = new Decimal(settings.ForceEvolveAbovePercent);
            checkBoxStopOnAPIUpdate.Checked        = settings.StopOnAPIUpdate;

            if (!string.IsNullOrEmpty(settings.DefaultTeam) && settings.DefaultTeam != "Neutral")
            {
                checkBoxSpinGyms.Enabled     = true;
                checkBoxSpinGyms.Checked     = settings.SpinGyms;
                checkBoxDeployToGym.Enabled  = true;
                checkBoxDeployToGym.Checked  = settings.DeployPokemon;
                checkBoxGoToGymsOnly.Enabled = true;
                checkBoxGoToGymsOnly.Checked = settings.GoOnlyToGyms;
            }
            else
            {
                checkBoxSpinGyms.Enabled     = false;
                checkBoxSpinGyms.Checked     = false;
                checkBoxDeployToGym.Enabled  = false;
                checkBoxDeployToGym.Checked  = false;
                checkBoxGoToGymsOnly.Enabled = false;
                checkBoxGoToGymsOnly.Checked = false;
            }

            cbUseIncense.Checked = settings.UseIncense;

            //Humanization
            checkBoxHumanizeThrows.Checked          = settings.EnableHumanization;
            numericUpDownInsideReticuleChance.Value = settings.InsideReticuleChance;

            numericUpDownGeneralDelay.Value       = settings.GeneralDelay;
            numericUpDownGeneralDelayRandom.Value = settings.GeneralDelayRandom;

            numericUpDownLocationUpdateDelay.Value  = settings.DelayBetweenLocationUpdates;
            numericUpDownLocationUpdateRandom.Value = settings.LocationupdateDelayRandom;

            numericUpDownPlayerActionDelay.Value    = settings.DelayBetweenPlayerActions;
            numericUpDownPlayerActionRandomiz.Value = settings.PlayerActionDelayRandom;

            numericUpDownWalkingOffset.Value = new Decimal(settings.WalkingSpeedOffset);
            //End humanization

            //Device settings
            textBoxDeviceId.Text             = settings.DeviceId;
            textBoxDeviceModel.Text          = settings.DeviceModel;
            textBoxDeviceBrand.Text          = settings.DeviceBrand;
            textBoxDeviceModelBoot.Text      = settings.DeviceModelBoot;
            textBoxFirmwareBrand.Text        = settings.FirmwareBrand;
            textBoxFirmwareType.Text         = settings.FirmwareType;
            textBoxHardwareManufacturer.Text = settings.HardwareManufacturer;
            textBoxHardwareModel.Text        = settings.HardwareModel;
            //End device settings

            //Api config
            cbHashHost.Text              = settings.HashHost.ToString();
            cbHashEndpoint.Text          = settings.HashEndpoint;
            tbAuthHashKey.Text           = settings.AuthAPIKey;
            cbUseOnlyThisHashKey.Checked = settings.UseOnlyOneKey;

            checkBoxUseBerries.Checked       = settings.UseBerries;
            checkBoxGetARBonus.Checked       = settings.GetArBonus;
            checkBoxCompleteTutorial.Checked = settings.CompleteTutorial;
            checkBoxTransferAtOnce.Checked   = settings.TransferAtOnce;
            numericUpDownProximity.Value     = settings.ARBonusProximity;
            numericUpDownAwareness.Value     = settings.ARBonusAwareness;
            checkBoxUpgradePokemons.Checked  = settings.UpgradePokemon;

            cbUseOnlyThisHashKey.Checked         = _manager.UserSettings.UseOnlyOneKey;
            tbAuthHashKey.Text                   = _manager.UserSettings.AuthAPIKey;
            cbAutoUpdate.Checked                 = AutoUpdate;
            numericUpDownDisableCatchDelay.Value = new Decimal(_manager.UserSettings.DisableCatchDelay);

            checkBoxShowDebugLogs.Checked     = settings.ShowDebugLogs;
            checkBoxDownloadResources.Checked = settings.DownloadResources;

            //Captcha Config
            AllowManualCaptchaResolve.Checked = settings.AllowManualCaptchaResolve;
            ManualCaptchaTimeout.Text         = settings.ManualCaptchaTimeout.ToString();
            PlaySoundOnCaptcha.Checked        = settings.PlaySoundOnCaptcha;
            DisplayOnTop.Checked              = settings.DisplayOnTop;
            Enable2Captcha.Checked            = settings.Enable2Captcha;
            EnableAntiCaptcha.Checked         = settings.EnableAntiCaptcha;
            AntiCaptchaAPIKey.Text            = settings.AntiCaptchaAPIKey;
            ProxyHostCaptcha.Text             = settings.ProxyHostCaptcha;
            ProxyPortCaptcha.Text             = settings.ProxyPortCaptcha.ToString();
            EnableCaptchaSolutions.Checked    = settings.EnableCaptchaSolutions;
            CaptchaSolutionAPIKey.Text        = settings.CaptchaSolutionAPIKey;
            CaptchaSolutionsSecretKey.Text    = settings.CaptchaSolutionsSecretKey;
            AutoCaptchaTimeout.Text           = settings.AutoCaptchaTimeout.ToString();
            AutoCaptchaRetries.Text           = settings.AutoCaptchaRetries.ToString();
            TwoCaptchaAPIKey.Text             = settings.TwoCaptchaAPIKey;
            checkBoxAutoFavShiny.Checked      = settings.AutoFavoritShiny;
            checkBoxSniperNoInPokedex.Checked = settings.SnipeAllPokemonsNoInPokedex;

            //Location time zones
            var zones = new TimeZoneIds().GetTimeZoneIds();

            foreach (var tz in zones)
            {
                cbTimeZones.Items.Add(tz.Key);
            }

            cbTimeZones.Text = _manager.UserSettings.TimeZone;

            for (int i = 0; i < comboBoxMinAccountState.Items.Count; i++)
            {
                if ((AccountState)comboBoxMinAccountState.Items[i] == settings.StopAtMinAccountState)
                {
                    comboBoxMinAccountState.SelectedIndex = i;
                    break;
                }
            }

            for (int i = 0; i < cbTeam.Items.Count; i++)
            {
                if (cbTeam.Items[i].ToString() == settings.DefaultTeam)
                {
                    cbTeam.SelectedIndex = i;
                    if (cbTeam.SelectedItem.ToString() != "Neutral" && !string.IsNullOrEmpty(settings.DefaultTeam))
                    {
                        cbTeam.Enabled = false;
                    }
                    break;
                }
            }
        }
Beispiel #8
0
        private void UpdateDetails(Settings settings)
        {
            textBoxPtcPassword.Text                = settings.Password;
            textBoxPtcUsername.Text                = settings.Username;
            textBoxLat.Text                        = settings.Location.Latitude.ToString();
            textBoxLong.Text                       = settings.Location.Longitude.ToString();
            textBoxName.Text                       = settings.AccountName;
            textBoxMaxTravelDistance.Text          = settings.MaxTravelDistance.ToString();
            textBoxWalkSpeed.Text                  = settings.WalkingSpeed.ToString();
            textBoxPokemonBeforeEvolve.Text        = settings.MinPokemonBeforeEvolve.ToString();
            textBoxMaxLevel.Text                   = settings.MaxLevel.ToString();
            textBoxProxy.Text                      = settings.Proxy.ToString();
            checkBoxMimicWalking.Checked           = settings.MimicWalking;
            checkBoxShufflePokestops.Checked       = settings.ShufflePokestops;
            checkBoxEncounterWhileWalking.Checked  = settings.EncounterWhileWalking;
            checkBoxRecycle.Checked                = settings.RecycleItems;
            checkBoxEvolve.Checked                 = settings.EvolvePokemon;
            checkBoxTransfers.Checked              = settings.TransferPokemon;
            checkBoxTransferSlashPokemons.Checked  = settings.TransferSlashPokemons;
            checkBoxUseLuckyEgg.Checked            = settings.UseLuckyEgg;
            checkBoxIncubateEggs.Checked           = settings.IncubateEggs;
            checkBoxOnlyUnlimitedIncubator.Checked = settings.OnlyUnlimitedIncubator;
            checkBoxCatchPokemon.Checked           = settings.CatchPokemon;
            numericUpDownRunForHours.Value         = new Decimal(settings.RunForHours);
            numericUpDownMaxLogs.Value             = settings.MaxLogs;
            numericUpDownMaxFailBeforeReset.Value  = settings.MaxFailBeforeReset;
            checkBoxStopOnIPBan.Checked            = settings.StopOnIPBan;
            checkBoxAutoRotateProxies.Checked      = settings.AutoRotateProxies;
            checkBoxRemoveOnStop.Checked           = settings.AutoRemoveOnStop;
            checkBoxClaimLevelUp.Checked           = settings.ClaimLevelUpRewards;
            numericUpDownSearchFortBelow.Value     = new Decimal(settings.SearchFortBelowPercent);
            numericUpDownForceEvolveAbove.Value    = new Decimal(settings.ForceEvolveAbovePercent);
            checkBoxStopOnAPIUpdate.Checked        = settings.StopOnAPIUpdate;
            checkBoxSpinGyms.Checked               = settings.SpinGyms;

            //Humanization
            checkBoxHumanizeThrows.Checked          = settings.EnableHumanization;
            numericUpDownInsideReticuleChance.Value = settings.InsideReticuleChance;

            numericUpDownGeneralDelay.Value       = settings.GeneralDelay;
            numericUpDownGeneralDelayRandom.Value = settings.GeneralDelayRandom;

            numericUpDownLocationUpdateDelay.Value  = settings.DelayBetweenLocationUpdates;
            numericUpDownLocationUpdateRandom.Value = settings.LocationupdateDelayRandom;

            numericUpDownPlayerActionDelay.Value    = settings.DelayBetweenPlayerActions;
            numericUpDownPlayerActionRandomiz.Value = settings.PlayerActionDelayRandom;

            numericUpDownWalkingOffset.Value = new Decimal(settings.WalkingSpeedOffset);
            //End humanization

            //Device settings
            textBoxDeviceId.Text             = settings.DeviceInfo.DeviceId;
            textBoxDeviceModel.Text          = settings.DeviceInfo.DeviceModel;
            textBoxDeviceBrand.Text          = settings.DeviceInfo.DeviceBrand;
            textBoxDeviceModelBoot.Text      = settings.DeviceInfo.DeviceModelBoot;
            textBoxFirmwareBrand.Text        = settings.DeviceInfo.FirmwareBrand;
            textBoxFirmwareType.Text         = settings.DeviceInfo.FirmwareType;
            textBoxHardwareManufacturer.Text = settings.DeviceInfo.HardwareManufacturer;
            textBoxHardwareModel.Text        = settings.DeviceInfo.HardwareModel;
            //End device settings

            //Api config
            cbHashHost.Text              = settings.HashHost.ToString();
            cbHashEndpoint.Text          = settings.HashEndpoint;
            tbAuthHashKey.Text           = settings.AuthAPIKey;
            cbUseOnlyThisHashKey.Checked = settings.UseOnlyOneKey;

            checkBoxUseBerries.Checked       = settings.UseBerries;
            checkBoxGetARBonus.Checked       = settings.GetArBonus;
            checkBoxCompleteTutorial.Checked = settings.CompleteTutorial;
            checkBoxTransferAtOnce.Checked   = settings.TransferAtOnce;
            numericUpDownProximity.Value     = settings.ARBonusProximity;
            numericUpDownAwareness.Value     = settings.ARBonusAwareness;

            cbUseOnlyThisHashKey.Checked         = _manager.UserSettings.UseOnlyOneKey;
            tbAuthHashKey.Text                   = _manager.UserSettings.AuthAPIKey;
            cbAutoUpdate.Checked                 = AutoUpdate;
            numericUpDownDisableCatchDelay.Value = new Decimal(_manager.UserSettings.DisableCatchDelay);

            checkBoxShowDebugLogs.Checked     = settings.ShowDebugLogs;
            checkBoxDownloadResources.Checked = settings.DownloadResources;


            //Location time zones
            var zones = new TimeZoneIds().GetTimeZoneIds();

            foreach (var tz in zones)
            {
                cbTimeZones.Items.Add(tz.Key);
            }

            cbTimeZones.Text = _manager.UserSettings.PlayerLocale.Timezone;

            for (int i = 0; i < comboBoxMinAccountState.Items.Count; i++)
            {
                if ((AccountState)comboBoxMinAccountState.Items[i] == settings.StopAtMinAccountState)
                {
                    comboBoxMinAccountState.SelectedIndex = i;
                    break;
                }
            }
        }
        private bool SaveSettings()
        {
            Settings userSettings = _manager.UserSettings;

            ProxyEx proxyEx = null;

            int maxLevel;

            if (!Int32.TryParse(textBoxMaxLevel.Text, out maxLevel) || maxLevel < 0)
            {
                MessageBox.Show("Invalid Max level", "Warning");
                return(false);
            }

            int minPokemonBeforeEvolve;

            if (!Int32.TryParse(textBoxPokemonBeforeEvolve.Text, out minPokemonBeforeEvolve) || minPokemonBeforeEvolve < 0)
            {
                MessageBox.Show("Invalid pokemon before evolve", "Warning");
                return(false);
            }
            int walkingSpeed;

            if (!Int32.TryParse(textBoxWalkSpeed.Text, out walkingSpeed) || walkingSpeed <= 0)
            {
                MessageBox.Show("Invalid walking speed", "Warning");
                return(false);
            }
            int maxTravelDistance;

            if (!Int32.TryParse(textBoxMaxTravelDistance.Text, out maxTravelDistance) || maxTravelDistance <= 0)
            {
                MessageBox.Show("Invalid max travel distance", "Warning");
                return(false);
            }
            double defaultLat;

            if (!Double.TryParse(textBoxLat.Text.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out defaultLat))
            {
                MessageBox.Show("Invalid latitude", "Warning");
                return(false);
            }
            double defaultLong;

            if (!Double.TryParse(textBoxLong.Text.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out defaultLong))
            {
                MessageBox.Show("Invalid longitude", "Warning");
                return(false);
            }

            if (!String.IsNullOrEmpty(textBoxProxy.Text) && !ProxyEx.TryParse(textBoxProxy.Text, out proxyEx))
            {
                MessageBox.Show("Invalid proxy format", "Warning");
                return(false);
            }

            if (comboBoxMinAccountState.SelectedItem == null)
            {
                MessageBox.Show("Please select a valid min account state", "Warning");
                return(false);
            }

            if (walkingSpeed < (double)numericUpDownWalkingOffset.Value)
            {
                MessageBox.Show("Walking offset must be more than walking speed", "Warning");
                return(false);
            }

            userSettings.AuthType = textBoxPtcUsername.Text.Contains("@") ?  AuthType.Google : AuthType.Ptc;

            userSettings.MimicWalking            = checkBoxMimicWalking.Checked;
            userSettings.Username                = textBoxPtcUsername.Text.Trim();
            userSettings.Password                = textBoxPtcPassword.Text.Trim();
            userSettings.DefaultLatitude         = defaultLat;
            userSettings.DefaultLongitude        = defaultLong;
            userSettings.WalkingSpeed            = walkingSpeed;
            userSettings.MaxTravelDistance       = maxTravelDistance;
            userSettings.EncounterWhileWalking   = checkBoxEncounterWhileWalking.Checked;
            userSettings.AccountName             = textBoxName.Text;
            userSettings.TransferPokemon         = checkBoxTransfers.Checked;
            userSettings.EvolvePokemon           = checkBoxEvolve.Checked;
            userSettings.RecycleItems            = checkBoxRecycle.Checked;
            userSettings.MinPokemonBeforeEvolve  = minPokemonBeforeEvolve;
            userSettings.UseLuckyEgg             = checkBoxUseLuckyEgg.Checked;
            userSettings.IncubateEggs            = checkBoxIncubateEggs.Checked;
            userSettings.MaxLevel                = maxLevel;
            userSettings.CatchPokemon            = checkBoxCatchPokemon.Checked;
            userSettings.StopAtMinAccountState   = (AccountState)comboBoxMinAccountState.SelectedItem;
            userSettings.SearchFortBelowPercent  = (double)numericUpDownSearchFortBelow.Value;
            userSettings.ForceEvolveAbovePercent = (double)numericUpDownForceEvolveAbove.Value;
            userSettings.ClaimLevelUpRewards     = checkBoxClaimLevelUp.Checked;
            userSettings.StopOnAPIUpdate         = checkBoxStopOnAPIUpdate.Checked;
            userSettings.SpinGyms                = checkBoxSpinGyms.Checked;
            AutoUpdate = cbAutoUpdate.Checked;
            userSettings.UseBerries = checkBoxUseBerries.Checked;

            userSettings.RunForHours        = (double)numericUpDownRunForHours.Value;
            userSettings.MaxLogs            = (int)numericUpDownMaxLogs.Value;
            userSettings.StopOnIPBan        = checkBoxStopOnIPBan.Checked;
            userSettings.MaxFailBeforeReset = (int)numericUpDownMaxFailBeforeReset.Value;
            userSettings.AutoRotateProxies  = checkBoxAutoRotateProxies.Checked;
            userSettings.AutoRemoveOnStop   = checkBoxRemoveOnStop.Checked;

            //Humanization
            userSettings.EnableHumanization   = checkBoxHumanizeThrows.Checked;
            userSettings.InsideReticuleChance = (int)numericUpDownInsideReticuleChance.Value;

            userSettings.GeneralDelay       = (int)numericUpDownGeneralDelay.Value;
            userSettings.GeneralDelayRandom = (int)numericUpDownGeneralDelayRandom.Value;

            userSettings.DelayBetweenLocationUpdates = (int)numericUpDownLocationUpdateDelay.Value;
            userSettings.LocationupdateDelayRandom   = (int)numericUpDownLocationUpdateRandom.Value;

            userSettings.DelayBetweenPlayerActions = (int)numericUpDownPlayerActionDelay.Value;
            userSettings.PlayerActionDelayRandom   = (int)numericUpDownPlayerActionRandomiz.Value;

            userSettings.WalkingSpeedOffset = (double)numericUpDownWalkingOffset.Value;
            //End humanization

            //Device settings
            userSettings.DeviceId             = textBoxDeviceId.Text;
            userSettings.DeviceModel          = textBoxDeviceModel.Text;
            userSettings.DeviceBrand          = textBoxDeviceBrand.Text;
            userSettings.DeviceModelBoot      = textBoxDeviceModelBoot.Text;
            userSettings.FirmwareBrand        = textBoxFirmwareBrand.Text;
            userSettings.FirmwareType         = textBoxFirmwareType.Text;
            userSettings.HardwareManufacturer = textBoxHardwareManufacturer.Text;
            userSettings.HardwareModel        = textBoxHardwareModel.Text;
            //End device settings

            //Api config
            userSettings.HashHost      = new Uri(cbHashHost.Text);
            userSettings.HashEndpoint  = cbHashEndpoint.Text;
            userSettings.AuthAPIKey    = tbAuthHashKey.Text;
            userSettings.UseOnlyOneKey = cbUseOnlyThisHashKey.Checked;
            //End api config

            //Location time zones
            var x = new TimeZoneIds().GetTimeZoneIds();

            userSettings.TimeZone = cbTimeZones.Text;
            userSettings.Country  = x[cbTimeZones.Text].Item1;
            userSettings.Language = x[cbTimeZones.Text].Item2;
            userSettings.POSIX    = x[cbTimeZones.Text].Item3;
            //End location time zones

            if (proxyEx != null)
            {
                userSettings.ProxyIP       = proxyEx.Address;
                userSettings.ProxyPort     = proxyEx.Port;
                userSettings.ProxyUsername = proxyEx.Username;
                userSettings.ProxyPassword = proxyEx.Password;
            }
            else
            {
                userSettings.ProxyUsername = null;
                userSettings.ProxyPassword = null;
                userSettings.ProxyIP       = null;
                userSettings.ProxyPort     = 0;
            }

            return(true);
        }