static void Main() { // Allow only one instance to be run if (!SingleInstance.Start()) { SingleInstance.ShowFirstInstance(); return; } // Run as admin check IsRunAsAdmin = (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)); // Get Commandline args CommandLineArgs.Get(); // Load settings BotSettings.Instance.Load(); Settings.Default.Reload(); if (Settings.Default.AutoPosScreens == null || (Settings.Default.AutoPosScreens != null && Settings.Default.AutoPosScreens.Count == 0)) { AutoPosition.UpdateScreens(); } if (Settings.Default.D3StarterPath.Equals(string.Empty) || Settings.Default.D3StarterPath.Equals("")) { Settings.Default.D3StarterPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ThirdParty\\D3Starter.exe"); } // Start background thread Relogger.Instance.Start(); if (Settings.Default.FocusCheck) { ForegroundChecker.Instance.Start(); } var comms = new Communicator(); comms.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Mainform = new MainForm2(); Application.Run(Mainform); // Clean up SingleInstance.Stop(); Settings.Default.Save(); Logger.Instance.WriteGlobal("Closed!"); Logger.Instance.ClearBuffer(); }
private static void Main() { try { // Allow only one instance to be run if (!SingleInstance.Start()) { SingleInstance.ShowFirstInstance(); return; } // Run as admin check WindowsIdentity identity = WindowsIdentity.GetCurrent(); if (identity != null) { IsRunAsAdmin = (new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator)); } // Get Commandline args CommandLineArgs.Get(); if (CommandLineArgs.SafeMode) { DialogResult result = MessageBox.Show("Launching in safe mode!\nThis will reset some features", "YetAnotherRelogger Safe Mode", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return; } } // Load settings BotSettings.Instance.Load(); Settings.Default.Reload(); Settings.Default.Upgrade(); if (Settings.Default.AutoPosScreens == null || (Settings.Default.AutoPosScreens != null && Settings.Default.AutoPosScreens.Count == 0)) { AutoPosition.UpdateScreens(); } // Start background threads Relogger.Instance.Start(); Communicator.Instance.Start(); if (!CommandLineArgs.SafeMode) { if (Settings.Default.StatsEnabled) { StatsUpdater.Instance.Start(); } if (Settings.Default.FocusCheck) { ForegroundChecker.Instance.Start(); } } else { Settings.Default.StatsEnabled = false; Settings.Default.FocusCheck = false; AutoPosition.UpdateScreens(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Mainform = new MainForm2(); Application.Run(Mainform); } catch (Exception ex) { Logger.Instance.WriteGlobal(ex.ToString()); } // Clean up SingleInstance.Stop(); Settings.Default.Save(); Logger.Instance.WriteGlobal("Closed!"); Logger.Instance.ClearBuffer(); }