static void Main() { // Startup #if !DEBUG AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; #endif Properties.Resources.Culture = CultureInfo.CurrentCulture; InfoManager = new WzInformationManager(); SettingsManager = new WzSettingsManager(GetLocalSettingsPath(), typeof(UserSettings), typeof(ApplicationSettings), typeof(Microsoft.Xna.Framework.Color)); SettingsManager.Load(); MultiBoard.RecalculateSettings(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Program run here GUI.Initialization initForm = new GUI.Initialization(); Application.Run(initForm); // Shutdown if (initForm.editor != null) { initForm.editor.hcsm.backupMan.ClearBackups(); } SettingsManager.Save(); if (Restarting) { Application.Restart(); } }
public static bool PrepareApplication(bool from_internal) { SettingsManager = new WzSettingsManager(GetLocalSettingsPath(), typeof(UserSettings), typeof(ApplicationSettings)); bool loaded = false; for (int i = 0; i < 5; i++) { try { SettingsManager.Load(); loaded = true; break; } catch { Thread.Sleep(1000); } } if (!loaded) { Warning.Error(HaRepacker.Properties.Resources.ProgramLoadSettingsError); return(true); } bool firstRun = ApplicationSettings.FirstRun; if (ApplicationSettings.FirstRun) { //new FirstRunForm().ShowDialog(); ApplicationSettings.FirstRun = false; SettingsManager.Save(); } if (UserSettings.AutoAssociate && from_internal && IsUserAdministrator()) { string path = Application.ExecutablePath; Registry.ClassesRoot.CreateSubKey(".wz").SetValue("", "WzFile"); RegistryKey wzKey = Registry.ClassesRoot.CreateSubKey("WzFile"); wzKey.SetValue("", "Wz File"); wzKey.CreateSubKey("DefaultIcon").SetValue("", path + ",1"); wzKey.CreateSubKey("shell\\open\\command").SetValue("", "\"" + path + "\" \"%1\""); } return(firstRun); }
public static bool PrepareApplication() { SettingsManager = new WzSettingsManager(System.IO.Path.Combine(Application.StartupPath, "HRSettings.wz"), typeof(UserSettings), typeof(ApplicationSettings)); int tryCount = 0; tryagain: try { SettingsManager.Load(); } catch { tryCount++; if (tryCount < 5) { Thread.Sleep(1000); goto tryagain; } else { Warning.Error("Could not load settings file, make sure it is not in use. If it is not, delete it and try again."); return(true); } } bool firstRun = ApplicationSettings.FirstRun; if (ApplicationSettings.FirstRun) { new FirstRunForm().ShowDialog(); ApplicationSettings.FirstRun = false; SettingsManager.Save(); } if (UserSettings.AutoAssociate) { string path = Application.ExecutablePath; Registry.ClassesRoot.CreateSubKey(".wz").SetValue("", "WzFile"); RegistryKey wzKey = Registry.ClassesRoot.CreateSubKey("WzFile"); wzKey.SetValue("", "Wz File"); wzKey.CreateSubKey("DefaultIcon").SetValue("", path + ",1"); wzKey.CreateSubKey("shell\\open\\command").SetValue("", "\"" + path + "\" \"%1\""); } return(firstRun); }
static void Main() { SelfCheck(); InfoManager = new WzInformationManager(); SettingsManager = new WzSettingsManager(System.IO.Path.Combine(Application.StartupPath, "HCSettings.wz"), typeof(UserSettings), typeof(ApplicationSettings), typeof(Microsoft.Xna.Framework.Color)); SettingsManager.Load(); MultiBoard.RecalculateSettings(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG try { Application.Run(new GUI.Initialization()); } catch (Exception e) { Application.Run(new ExceptionHandler(e)); } #else Application.Run(new GUI.Initialization()); #endif SettingsManager.Save(); }