static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Set the unhandled exception mode to force all Windows Forms errors // to go through our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // set higher priority Process.GetCurrentProcess().PriorityBoostEnabled = true; Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; // Of course this only affects the main thread rather than child threads. Thread.CurrentThread.Priority = MainFunctions.threadPriority; // do this before creating Main Form as the loading screen will be displayed unnecessarily if (SingleApplication.IsAlreadyRunning()) { LAWC.NativeMethods.SendNotifyMessage( (IntPtr)LAWC.NativeMethods.HWND_BROADCAST, SingleApplication.WMSHOWFIRSTINSTANCE, IntPtr.Zero, IntPtr.Zero); //set focus on previously running app SingleApplication.SwitchToCurrentInstance(); return; } try { Application.Run(new FrmMain(args)); } catch (Exception ex) { MessageBox.Show(ex.InnerException.Message + "\n\n\n\n" + ex.Message); MessageBox.Show("Well, this is embarassing. Something went wrong... \n\n" + "Try starting up LAWC again. Also check the Error Log (in Advanced Settings)\n\n" + "Error: " + ex.Message.ToString(CultureInfo.InvariantCulture) + "\n\n" + ex.StackTrace.ToString(CultureInfo.InvariantCulture) + "\n\n" + ex.Source.ToString(CultureInfo.InvariantCulture), "LAWC Crashed", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //TipsForm.ShowTipSlide(UserConfigKey.Tips_ChangeNumber); #if !DEBUG if (SingleApplication.IsAlreadyRunning()) { MessageBox.Show(string.Format(LangResource.already_running, Application.ProductName), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endif //new SettingForm().ShowDialog(); string lang = ConfigurationManager.Instance.GetCurrentUserSetting(UserConfigKey.User_Language, string.Empty); if (lang != string.Empty) { try { LangResource.Culture = new CultureInfo(lang); } catch { } } // check startup setting if (RegistryToolkit.IsStartupProcessExists(Application.ProductName)) { // update startup shortcut to current exe file RegistryToolkit.SetStartupProcess(Application.ProductName, Application.ExecutablePath); } int startOperation = ConfigurationManager.Instance.GetCurrentUserSettingIntValue( UserConfigKey.User_StartOperation, 0); switch (startOperation) { default: case 0: // run in background Application.Run(new MainForm(true, args)); break; case 1: // start capture Thread.Sleep(200); ShortcutActionManager.Instance.DoActionById((int)ActionIds.CaptureRegionOfScreen_Clipboard); ConfigurationManager.Instance.SaveCurrentUserConfiguration(); break; case 2: // image editor new MainForm(false, args); new EditorForm().ShowDialog(); ConfigurationManager.Instance.SaveCurrentUserConfiguration(); break; } //new EditTextForm().ShowDialog(); //Application.Run(new MainForm(args)); ResourcePoolManager.Instance.ReleaseAllResources(); }