예제 #1
0
파일: Form2.cs 프로젝트: adryzz/EasyEdit.io
 private void UpdateGitHub()
 {
     try
     {
         var     client   = new GitHubClient(new ProductHeaderValue("adryzz"));
         var     releases = client.Repository.Release.GetAll("adryzz", "EasyEdit.io");
         Release latest   = releases.Result[0];
         if (latest.Name.Equals(ProductVersion.Remove(ProductVersion.Length - 2)))
         {
             MessageBox.Show("You are running the latest version!", "EasyEdit.io", MessageBoxButtons.OK, MessageBoxIcon.Information);
             AllowClosing   = true;
             Form1.Enabled  = true;
             Form1.Updating = false;
             ControlBox     = true;
             Close();
         }
         using (WebClient wc = new WebClient())
         {
             progressBar1.Style          = ProgressBarStyle.Continuous;
             wc.DownloadProgressChanged += wc_DownloadProgressChanged;
             wc.DownloadFileCompleted   += Wc_DownloadFileCompleted;
             wc.DownloadFileAsync(new Uri(latest.Assets.First().BrowserDownloadUrl), Path.Combine(System.Windows.Forms.Application.StartupPath, "update.exe"));
             label1.Text = "Downloading update...";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message, "EasyEdit.io", MessageBoxButtons.OK, MessageBoxIcon.Error);
         AllowClosing   = true;
         Form1.Enabled  = true;
         Form1.Updating = false;
         ControlBox     = true;
         Close();
     }
 }