Пример #1
0
        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();
        }
Пример #2
0
 public async void PresentInformation()
 {
     infoForm         = new UpdateInfoForm();
     infoForm.TopMost = true;
     infoForm.ShowDialog();
 }