private static void Main() { var culture = CultureInfo.CreateSpecificCulture("en-US"); CultureInfo.DefaultThreadCurrentCulture = culture; Thread.CurrentThread.CurrentCulture = culture; AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs eargs) { Exception exception = (Exception)eargs.ExceptionObject; System.Console.WriteLine(@"Unhandled exception: " + exception); Environment.Exit(1); }; ServicePointManager.ServerCertificateValidationCallback = Validator; Logger.SetLogger(); if (File.Exists(XmlSettings._configsFile)) { // Load the settings from the config file // If the current program is not the latest version, ensure we skip saving the file after loading // This is to prevent saving the file with new options at their default values so we can check for differences XmlSettings.LoadSettings(); } else { XmlSettings.CreateSettings(new Settings()); } Task.Run(() => { try { new Logic.Logic(new Settings()).Execute().Wait(); } catch (PtcOfflineException) { Logger.Write("PTC Servers are probably down OR your credentials are wrong. Try google", LogLevel.Error); Logger.Write("Trying again in 60 seconds..."); Thread.Sleep(60000); new Logic.Logic(new Settings()).Execute().Wait(); } catch (AccountNotVerifiedException) { Logger.Write("Account not verified. - Exiting"); Environment.Exit(0); } catch (Exception ex) { Logger.Write($"Unhandled exception: {ex}", LogLevel.Error); new Logic.Logic(new Settings()).Execute().Wait(); } }); System.Console.ReadLine(); }
private void Form1_Load(object sender, System.EventArgs e) { bf = new BinaryFormatter(); AppDir = Path.GetDirectoryName(Application.ExecutablePath); xs = new XmlSettings(Path.GetFileNameWithoutExtension(Application.ExecutablePath)); xs.LoadSettings(Path.Combine(AppDir, "settings.xml")); SetPosAndSize(); turPath = xs.ReadSetting(Setting.LastFile, String.Empty); RestoreTurnir(turPath); tabControl1.SelectedIndex = xs.ReadSetting(Setting.LastTab, 0); var ti = xs.ReadSetting(Setting.TableIndex, 0); cbTable.SelectedIndex = ti < cbTable.Items.Count ? ti : 0; }