private void StartWithWindows_CheckedChanged(object sender, EventArgs e)
 {
     if (StartWithWindows.Checked && !StartupHandler.IsAddedToStartup())
     {
         MessageBox.Show("This feature will stop working if you delete or move the parser to a different location.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void BackupSettings_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (BackUpChatLogAutomatically.Checked && (string.IsNullOrWhiteSpace(BackupPath.Text) || !Directory.Exists(BackupPath.Text)))
            {
                e.Cancel = true;
                MessageBox.Show("Please choose a valid backup location or turn automatic backup off.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            if ((StartWithWindows.Checked && !StartupHandler.IsAddedToStartup()) || (!StartWithWindows.Checked && StartupHandler.IsAddedToStartup()))
            {
                StartupHandler.ToggleStartup(StartWithWindows.Checked);
            }

            SaveSettings();
        }
Exemplo n.º 3
0
        static void Main()
        {
            Mutex mutex = new Mutex(true, "UniqueAppId", out bool isUnique);

            if (!isUnique)
            {
                MessageBox.Show("Another instance is already running, check your taskbar or task manager.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var args = Environment.GetCommandLineArgs();

            if (args != null && args.Any(arg => arg == $"{Data.parameterPrefix}minimized"))
            {
                startMinimized = true;

                if (args.Any(arg => arg == $"{Data.parameterPrefix}notray"))
                {
                    startMinimizedWithoutTrayIcon = true;
                }
            }

            Data.Initialize();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!startMinimizedWithoutTrayIcon)
            {
                Application.Run(new Main(startMinimized));
            }
            else
            {
                StartupHandler.Initialize();
                BackupHandler.Initialize();

                //MessageBox.Show("Started the GTA World Chat Log Parser in minimized mode with no tray icon. You can only close it from the task manager.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            GC.KeepAlive(mutex);
        }
Exemplo n.º 4
0
        public Main(bool startMinimized)
        {
            LocalizationManager.Initialize();

            if (Properties.Settings.Default.FirstStart)
            {
                if (languagePicker == null)
                {
                    languagePicker = new LanguagePicker();
                }
                else
                {
                    languagePicker.Initialize();

                    languagePicker.WindowState = FormWindowState.Normal;
                    languagePicker.BringToFront();
                }

                languagePicker.ShowDialog();
            }

            StartupHandler.Initialize();

            allowFormDisplay = !startMinimized;

            InitializeComponent();

            // Also checks for the RAGEMP folder on the first start
            LoadSettings();

            string currentLanguage = LocalizationManager.GetLanguageFromCode(LocalizationManager.GetLanguage());

            for (int i = 0; i < ((LocalizationManager.Language[])Enum.GetValues(typeof(LocalizationManager.Language))).Length; ++i)
            {
                LocalizationManager.Language language = (LocalizationManager.Language)i;
                ToolStripItem newLanguage             = languageToolStripMenuItem.DropDownItems.Add(language.ToString());
                newLanguage.Click += (s, e) =>
                {
                    if (((ToolStripMenuItem)newLanguage).Checked == true)
                    {
                        return;
                    }

                    CultureInfo cultureInfo = new CultureInfo(LocalizationManager.GetCodeFromLanguage(language));

                    if (MessageBox.Show(Strings.ResourceManager.GetString("Restart", cultureInfo), Strings.ResourceManager.GetString("RestartTitle", cultureInfo), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        LocalizationManager.SetLanguage(language);

                        Hide();
                        System.Windows.Forms.Application.Restart();
                        System.Windows.Forms.Application.Exit();
                    }
                };

                if (currentLanguage == language.ToString())
                {
                    ((ToolStripMenuItem)languageToolStripMenuItem.DropDownItems[i]).Checked = true;
                }
            }

            BackupHandler.Initialize();

            if (startMinimized)
            {
                TrayIcon.Visible = true;
            }

            if (Properties.Settings.Default.CheckForUpdatesAutomatically)
            {
                TryCheckingForUpdates(manual: false);
            }
        }