ForTheCommonGood.frmSettings.button2_Click C# (CSharp) Method

button2_Click() private method

private button2_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void button2_Click(object sender, EventArgs e)
        {
            if (!loginOnly && localWikiDataDomain != "" && localWikiDataDomain != txtLocalDomain.Text)
            {
                if (MessageBox.Show(this, Localization.GetString("LocalWikiDataWrongDomain", localWikiDataDomain) + "\n\n" +
                    Localization.GetString("ContinueAnyway"), Application.ProductName, MessageBoxButtons.YesNo,
                    MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                    return;
            }

            Settings.LocalDomain = txtLocalDomain.Text;
            Settings.LocalUserName = chkLocalSameAsCommons.Checked ? txtCommonsUserName.Text : txtLocalUserName.Text;
            Settings.LocalPassword = chkLocalSameAsCommons.Checked ? txtCommonsPassword.Text : txtLocalPassword.Text;
            Settings.LocalSysop = chkLocalSysop.Checked;
            Settings.CommonsUserName = txtCommonsUserName.Text;
            Settings.CommonsPassword = txtCommonsPassword.Text;
            Settings.SaveCreds = chkSaveCreds.Checked;

            if (!loginOnly)
            {
                Settings.UseHttps = chkUseHttps.Checked;
                Settings.LogTransfers = chkLogTransfers.Checked;
                Settings.OpenBrowserAutomatically = chkOpenBrowserAutomatically.Checked;
                Settings.OpenBrowserLocal = chkOpenBrowserLocal.Checked;
                Settings.AutoUpdate = chkAutoUpdate.Checked;
                Settings.LocalWikiData = optLocalDataFile.Checked ? localWikiDataFile : "";
                if (optLocalDataHosted.Checked && cboLocalDataHosted.SelectedIndex != -1 &&
                    cboLocalDataHosted.SelectedItem is HostedLocalWikiDataEntry)
                {
                    Settings.LocalWikiDataHosted = ((HostedLocalWikiDataEntry) cboLocalDataHosted.SelectedItem).GetFull();
                }
                else
                {
                    Settings.LocalWikiDataHosted = "";
                }
            }

            // save settings
            Settings.WriteSettings();

            DialogResult = DialogResult.OK;
            Close();
        }