示例#1
0
        public static async void CheckForUpdates(bool showUpToDateDialog, bool topMost, IntPtr owner)
        {
            try
            {
                UpdateChecker.Init(_githubOwner, _githubRepo);
                string update = await UpdateChecker.CheckUpdate();

                if (update == null)
                {
                    if (showUpToDateDialog)
                    {
                        OnIsUpToDate(EventArgs.Empty);
                    }
                }
                else
                {
                    if (!showUpToDateDialog && _skippedVersion == update)
                    {
                        return;
                    }

                    UpdateForm updateDialog = new UpdateForm(_darkMode, _title, _message, _dwnldBtnText, _skipBtnText, _whatsNewBtnText);
                    updateDialog.TopMost = topMost;

                    DialogResult result = updateDialog.ShowDialog(Form.FromHandle(owner));
                    if (result == DialogResult.Yes)
                    {
                        DownloadForm downloadBox = new DownloadForm(UpdateChecker.GetAssetUrl(_exeName), _darkMode, _updating, _downloading, _readyToInstall, _failed, _dwnldBtnText);
                        downloadBox.TopMost = topMost;
                        downloadBox.ShowDialog(Form.FromHandle(owner));
                    }
                    if (result == DialogResult.No)
                    {
                        UpdateSkippedEventArgs usea = new UpdateSkippedEventArgs
                        {
                            SkippedVersion = update
                        };
                        OnUpdateSkipped(usea);
                    }
                    else
                    {
                        updateDialog.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                if (showUpToDateDialog)
                {
                    UpdateFailedEventArgs ufea = new UpdateFailedEventArgs
                    {
                        Exception = ex
                    };
                    OnUpdateFailed(ufea);
                }
            }
        }
示例#2
0
 public static void OnUpdateSkipped(UpdateSkippedEventArgs usea)
 {
     UpdateSkipped?.Invoke(null, usea);
 }