internal void StartButton_Click(object sender, EventArgs e) { if (!StartButton.Enabled) return; Seeders = -1; Leechers = -1; if (trackerAddress.Text == "" || shaHash.Text == "" || txtTorrentSize.Text == "") { MessageBox.Show("Please select valid torrent file!", "RatioMaster.NET " + version + " - ERROR"); return; } // Check rem work if ((string)cmbStopAfter.SelectedItem == "After time:") { int res; bool bCheck = int.TryParse(txtStopValue.Text, out res); if (bCheck == false) { MessageBox.Show("Please select valid number for Remaning Work\n\r- 0 - default - never stop\n\r- positive number (greater than 1000)", "RatioMaster.NET " + version + " - ERROR"); return; } else { if (res < 1000 && res != 0) { MessageBox.Show("Please select valid number for Remaning Work\n\r- 0 - default - never stop\n\r- positive number (greater than 1000)", "RatioMaster.NET " + version + " - ERROR"); return; } } } updateScrapStats("", "", ""); totalRunningTimeCounter = 0; timerValue.Text = "updating..."; // txtStopValue.Text = res.ToString(); updateProcessStarted = true; seedMode = false; requestScrap = checkRequestScrap.Checked; updateScrapStats("", "", ""); StartButton.Enabled = false; StartButton.BackColor = SystemColors.Control; StopButton.Enabled = true; StopButton.BackColor = Color.Silver; manualUpdateButton.Enabled = true; manualUpdateButton.BackColor = Color.Silver; btnDefault.Enabled = false; interval.ReadOnly = true; fileSize.ReadOnly = true; cmbClient.Enabled = false; cmbVersion.Enabled = false; trackerAddress.ReadOnly = true; browseButton.Enabled = false; txtStopValue.Enabled = false; cmbStopAfter.Enabled = false; customPeersNum.Enabled = false; customPort.Enabled = false; currentClient = TorrentClientFactory.GetClient(GetClientName()); currentTorrent = getCurrentTorrent(); currentProxy = getCurrentProxy(); AddClientInfo(); OpenTcpListener(); Thread myThread = new Thread(startProcess); myThread.Name = "startProcess() Thread"; myThread.Start(); serverUpdateTimer.Start(); remWork = 0; if ((string)cmbStopAfter.SelectedItem == "After time:") RemaningWork.Start(); requestScrapeFromTracker(currentTorrent); }
private ProxyInfo getCurrentProxy() { Encoding _usedEnc = Encoding.GetEncoding(0x4e4); ProxyInfo curProxy = new ProxyInfo(); switch (comboProxyType.SelectedIndex) { case 0: curProxy.ProxyType = ProxyType.None; break; case 1: curProxy.ProxyType = ProxyType.HttpConnect; break; case 2: curProxy.ProxyType = ProxyType.Socks4; break; case 3: curProxy.ProxyType = ProxyType.Socks4a; break; case 4: curProxy.ProxyType = ProxyType.Socks5; break; default: curProxy.ProxyType = ProxyType.None; break; } curProxy.ProxyServer = textProxyHost.Text; curProxy.ProxyPort = textProxyPort.Text.ParseValidInt(0); curProxy.ProxyUser = _usedEnc.GetBytes(textProxyUser.Text); curProxy.ProxyPassword = _usedEnc.GetBytes(textProxyPass.Text); // Add log info Encoding enc = System.Text.Encoding.ASCII; AddLogLine("PROXY INFO:"); AddLogLine("proxyType = " + curProxy.ProxyType); AddLogLine("proxyServer = " + curProxy.ProxyServer); AddLogLine("proxyPort = " + curProxy.ProxyPort); AddLogLine("proxyUser = "******"proxyPassword = "******"\n" + "\n"); return curProxy; }