Ejemplo n.º 1
0
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     Logging.Log("Mahou started.");
     //Catch any error during program runtime
     AppDomain.CurrentDomain.UnhandledException += (obj, arg) => {
         var e = (Exception)arg.ExceptionObject;
         Logging.Log("Unexpected error occured, Mahou exitted, error details:\r\n" + e.Message + "\r\n" + e.StackTrace, 1);
     };
     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
     using (var mutex = new Mutex(false, "Global\\" + appGUid)) {
         if (!mutex.WaitOne(0, false))
         {
             KMHook.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (locales.Length < 2)
         {
             Logging.Log("Too less layouts/locales. Program will exit.");
             Locales.IfLessThan2();
         }
         else
         {
             mahou = new MahouForm();
             InitLanguage();
             //Refreshes icon text language at startup
             mahou.icon.RefreshText(MMain.UI[44], MMain.UI[42], MMain.UI[43]);
             KMHook.ReInitSnippets();
             Application.EnableVisualStyles();                     // Huh i did not noticed that it was missing... '~'
             if (args.Length != 0)
             {
                 if (args[0] == "_!_updated_!_")
                 {
                     Logging.Log("Mahou updated.");
                     mahou.ToggleVisibility();
                     MessageBox.Show(Msgs[0], Msgs[1], MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             StartHook();
             //for first run, add your locale 1 & locale 2 to settings
             if (MyConfs.Read("Locales", "locale1Lang") == "" && MyConfs.Read("Locales", "locale2Lang") == "")
             {
                 Logging.Log("Initializing locales.");
                 MyConfs.Write("Locales", "locale1uId", locales[0].uId.ToString());
                 MyConfs.Write("Locales", "locale2uId", locales[1].uId.ToString());
                 MyConfs.Write("Locales", "locale1Lang", locales[0].Lang);
                 MyConfs.Write("Locales", "locale2Lang", locales[1].Lang);
             }
             Application.Run();
             StopHook();
         }
     }
 }
Ejemplo n.º 2
0
 [STAThread]         //DO NOT REMOVE THIS
 public static void Main(string[] args)
 {
     LogHelper.ConfigureNlog();
     log.Trace("Program start");
     using (var mutex = new Mutex(false, "Global\\" + appGUid)) {
         log.Trace("Mutex created");
         if (!mutex.WaitOne(0, false))
         {
             KMHook.PostMessage((IntPtr)0xffff, ao, 0, 0);
             return;
         }
         if (locales.Length < 2)
         {
             Locales.IfLessThan2();
         }
         else
         {
             mahou = new MahouForm();
             InitLanguage();
             //Refreshes icon text language at startup
             mahou.icon.RefreshText(MMain.UI[44], MMain.UI[42], MMain.UI[43]);
             KMHook.ReInitSnippets();
             Application.EnableVisualStyles();                     // Huh i did not noticed that it was missing... '~'
             if (args.Length != 0)
             {
                 if (args[0] == "_!_updated_!_")
                 {
                     mahou.ToggleVisibility();
                     MessageBox.Show(Msgs[0], Msgs[1], MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             StartHook();
             //for first run, add your locale 1 & locale 2 to settings
             if (MyConfs.Read("Locales", "locale1Lang") == "" && MyConfs.Read("Locales", "locale2Lang") == "")
             {
                 MyConfs.Write("Locales", "locale1uId", locales[0].uId.ToString());
                 MyConfs.Write("Locales", "locale2uId", locales[1].uId.ToString());
                 MyConfs.Write("Locales", "locale1Lang", locales[0].Lang);
                 MyConfs.Write("Locales", "locale2Lang", locales[1].Lang);
             }
             try {
                 Application.Run();
             } catch (Exception ex) {
                 log.Fatal(ex, "Global error handler caught the exception in app");
             }
             StopHook();
         }
     }
 }