Example #1
0
        private void BtnRefreshVer_Click(object sender, System.EventArgs e)
        {
            var elRefresh = btnRefreshVer;
            var elCboxVer = cboxVer;

            elRefresh.Enabled = false;

            VgcApis.Misc.Utils.RunInBackground(() =>
            {
                int proxyPort = -1;
                if (chkUseProxy.Checked)
                {
                    proxyPort = servers.GetAvailableHttpProxyPort();
                }
                var versions = Misc.Utils.GetOnlineV2RayCoreVersionList(proxyPort);
                if (versions != null && versions.Count > 0)
                {
                    setting.SaveV2RayCoreVersionList(versions);
                }

                VgcApis.Misc.UI.Invoke(() => elRefresh.Enabled = true);

                VgcApis.Misc.UI.Invoke(() =>
                {
                    if (versions.Count > 0)
                    {
                        Misc.UI.FillComboBox(elCboxVer, versions);
                    }
                    else
                    {
                        MessageBox.Show(I18N.GetVersionListFail);
                    }
                });
            });
        }
Example #2
0
        private void BtnRefreshVer_Click(object sender, System.EventArgs e)
        {
            btnRefreshVer.Enabled = false;

            var sourceUrl = VgcApis.Models.Consts.Core.GetSourceUrlByIndex(cboxDownloadSource.SelectedIndex);
            int proxyPort = chkUseProxy.Checked ? servers.GetAvailableHttpProxyPort() : -1;

            Action <List <string> > done = (versions) =>
            {
                btnRefreshVer.Enabled = true;
                if (versions.Count > 0)
                {
                    Misc.UI.FillComboBox(cboxVer, versions);
                }
                else
                {
                    MessageBox.Show(I18N.GetVersionListFail);
                }
            };

            Action worker = () =>
            {
                var versions = Misc.Utils.GetOnlineV2RayCoreVersionList(proxyPort, sourceUrl);
                if (versions != null && versions.Count > 0)
                {
                    setting.SaveV2RayCoreVersionList(versions);
                }
                VgcApis.Misc.UI.Invoke(() => done(versions));
            };

            VgcApis.Misc.Utils.RunInBackground(worker);
        }