Ejemplo n.º 1
0
        private void AutomaticBackupSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(FolderPath.Text) || !Directory.Exists(FolderPath.Text + "client_resources\\"))
            {
                MessageBox.Show(Strings.InvalidFolderPathBackup, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Properties.Settings.Default.BackupChatLogAutomatically)
            {
                if (MessageBox.Show(Strings.BackupWillBeOff, Strings.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }

                StatusLabel.Text = string.Format(Strings.BackupStatus, Strings.Disabled);
            }
            else
            {
                MessageBox.Show(Strings.SettingsAfterClose, Strings.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            BackupHandler.AbortAll();
            SaveSettings();

            if (backupSettings == null)
            {
                backupSettings             = new BackupSettings();
                backupSettings.FormClosed += (s, args) =>
                {
                    BackupHandler.Initialize();
                    StatusLabel.Text = string.Format(Strings.BackupStatus, Properties.Settings.Default.BackupChatLogAutomatically ? Strings.Enabled : Strings.Disabled);
                };
            }
            else
            {
                backupSettings.LoadSettings();

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

            backupSettings.ShowDialog();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
            }
        }