private void detail_Btn_Click(object sender, System.EventArgs e) { UpdateInfoForm uc = new UpdateInfoForm(); Dispose(); uc.Owner = GlobalData.mainForm; uc.ShowDialog(); }
//仅在启动一段时间后检查一次更新, private static void ScheduledUpdateCheck(object sender, NotifyIcon tray) { var timer = sender as Timer; timer.Stop(); timer.Dispose(); timer = null; if (!config.Get <bool>(ConfigKeys.AutoCheckForUpdate)) { return; } var checker = new VersionChecker(AppSettings.CheckForUpdateUrl); checker.Finished += info => { var whatsNew = info.WhatsNew.Length > 50 ? info.WhatsNew.Substring(0, 50) : info.WhatsNew; if (info.Version != Application.ProductVersion) { tray.BalloonTipClicked += (o, args) => { if (info.Version == Application.ProductVersion) { return; } using (var frm = new UpdateInfoForm(ConfigurationManager.AppSettings.Get(Constants.ProductHomePageAppSettingKey), info)) { frm.ShowDialog(); } }; tray.ShowBalloonTip(1000 * 15, Application.ProductName + "新版本可用!", "版本:" + info.Version + "\n" + whatsNew, ToolTipIcon.Info); } checker.Dispose(); checker = null; GC.Collect(); }; #if DEBUG checker.ErrorHappened += e => { Debug.WriteLine("Program.ScheduledUpdateCheck Error:" + e.Message); checker.Dispose(); checker = null; GC.Collect(); }; #endif checker.CheckAsync(); }
public void checkForUpdates() { // Check for settings updates. if (Settings.Default.UpdateRequired) { Settings.Default.Upgrade(); Settings.Default.UpdateRequired = false; Settings.Default.Save(); // open up changelog if (Settings.Default.OpenChangelog && !mainForm.DEBUG) { Process.Start("https://github.com/Myll/Dota-2-ModKit/releases"); } // display notification //text_notification("D2ModKit updated!", MetroColorStyle.Green, 1500); } var updatesWorker = new BackgroundWorker(); updatesWorker.DoWork += (s, e) => { // use these to test version updater. //newVers = "1.3.2"; //url = "https://github.com/stephenfournier/Dota-2-ModKit/releases/download/v1.3.2/D2ModKit.zip"; // remember to keep the version naming consistent! // you can go from 1.3.4.4 to 1.3.5.0, OR 1.3.4.0 to 1.3.5.0 int count = 1; int j = 0; while (true) { newVers = Util.IncrementVers(version, count + j); url = "https://github.com/stephenfournier/Dota-2-ModKit/releases/download/v"; url += newVers + "/D2ModKit.zip"; WebClient wc = new WebClient(); try { byte[] responseBytes = wc.DownloadData("https://github.com/stephenfournier/Dota-2-ModKit/releases/tag/v" + newVers); releases_page_source = System.Text.Encoding.ASCII.GetString(responseBytes); } catch (Exception) { if (j < 10) { j++; continue; } break; } newVersFound = true; count += j + 1; j = 0; } newVers = Util.IncrementVers(version, count - 1); url = "https://github.com/stephenfournier/Dota-2-ModKit/releases/download/v"; url += newVers + "/D2ModKit.zip"; }; updatesWorker.RunWorkerCompleted += (s, e) => { if (!newVersFound) { Debug.WriteLine("No new vers available."); return; } mainForm.newVers = newVers; mainForm.newVersUrl = url; mainForm.releases_page_source = releases_page_source; UpdateInfoForm uif = new UpdateInfoForm(mainForm); uif.ShowDialog(); }; updatesWorker.RunWorkerAsync(); }
private void BtnUpdateInfo_Click(object sender, EventArgs e) { UpdateInfoForm updateInfoForm = new UpdateInfoForm(); updateInfoForm.ShowDialog(); }
public async void PresentInformation() { infoForm = new UpdateInfoForm(); infoForm.TopMost = true; infoForm.ShowDialog(); }