예제 #1
0
        internal static void Main(string[] args)
        {
#if !DEBUG
            // Only allows starting from launcher, because otherwise:
            //   * if the current one is not the latest version, data loss might occur because of
            //     the updater.
            //   * the launcher start this program with admin permission. Without this
            //     some issues may occur.

            try
            {
                var latest = UsingLatestVersion();
                if (!latest || !Windows.IsAdministrator())
                {
                    MsgBoxHelper.ShowError(null, "Please start QSimPlanner via Launcher.exe.");
                    return;
                }
            }
            catch (Exception e)
            {
                MsgBoxHelper.ShowError(null, "An error occurred.\n" + e.Message);
                return;
            }
#endif
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            using (var mutex = new Mutex(false, $"Global\\{GetGuid()}"))
            {
                if (!mutex.WaitOne(0, false))
                {
                    MsgBoxHelper.ShowError(null, "QSimPlanner is already running.");
                    return;
                }

                config = XDocument.Load("./config.xml").Root;
#if !DEBUG
                // We want the debugger to break when having an unhandled exception.
                SetExceptionHandler();
#endif
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
#if !DEBUG
                UpdateOnFirstRun();
                MoveNavData();
#endif

                ShowLicenseIfNeeded();
                WebRequests.SetSecuityProtocol();
                var mainFrm = new QspForm();
                mainFrm.Init();
                Application.Run(mainFrm);
            }
        }
예제 #2
0
        internal static void Main(string[] args)
        {
#if !DEBUG
            // Only allows starting from launcher. Otherwise data loss might occur because of
            // the updater.
            try
            {
                var latest = UsingLatestVersion();
                if (!latest)
                {
                    MsgBoxHelper.ShowError(null, "Please start QSimPlanner via Launcher.exe.");
                    return;
                }
            }
            catch (Exception e)
            {
                MsgBoxHelper.ShowError(null, "An error occurred.\n" + e.Message);
                return;
            }
#endif
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            using (var mutex = new Mutex(false, $"Global\\{GetGuid()}"))
            {
                if (!mutex.WaitOne(0, false))
                {
                    MsgBoxHelper.ShowError(null, "QSimPlanner is already running.");
                    return;
                }

                SetExceptionHandler();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
#if !DEBUG
                UpdateOnFirstRun();
#endif
                var mainFrm = new QspForm();
                mainFrm.Init();

                Application.Run(mainFrm);
            }
        }