Esempio n. 1
0
        private static void Main()
        {
            // Get the command line arguments and check
            // if the current session is a restart
            string[] args = Environment.GetCommandLineArgs();
            if (args.Any(arg => arg == $"{ProgramController.ParameterPrefix}restart"))
            {
                isRestarted = true;
            }

            // Make sure only one instance is running
            // if the application is not currently restarting
            Mutex mutex = new Mutex(true, "ParserMini", out bool isUnique);

            if (!isUnique && !isRestarted)
            {
                MessageBox.Show(Strings.OtherInstanceRunning, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Initialize the controllers and
            // display the main user form
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LocalizationController.InitializeLocale();
            ProgramController.InitializeServerIp();
            Application.Run(new UI.Main());

            // Don't let the garbage
            // collector touch the Mutex
            GC.KeepAlive(mutex);
        }
Esempio n. 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Get the command line arguments and check
            // if the current session is a restart or
            // a minimized start
            string[] args = Environment.GetCommandLineArgs();
            if (args.Any(arg => arg == $"{AppController.ParameterPrefix}restart"))
            {
                isRestarted = true;
            }

            if (args.Any(arg => arg == $"{AppController.ParameterPrefix}minimized"))
            {
                startMinimized = true;
            }

            // Make sure only one instance is running
            // if the application is not currently restarting
            Mutex mutex = new Mutex(true, "GTAWAssistant", out bool isUnique);

            if (!isUnique && !isRestarted)
            {
                MessageBox.Show(Localization.Strings.OtherInstanceRunning, Localization.Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                Current.Shutdown();
                return;
            }

            // Initialize the controllers and
            // display the server picker on the
            // first start, or the main window
            // on subsequent starts
            LocalizationController.InitializeLocale();
            AppController.InitializeServerIp();

            if (!Settings.Default.HasPickedLanguage)
            {
                LanguagePickerWindow languagePicker = new LanguagePickerWindow();
                languagePicker.Show();
            }
            else
            {
                MainWindow mainWindow = new MainWindow(startMinimized);
                if (!startMinimized)
                {
                    mainWindow.Show();
                }
            }

            // Don't let the garbage
            // collector touch the Mutex
            GC.KeepAlive(mutex);
        }