示例#1
0
        private void GetUpdateInfoCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (frmMain.Default.InvokeRequired)
            {
                frmMain.Default.Invoke(new AsyncCompletedEventHandler(GetUpdateInfoCompleted), new object[] { sender, e });
                return;
            }

            try
            {
                _appUpdate.GetUpdateInfoCompletedEvent -= GetUpdateInfoCompleted;

                if (e.Cancelled)
                {
                    return;
                }
                if (e.Error != null)
                {
                    throw (e.Error);
                }

                if (_appUpdate.IsUpdateAvailable())
                {
                    Windows.Show(WindowType.Update);
                }
            }
            catch (Exception ex)
            {
                Runtime.MessageCollector.AddExceptionMessage("GetUpdateInfoCompleted() failed.", ex, MessageClass.ErrorMsg, true);
            }
        }
示例#2
0
        private void GetUpdateInfoCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (InvokeRequired)
            {
                var myDelegate = new AsyncCompletedEventHandler(GetUpdateInfoCompleted);
                Invoke(myDelegate, sender, e);
                return;
            }

            try
            {
                _appUpdate.GetUpdateInfoCompletedEvent -= GetUpdateInfoCompleted;

                lblInstalledVersion.Text         = Application.ProductVersion;
                lblInstalledVersion.Visible      = true;
                lblInstalledVersionLabel.Visible = true;
                btnCheckForUpdate.Visible        = true;

                if (e.Cancelled)
                {
                    return;
                }
                if (e.Error != null)
                {
                    throw e.Error;
                }

                if (_appUpdate.IsUpdateAvailable())
                {
                    lblStatus.Text      = Language.strUpdateAvailable;
                    lblStatus.ForeColor = Color.OrangeRed;
                    pnlUpdate.Visible   = true;

                    var updateInfo = _appUpdate.CurrentUpdateInfo;
                    lblLatestVersion.Text         = updateInfo.Version.ToString();
                    lblLatestVersionLabel.Visible = true;
                    lblLatestVersion.Visible      = true;

                    if (updateInfo.ImageAddress == null || string.IsNullOrEmpty(updateInfo.ImageAddress.ToString()))
                    {
                        pbUpdateImage.Visible = false;
                    }
                    else
                    {
                        pbUpdateImage.ImageLocation = updateInfo.ImageAddress.ToString();
                        pbUpdateImage.Tag           = updateInfo.ImageLinkAddress;
                        pbUpdateImage.Visible       = true;
                    }

                    _appUpdate.GetChangeLogCompletedEvent += GetChangeLogCompleted;
                    _appUpdate.GetChangeLogAsync();

                    btnDownload.Focus();
                }
                else
                {
                    lblStatus.Text      = Language.strNoUpdateAvailable;
                    lblStatus.ForeColor = Color.ForestGreen;

                    if (_appUpdate.CurrentUpdateInfo != null)
                    {
                        var updateInfo = _appUpdate.CurrentUpdateInfo;
                        if (updateInfo.IsValid && updateInfo.Version != null)
                        {
                            lblLatestVersion.Text         = updateInfo.Version.ToString();
                            lblLatestVersionLabel.Visible = true;
                            lblLatestVersion.Visible      = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text      = Language.strUpdateCheckFailedLabel;
                lblStatus.ForeColor = Color.OrangeRed;

                Runtime.MessageCollector.AddExceptionMessage(Language.strUpdateCheckCompleteFailed, ex);
            }
        }