RatioMaster_source.RM.ReadSettings C# (CSharp) Метод

ReadSettings() приватный Метод

private ReadSettings ( ) : void
Результат void
        internal void ReadSettings()
        {
            try
            {
                RegistryKey reg = Registry.CurrentUser.OpenSubKey("Software\\RatioMaster.NET", true);

                // TorrentInfo torrent = new TorrentInfo(0, 0);
                if (reg == null)
                {
                    // The key doesn't exist; create it / open it
                    Registry.CurrentUser.CreateSubKey("Software\\RatioMaster.NET");
                    return;
                }

                string Version = (string)reg.GetValue("Version", "none");
                if (Version == "none")
                {
                    btnDefault_Click(null, null);
                    return;
                }

                chkNewValues.Checked = ItoB((int)reg.GetValue("NewValues", true));
                getnew = false;
                cmbClient.SelectedItem = reg.GetValue("Client", DefaultClient);
                getnew = false;
                cmbVersion.SelectedItem = reg.GetValue("ClientVersion", DefaultClientVersion);
                uploadRate.Text = ((string)reg.GetValue("UploadRate", uploadRate.Text));
                downloadRate.Text = ((string)reg.GetValue("DownloadRate", downloadRate.Text));
                fileSize.Text = (string)reg.GetValue("fileSize", "0");

                // fileSize.Text = "0";
                interval.Text = (reg.GetValue("Interval", interval.Text)).ToString();
                DefaultDirectory = (string)reg.GetValue("Directory", DefaultDirectory);
                checkTCPListen.Checked = ItoB((int)reg.GetValue("TCPlistener", BtoI(checkTCPListen.Checked)));
                checkRequestScrap.Checked = ItoB((int)reg.GetValue("ScrapeInfo", BtoI(checkRequestScrap.Checked)));
                checkLogEnabled.Checked = ItoB((int)reg.GetValue("EnableLog", BtoI(checkLogEnabled.Checked)));

                // Radnom value
                chkRandUP.Checked = ItoB((int)reg.GetValue("GetRandUp", BtoI(chkRandUP.Checked)));
                chkRandDown.Checked = ItoB((int)reg.GetValue("GetRandDown", BtoI(chkRandDown.Checked)));
                txtRandUpMin.Text = (string)reg.GetValue("MinRandUp", txtRandUpMin.Text);
                txtRandUpMax.Text = (string)reg.GetValue("MaxRandUp", txtRandUpMax.Text);
                txtRandDownMin.Text = (string)reg.GetValue("MinRandDown", txtRandDownMin.Text);
                txtRandDownMax.Text = (string)reg.GetValue("MaxRandDown", txtRandDownMax.Text);

                // Custom values
                if (chkNewValues.Checked == false)
                {
                    customKey.Text = (string)reg.GetValue("CustomKey", customKey.Text);
                    customPeerID.Text = (string)reg.GetValue("CustomPeerID", customPeerID.Text);
                    lblGenStatus.Text = "Generation status: " + "using last saved values";
                }
                else
                {
                    SetCustomValues();
                }

                customPort.Text = (string)reg.GetValue("CustomPort", customPort.Text);
                customPeersNum.Text = (string)reg.GetValue("CustomPeers", customPeersNum.Text);

                // Radnom value on next
                checkRandomUpload.Checked = ItoB((int)reg.GetValue("GetRandUpNext", BtoI(checkRandomUpload.Checked)));
                checkRandomDownload.Checked = ItoB((int)reg.GetValue("GetRandDownNext", BtoI(checkRandomDownload.Checked)));
                RandomUploadFrom.Text = (string)reg.GetValue("MinRandUpNext", RandomUploadFrom.Text);
                RandomUploadTo.Text = (string)reg.GetValue("MaxRandUpNext", RandomUploadTo.Text);
                RandomDownloadFrom.Text = (string)reg.GetValue("MinRandDownNext", RandomDownloadFrom.Text);
                RandomDownloadTo.Text = (string)reg.GetValue("MaxRandDownNext", RandomDownloadTo.Text);

                // Stop after...
                cmbStopAfter.SelectedItem = reg.GetValue("StopWhen", "Never");
                txtStopValue.Text = (string)reg.GetValue("StopAfter", txtStopValue.Text);

                // Proxy
                comboProxyType.SelectedItem = reg.GetValue("ProxyType", comboProxyType.SelectedItem);
                textProxyHost.Text = (string)reg.GetValue("ProxyAdress", textProxyHost.Text);
                textProxyUser.Text = (string)reg.GetValue("ProxyUser", textProxyUser.Text);
                textProxyPass.Text = (string)reg.GetValue("ProxyPass", textProxyPass.Text);
                textProxyPort.Text = (string)reg.GetValue("ProxyPort", textProxyPort.Text);
                checkIgnoreFailureReason.Checked = ItoB((int)reg.GetValue("IgnoreFailureReason", BtoI(checkIgnoreFailureReason.Checked)));
            }
            catch (Exception e)
            {
                AddLogLine("Error in ReadSettings(): " + e.Message);
            }
        }