public static void CheckForUpdates(bool user) { string url = "https://api.github.com/repos/atomic-software/TISFAT-Zero/releases/latest"; HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(url); Request.UserAgent = "TISFAT Zero"; WebResponse Response; try { Response = Request.GetResponse(); } catch (WebException ex) { var response = ex.Response; StreamReader r = new StreamReader(response.GetResponseStream()); MessageBox.Show(r.ReadToEnd()); return; } StreamReader reader = new StreamReader(Response.GetResponseStream()); string result = reader.ReadToEnd(); GithubReleaseDto latestRelease = JsonConvert.DeserializeObject <GithubReleaseDto>(result); string[] version = latestRelease.body.Split('\r'); if (IsVersionNewer(version[0], Application.ProductVersion)) { GithubAssetsDto asset = null; foreach (GithubAssetsDto set in latestRelease.assets) { if (set.name == Program.TargetMsiName) { asset = set; break; } } if (asset == null) { // Some error return; } AutoUpdateDialog dlg = new AutoUpdateDialog(version[0], asset.browser_download_url, asset.download_count, latestRelease.body); dlg.StartPosition = FormStartPosition.CenterParent; dlg.ShowDialog(); } else if (user) { MessageBox.Show("You have the latest version of TISFAT Zero.", "No updates available"); } }
private void MainForm_Load(object sender, EventArgs e) { ProjectNew(); // Create and show forms Form_Timeline = new TimelineForm(sc_MainContainer.Panel2); Form_Toolbox = new PropertiesForm(sc_MainContainer.Panel2); Form_Canvas = new CanvasForm(sc_MainContainer.Panel2); Form_Timeline.Show(); Form_Toolbox.Show(); Form_Canvas.Show(); Form_Timeline.Location = new Point(5, 0); Form_Toolbox.Location = new Point(50, Form_Timeline.Location.Y + Form_Timeline.Height + 4); Form_Canvas.Location = new Point(Form_Toolbox.Location.X + Form_Toolbox.Width + 20, Form_Timeline.Location.Y + Form_Timeline.Height + 4); if (Program.LoadFile != "") { ProjectOpen(Program.LoadFile); } AutoUpdateDialog.CheckForUpdates(false); }
private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e) { AutoUpdateDialog.CheckForUpdates(true); }