private void btnUpdate_Click(object sender, System.EventArgs e) { if (downloader != null) { MessageBox.Show(I18N("Downloading")); return; } downloader = new Service.Downloader(); downloader.SelectArchitecture(cboxArch.SelectedIndex == 1); downloader.SetVersion(cboxVer.Text); string packageName = downloader.GetPackageName(); downloader.OnProgress += (s, a) => UpdateProgressBarReciever(a.Data); downloader.OnDownloadCancelled += (s, a) => { downloader = null; UpdateProgressBarReciever(0); MessageBox.Show(I18N("DownloadCancelled")); }; downloader.OnDownloadCompleted += (s, a) => { Debug.WriteLine("Download completed!"); string msg = I18N("DownloadCompleted"); try { var isRunning = core.isRunning; if (isRunning) { core.StopCore(); } downloader.UnzipPackage(); if (isRunning) { setting.ActivateServer(); } } catch { msg = I18N("DownloadFail"); } MessageBox.Show(msg); downloader = null; }; downloader.GetV2RayCore(); UpdateProgressBar(1); }
public void RunSpeedTest() { void log(string msg) { SendLog(msg); SetPropertyOnDemand(ref status, msg); } var port = Lib.Utils.GetFreeTcpPort(); var config = PrepareSpeedTestConfig(port); if (string.IsNullOrEmpty(config)) { log(I18N.DecodeImportFail); return; } var url = StrConst.SpeedTestUrl; var text = I18N.Testing; log(text); SendLog(url); var speedTester = new Service.Core(setting) { title = GetTitle() }; speedTester.OnLog += OnLogHandler; speedTester.RestartCore(config); this.speedTestResult = Lib.Utils.VisitWebPageSpeedTest(url, port); text = string.Format("{0}", speedTestResult < long.MaxValue ? speedTestResult.ToString() + "ms" : I18N.Timeout); log(text); speedTester.StopCore(); speedTester.OnLog -= OnLogHandler; }
private void stopToolStripMenuItem_Click(object sender, EventArgs e) { core.StopCore(); }