コード例 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG
            // Prevent multiple instances
            if (!mutex.WaitOne(TimeSpan.FromSeconds(0), false))
            {
                return;
            }
#endif

            CRCStrings.Load();
            bool optionsLoaded = CRCOptions.Load();
            if (!optionsLoaded)
            {
                // No point localizing this since localization may not even be loaded
                MessageBox.Show("CRC was unable to access the registry, which is needed to preserve settings.\r\n"
                                + "Please try running the application As Administrator.\r\n\r\n"
                                + "CRC не смог получить доступ к реестру, который необходим для сохранения настроек.\r\n"
                                + "Попробуйте запустить приложение с правами администратора.",
                                CRCStrings.Localize("crc_name"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (CRCUpdate.CheckFirstUpdate())
            {
                return;
            }

            displayThread = new Thread(CRCDisplay.Start);
            displayThread.Start();
            clientThread = new Thread(CRCClient.Start);
            clientThread.Start();

            clientThread.Join();
            displayThread.Join();
            CRCOptions.Save();
        }
コード例 #2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string name   = textBoxName.Text.Replace(' ', '_');
            string result = CRCStrings.ValidateNick(name);

            if (result != null)
            {
                MessageBox.Show(result, CRCStrings.Localize("crc_error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string lang = indexToLanguage[comboBoxLanguage.SelectedIndex];

            if (lang != CRCOptions.Language)
            {
                CRCOptions.Language = lang;
                MessageBox.Show(CRCStrings.Localize("options_language_restart"), CRCStrings.Localize("crc_name"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            CRCOptions.Channel        = indexToChannel[comboBoxChannel.SelectedIndex];
            CRCOptions.AutoFaction    = radioButtonFactionAuto.Checked;
            CRCOptions.ManualFaction  = indexToFaction[comboBoxFaction.SelectedIndex];
            CRCOptions.Name           = name;
            CRCOptions.ShowTimestamps = checkBoxTimestamps.Checked;
            CRCOptions.SendDeath      = checkBoxDeathSend.Checked;
            CRCOptions.ReceiveDeath   = checkBoxDeathReceive.Checked;
            CRCOptions.DeathInterval  = (int)numericUpDownDeath.Value;

            CRCOptions.NewsDuration = (int)numericUpDownNewsDuration.Value;
            CRCOptions.ChatKey      = textBoxChatKey.Text;
            CRCOptions.NewsSound    = checkBoxNewsSound.Checked;
            CRCOptions.CloseChat    = checkBoxCloseChat.Checked;

            CRCOptions.Save();
            CRCClient.UpdateSettings();
            CRCGame.UpdateSettings();
            this.Close();
        }