public static MenuControlController GetInstance()
 {
     if (_Instance == null)
     {
         _Instance = new MenuControlController();
     }
     return(_Instance);
 }
Esempio n. 2
0
        public void StartChecking(bool isAutoCheckUpdate)
        {
            WebClient client = new WebClient();

            client.Headers.Add("User-Agent", UserAgent);
            client.DownloadStringCompleted += (sender, e) =>
            {
                List <Release> releaseList = new List <Release>();

                string result      = e.Result;
                JArray releaseJArr = JArray.Parse(result);
                foreach (JObject release in releaseJArr)
                {
                    if ((bool)release["prerelease"])
                    {
                        continue;
                    }
                    if (Release.CompareVersion((string)release["name"], _currentVersion) > 0)
                    {
                        releaseList.Add(new Release()
                        {
                            Version     = (string)release["name"],
                            FileName    = (string)release["assets"][0]["name"],
                            DownloadUrl = (string)release["assets"][0]["browser_download_url"]
                        });
                    }
                }

                if (releaseList.Count <= 0)
                {
                    if (!isAutoCheckUpdate)
                    {
                        MenuControlController.GetInstance()
                        .ShowNotification(5, "KcptunLauncher", "当前已是最新的版本", ToolTipIcon.Info);
                    }
                    return;
                }

                releaseList.Sort(new VersionComparer());

                latestRelease = releaseList[releaseList.Count - 1];
                MenuControlController.GetInstance().ShowNotification(5, "KcptunLauncher", "检测到有新版本,点击此处获取 KcptunLauncher " + latestRelease.Version + " 版本的更新", ToolTipIcon.Info);
            };
            client.DownloadStringAsync(new Uri(ReleaseUrl));
        }
 public static MenuControlController GetInstance()
 {
     return(_instance ?? (_instance = new MenuControlController()));
 }