Exemplo n.º 1
0
        void DownloadV2RayCore()
        {
            downloader = new Service.Downloader();
            downloader.SetArchitecture(cboxArch.SelectedIndex == 1);
            downloader.SetVersion(cboxVer.Text);

            downloader.OnProgress += (s, a) =>
            {
                UpdateProgressBar(a.Data);
            };

            downloader.OnDownloadCompleted += (s, a) =>
            {
                ResetUI(100);
                MessageBox.Show(I18N("DownloadCompleted"));
            };

            downloader.OnDownloadCancelled += (s, a) =>
            {
                ResetUI(0);
                MessageBox.Show(I18N("DownloadCancelled"));
            };

            downloader.OnDownloadFail += (s, a) =>
            {
                ResetUI(0);
                MessageBox.Show(I18N("DownloadFail"));
            };

            downloader.DownloadV2RayCore();
            UpdateProgressBar(1);
        }
Exemplo n.º 2
0
        void DownloadV2RayCore()
        {
            downloader = new Service.Downloader();
            downloader.SetArchitecture(cboxArch.SelectedIndex == 1);
            downloader.SetVersion(cboxVer.Text);

            downloader.OnProgress += (s, a) =>
            {
                UpdateProgressBar(a.Data);
            };

            downloader.OnDownloadCompleted += (s, a) =>
            {
                ResetUI(100);
                Task.Factory.StartNew(
                    () => MessageBox.Show(I18N.DownloadCompleted));
            };

            downloader.OnDownloadCancelled += (s, a) =>
            {
                ResetUI(0);
                Task.Factory.StartNew(
                    () => MessageBox.Show(I18N.DownloadCancelled));
            };

            downloader.OnDownloadFail += (s, a) =>
            {
                ResetUI(0);
                Task.Factory.StartNew(
                    () => MessageBox.Show(I18N.TryManualDownload));
            };

            downloader.DownloadV2RayCore();
            UpdateProgressBar(1);
        }
Exemplo n.º 3
0
        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);
        }