protected override void OnStartup(StartupEventArgs e) { //Check Version var newVersion = GitChecker.CheckNewVersion(); if (newVersion != null) { var result = MessageBox.Show($"There's a new Version available {newVersion.ToString()}\n Download it now?", "New Version", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (result == MessageBoxResult.Yes) { System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest"); } Application.Current.Shutdown(); } // get the theme from the current application var theme = ThemeManager.DetectAppStyle(Application.Current); // now set the Green accent and dark theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(GUI.Properties.Settings.Default.Accent), ThemeManager.GetAppTheme(GUI.Properties.Settings.Default.Theme)); base.OnStartup(e); }
public void IfCommintInDevelopYesterday_IsInValid() { var repo = CreateRepository(); //master CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-2)); repo.CreateBranch("develop"); repo.Checkout("develop"); CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-2)); repo.CreateBranch("feature/test"); repo.Checkout("feature/test"); CreateAndAddFile(repo); var yesterday = DateTimeOffset.Now.AddDays(-1); MakeCommit(repo, yesterday); repo.Checkout("develop"); CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-1));//yesterday repo.Checkout("feature/test"); var checker = new GitChecker(repo); //act var isValid = checker.IsValid(); Assert.That(isValid, Is.False); }
public void AfterMerge_IsValid() { var repo = CreateRepository(); //master CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-2)); repo.CreateBranch("develop"); repo.Checkout("develop"); CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-2)); repo.CreateBranch("feature/test"); repo.Checkout("feature/test"); CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now.AddDays(-1)); repo.Checkout("develop"); CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now); //merge repo.Checkout("feature/test"); repo.Merge(repo.Branches["develop"], new Signature("test", "*****@*****.**", DateTimeOffset.Now)); var checker = new GitChecker(repo); //act var isValid = checker.IsValid(); Assert.That(isValid, Is.True); }
public void IfMaster_Pass() { var repo = CreateRepository(); //master is head CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now); var checker = new GitChecker(repo); //act var isValid = checker.IsValid(); Assert.That(isValid, Is.True); }
public void IfDevelop_Pass() { var repo = CreateRepository(); //master CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now); repo.CreateBranch("develop"); repo.Checkout("develop"); //develop is head CreateAndAddFile(repo); MakeCommit(repo, DateTimeOffset.Now); var checker = new GitChecker(repo); //act var isValid = checker.IsValid(); Assert.That(isValid, Is.True); }
static void Main2() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Check Version var newVersion = GitChecker.CheckNewVersion(); if (newVersion != null) { var result = MessageBox.Show($"There's a new Version available {newVersion.ToString()}\n Download it now?", "New Version", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest"); } Application.Exit(); } Application.Run(new Main()); }
public async Task Execute() { if (!_isInitialized) { GitChecker.CheckVersion(); var latLngFromFile = PositionCheckState.LoadPositionFromDisk(); if (latLngFromFile != null && Math.Abs(latLngFromFile.Item1) > 0 && Math.Abs(latLngFromFile.Item2) > 0) { _client.Player.SetCoordinates(latLngFromFile.Item1, latLngFromFile.Item2, _client.Settings.DefaultAltitude); } else { _client.Player.SetCoordinates(_client.Settings.DefaultLatitude, _client.Settings.DefaultLongitude, _client.Settings.DefaultAltitude); } if (Math.Abs(_clientSettings.DefaultLatitude) <= 0 || Math.Abs(_clientSettings.DefaultLongitude) <= 0) { Logger.Write($"Please change first Latitude and/or Longitude because currently your using default values!", LogLevel.Error); for (int i = 3; i > 0; i--) { Logger.Write($"Bot will close in {i * 5} seconds!", LogLevel.Warning); await Task.Delay(5000); } Environment.Exit(1); } else { Logger.Write($"Make sure Lat & Lng is right. Exit Program if not! Lat: {_client.CurrentLatitude} Lng: {_client.CurrentLongitude}", LogLevel.Warning); for (int i = 3; i > 0; i--) { Logger.Write($"Bot will continue in {i * 5} seconds!", LogLevel.Warning); await Task.Delay(5000); } } } Logger.Write($"Logging in via: {_clientSettings.AuthType}", LogLevel.Info); while (true) { try { switch (_clientSettings.AuthType) { case AuthType.Ptc: await _client.Login.DoLogin(); break; case AuthType.Google: await _client.Login.DoLogin(); break; default: Logger.Write("wrong AuthType"); Environment.Exit(0); break; } await PostLoginExecute(); } catch (AccountNotVerifiedException) { Logger.Write("Account not verified! Exiting...", LogLevel.Error); await Task.Delay(5000); Environment.Exit(0); } catch (GoogleException e) { if (e.Message.Contains("NeedsBrowser")) { Logger.Write("As you have Google Two Factor Auth enabled, you will need to insert an App Specific Password into the UserSettings.", LogLevel.Error); Logger.Write("Opening Google App-Passwords. Please make a new App Password (use Other as Device)", LogLevel.Error); await Task.Delay(7000); try { Process.Start("https://security.google.com/settings/security/apppasswords"); } catch (Exception) { Logger.Write("https://security.google.com/settings/security/apppasswords"); throw; } } Logger.Write("Make sure you have entered the right Email & Password.", LogLevel.Error); await Task.Delay(5000); Environment.Exit(0); } catch (InvalidProtocolBufferException ex) when(ex.Message.Contains("SkipLastField")) { Logger.Write("Connection refused. Your IP might have been Blacklisted by Niantic. Exiting..", LogLevel.Error); await Task.Delay(5000); Environment.Exit(0); } catch (Exception e) { Logger.Write(e.Message + " from " + e.Source); Logger.Write("Error, trying automatic restart..", LogLevel.Error); await Execute(); } await Task.Delay(10000); } }
static int Main2(string[] args) { try { #if DEBUG System.Diagnostics.Debugger.Launch(); #endif string invokedVerb = ""; object invokedVerbInstance = ""; var options = new Options(); if (!CommandLine.Parser.Default.ParseArguments(args, options, (verb, subOptions) => { // if parsing succeeds the verb name and correct instance // will be passed to onVerbCommand delegate (string,object) invokedVerb = verb.ToLower(); invokedVerbInstance = subOptions; })) { Environment.Exit(CommandLine.Parser.DefaultExitCodeFail); } var version = Assembly.GetExecutingAssembly().GetName().Version; ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Yellow, $"WoTget Version: {version.ToString()}"); var newVersion = GitChecker.CheckNewVersion(); if (newVersion != null) { ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Red, $"New WoTget Version: {newVersion.ToString()}"); System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest"); return(0); } AddConsoleAppender(invokedVerbInstance is BaseSubOptions && ((BaseSubOptions)invokedVerbInstance).Verbose ? Level.Debug : Level.Info); WoTget.Application.InitializeInstance((string)JsonConfig.Config.Global.GoogleKeyFile); App = Application.Instance; if (invokedVerb == "init") { return(InitCommand((InitSubOptions)invokedVerbInstance)); } if (!App.IsDatabaseInitialized() && invokedVerb != "init") { Console.WriteLine(); ConsoleHelper.ColoredConsoleWrite(ConsoleColor.Yellow, $"What's your WoT Game Directory? (Default:C:\\Games\\World_of_Tanks):"); string wotDirectory = Console.ReadLine(); if (string.IsNullOrEmpty(wotDirectory)) { wotDirectory = "C:\\Games\\World_of_Tanks"; } var returnValue = InitCommand(new InitSubOptions { WotGameDirectory = wotDirectory }); if (returnValue == 1) { return(1); } } ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Green, $"WoT Version: '{App.GetWotVersion()}' Game Directory: '{App.GetWotHome()}'"); Console.WriteLine(""); if (invokedVerb == "list") { return(ListCommand((ListSubOptions)invokedVerbInstance)); } if (invokedVerb == "install") { return(InstallCommand((InstallSubOptions)invokedVerbInstance)); } if (invokedVerb == "update") { return(UpdateCommand((UpdateSubOptions)invokedVerbInstance)); } if (invokedVerb == "uninstall") { return(UninstallCommand((UninstallSubOptions)invokedVerbInstance)); } //Package Managment Commands if (invokedVerb == "add") { return(AddCommand((AddSubOptions)invokedVerbInstance)); } if (invokedVerb == "remove") { return(RemoveCommand((RemoveSubOptions)invokedVerbInstance)); } } catch (Exception ex) { Console.Error.WriteLine(ex.ToString()); return(1); } return(0); }
private void GUI_Load(object sender, EventArgs e) { // Instantiate the writer _writer = new TextBoxStreamWriter(txtConsole); // Redirect the out Console stream Console.SetOut(_writer); GitChecker.CheckVersion(); Logger.Write($"Initializing Bot..."); Button_Start.Visible = true; Button_Stop.Visible = false; ComboBox_AuthType.SelectedItem = ConfigurationManager.AppSettings["AuthType"]; TextBox_UserNameOrEmail.Text = ConfigurationManager.AppSettings["UserNameOrEmail"]; TextBox_UserPassword.Text = ConfigurationManager.AppSettings["UserPassword"]; TextBot_Latitude.Text = ConfigurationManager.AppSettings["DefaultLatitude"]; TextBot_Longitude.Text = ConfigurationManager.AppSettings["DefaultLongitude"]; TextBot_Altitude.Text = ConfigurationManager.AppSettings["DefaultAltitude"]; gmap.Position = new PointLatLng(Convert.ToDouble(ConfigurationManager.AppSettings["DefaultLatitude"]), Convert.ToDouble(ConfigurationManager.AppSettings["DefaultLongitude"])); OnOff_UseProxy.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UseProxy"]); TextBox_ProxyHost.Text = ConfigurationManager.AppSettings["ProxyHost"]; NumUpDown_ProxyPort.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["ProxyPort"]); TextBox_ProxyUsername.Text = ConfigurationManager.AppSettings["ProxyUsername"]; TextBox_ProxyPassword.Text = ConfigurationManager.AppSettings["ProxyPassword"]; OnOff_UseCSVExport.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UseCSVExport"]); NumUpDown_CSVExportInMinutes.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["CSVExportInMinutes"]); ComboBox_MovementType.SelectedItem = ConfigurationManager.AppSettings["MovementBy"]; NumUpDown_WalkingSpeed.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["WalkingSpeedInKilometerPerHour"]); NumUpDown_MaxTravelDistance.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["MaxTravelDistanceInMeters"]); TextBot_GPXFile.Text = ConfigurationManager.AppSettings["GPXFile"]; OnOff_GPXIgnorePokestops.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["GPXIgnorePokestops"]); OnOff_CatchMapPokemon.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["CatchMapPokemon"]); OnOff_CatchIncensePokemon.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["CatchIncensePokemon"]); OnOff_CatchLuredPokemon.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["CatchLuredPokemon"]); OnOff_ToNotCatchList.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePokemonToNotCatchList"]); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["PokemonToNotCatchList"])) { ConfigurationManager.AppSettings["PokemonToNotCatchList"].Split(',') .ToList() .ForEach(item => { var index = checkedList_ToNotCatchList.Items.IndexOf(item); checkedList_ToNotCatchList.SetItemChecked(index, true); }); } OnOff_EvolvePokemon.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["EvolvePokemon"]); OnOff_ToEvolveList.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePokemonToEvolveList"]); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["PokemonToEvolveList"])) { ConfigurationManager.AppSettings["PokemonToEvolveList"].Split(',') .ToList() .ForEach(item => { var index = checkedList_ToEvolveList.Items.IndexOf(item); checkedList_ToEvolveList.SetItemChecked(index, true); }); } OnOff_TransferPokemon.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["TransferPokemon"]); OnOff_ToNotTransferList.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UsePokemonToNotTransferList"]); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["PokemonToNotTransferList"])) { ConfigurationManager.AppSettings["PokemonToNotTransferList"].Split(',') .ToList() .ForEach(item => { var index = checkedList_ToNotTransferList.Items.IndexOf(item); checkedList_ToNotTransferList.SetItemChecked(index, true); }); } ComboBox_DeviceType.SelectedItem = ConfigurationManager.AppSettings["DeviceType"]; ComboBox_PreconfiguredDevices.SelectedItem = ConfigurationManager.AppSettings["DevicePackageName"]; if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["DeviceId"]) || ConfigurationManager.AppSettings["DeviceId"] == "8525f5d8201f78b5") { ConfigurationManager.AppSettings["DeviceId"] = RandomHelper.RandomString(16, "0123456789abcdef"); } TextBox_DeviceId.Text = ConfigurationManager.AppSettings["DeviceId"]; TextBox_AndroidBoardName.Text = ConfigurationManager.AppSettings["AndroidBoardName"]; TextBox_AndroidBootloader.Text = ConfigurationManager.AppSettings["AndroidBootloader"]; TextBox_DeviceBrand.Text = ConfigurationManager.AppSettings["DeviceBrand"]; TextBox_DeviceModel.Text = ConfigurationManager.AppSettings["DeviceModel"]; TextBox_DeviceModelIdentifier.Text = ConfigurationManager.AppSettings["DeviceModelIdentifier"]; TextBox_DeviceModelBoot.Text = ConfigurationManager.AppSettings["DeviceModelBoot"]; TextBox_HardwareManufacturer.Text = ConfigurationManager.AppSettings["HardwareManufacturer"]; TextBox_HardwareModel.Text = ConfigurationManager.AppSettings["HardwareModel"]; TextBox_FirmwareBrand.Text = ConfigurationManager.AppSettings["FirmwareBrand"]; TextBox_FirmwareTags.Text = ConfigurationManager.AppSettings["FirmwareTags"]; TextBox_FirmwareType.Text = ConfigurationManager.AppSettings["FirmwareType"]; TextBox_FirmwareFingerprint.Text = ConfigurationManager.AppSettings["FirmwareFingerprint"]; OnOff_LogOut_Runtime.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["LogOut_Runtime"]); NumUpDown_LogOut_Runtime.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["LogOut_Runtime_Value"]); OnOff_LogOut_LevelReached.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["LogOut_LevelReached"]); NumUpDown_LogOut_LevelReached.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["LogOut_LevelReached_Value"]); OnOff_LogOut_PokemonCaught.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["LogOut_PokemonCaught"]); NumUpDown_LogOut_PokemonCaught.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["LogOut_PokemonCaught_Value"]); OnOff_LogOut_PokestopsVisit.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["LogOut_PokestopsVisit"]); NumUpDown_LogOut_PokestopsVisit.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["LogOut_PokestopsVisit_Value"]); OnOff_DebugMode.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["DebugMode"]); Logger.Write($"Initializing Bot completed..."); }