public UpdateNotifyDialog(UpdateChecker checker)
        {
            _checker = checker;

            InitializeComponent();

            label1.Text = string.Format(label1.Text, checker.RepostoryName);
        }
Example #2
0
        void Check(object sender, EventArgs e)
        {
            UpdateChecker checker;
            if (ProductVersion.Checked)
            {
                checker = new UpdateChecker(User.Text, Repo.Text);
            }
            else
            {
                checker = new UpdateChecker(User.Text, Repo.Text, Version.Text);
            }

            ((Button)sender).Enabled = false;
            checker.CheckUpdate(locked: (UpdateType)Lock.SelectedIndex).ContinueWith(continuation =>
            {
                // if (continuation.Result == UpdateType.None)
                //    return;

                Invoke(new Action(() => // Go back to the UI thread
                {
                    ((Button)sender).Enabled = true;
                    if (continuation.Result != UpdateType.None)
                    {
                        var result = new UpdateNotifyDialog(checker).ShowDialog();
                        if (result == DialogResult.Yes)
                        {
                            checker.DownloadAsset(Asset.Text);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Up to date!");
                    }
                }));
            });
        }
Example #3
0
        async void CheckUpdate()
        {
            if (!Properties.Settings.Default.SeenNotice)
            {
                try
                {
                    using (var noticeChecker = new WebClient())
                    {
                        const string caption = "Notice";
                        var result = await noticeChecker.DownloadStringTaskAsync(@"https://raw.githubusercontent.com/nixxquality/WebMConverter/master/NOTICE");
                        var urlAndMessage = result.Split(new[] { '\n' }, 2);
                        switch (MessageBox.Show(urlAndMessage[1], caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            case DialogResult.Yes:
                                if (urlAndMessage[0].StartsWith("http")) // just in case someone hacks my anus, let's not give him any ways to execute arbitrary code on all my users
                                    System.Diagnostics.Process.Start(urlAndMessage[0]);

                                Application.Exit();
                                break;
                            case DialogResult.No:
                                Properties.Settings.Default.SeenNotice = true;
                                Properties.Settings.Default.Save();
                                break;
                        }
                    }
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("404"))
                    {
                        this.InvokeIfRequired(() =>
                        {
                            showToolTip("Update checking failed! " + e.Message, 2000);
                        });
                        return;
                    }
                }
            }

            try
            {
                var checker = new UpdateChecker("nixxquality", "WebMConverter");

                var update = await checker.CheckUpdate();

                if (update == UpdateType.None)
                {
                    this.InvokeIfRequired(() =>
                    {
                        showToolTip("Up to date!", 1000);
                    });
                }
                else
                {
                    this.InvokeIfRequired(() =>
                    {
                        var result = new UpdateNotifyDialog(checker).ShowDialog(this);
                        if (result == DialogResult.Yes)
                        {
                            checker.DownloadAsset("Converter.zip");
                            Application.Exit();
                        }
                    });
                }
            }
            catch (Exception e)
            {
                this.InvokeIfRequired(() =>
                {
                    showToolTip("Update checking failed! " + e.Message, 2000);
                });
            }
        }
 private async Task<bool> CheckUpdate(bool silent)
 {
     try
     {
         UpdateChecker checker = new UpdateChecker("TKGP", "STALK-IRC");
         UpdateType update = await checker.CheckUpdate();
         if (update == UpdateType.Major || update == UpdateType.Minor)
         {
             this.Hide();
             timer1.Enabled = false;
             timer3.Enabled = false;
             AddGameMsg("Information", "A mandatory update to STALK-IRC is available! STALK-IRC is now disabled; check the client to update.");
             SystemSounds.Asterisk.Play();
             string notes = await checker.RenderReleaseNotes();
             DialogResult result = new UpdateForm(notes, silent, true).ShowDialog();
             if (result == DialogResult.Yes)
                 checker.DownloadAsset("STALK-IRC.exe");
             doClose = true;
             return true;
         }
         else if (!updateSkipped && update == UpdateType.Patch)
         {
             AddGameMsg("Information", "An optional update to STALK-IRC is available! Check the client to update.");
             SystemSounds.Asterisk.Play();
             string notes = await checker.RenderReleaseNotes();
             DialogResult result = new UpdateForm(notes, silent, false).ShowDialog();
             if (result == DialogResult.Yes)
             {
                 this.Hide();
                 timer1.Enabled = false;
                 timer3.Enabled = false;
                 checker.DownloadAsset("STALK-IRC.exe");
                 doClose = true;
             }
             else
                 updateSkipped = true;
         }
     }
     catch (Octokit.RateLimitExceededException)
     {
         // Woops
     }
     return false;
 }