Contains update information
コード例 #1
0
        /// <summary>
        /// After the background worker is done, prompt to update if there is one
        /// </summary>
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // If there is a file on the server
            if (!e.Cancelled)
            {
                AutoUpdateXml update = (AutoUpdateXml)e.Result;

                // Check if the update is not null and is a newer version than the current application
                if (update != null && update.IsNewerThan(this.applicationInfo.ApplicationAssembly.GetName().Version))
                {
                    // Ask to accept the update
                    if (new AutoUpdateAcceptForm(this.applicationInfo, update).ShowDialog(this.applicationInfo.Context) == DialogResult.Yes)
                    {
                        this.DownloadUpdate(update);                         // Do the update
                    }
                }
                else
                {
                    if (!autoCheck)
                    {
                        MessageBoxEx.Show(this.applicationInfo.Context, lang.getString("autoUpdater_result_latest"));
                    }
                }
            }
            else
            {
                MessageBoxEx.Show(this.applicationInfo.Context, lang.getString("autoUpdater_result_none"));
            }
        }
コード例 #2
0
        /// <summary>
        /// Downloads update and installs the update
        /// </summary>
        /// <param name="update">The update xml info</param>
        private void DownloadUpdate(AutoUpdateXml update)
        {
            AutoUpdateDownloadForm form   = new AutoUpdateDownloadForm(this.applicationInfo, update.Uri, update.MD5, this.applicationInfo.ApplicationIcon);
            DialogResult           result = form.ShowDialog(this.applicationInfo.Context);

            // Download update
            if (result == DialogResult.OK)
            {
                String currentPath = this.applicationInfo.ApplicationAssembly.Location;
                String newPath     = Path.GetDirectoryName(currentPath) + "\\" + update.FileName;

                // "Install" it
                AutoClosingMessageBox.Show(this.applicationInfo.Context,
                                           lang.getString("autoUpdater_msg_success"),
                                           lang.getString("autoUpdater_msg_success_title"),
                                           5000);
                UpdateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs);

                Application.Exit();
            }
            else if (result == DialogResult.Abort)
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                  lang.getString("autoUpdater_msg_terminated"),
                                  lang.getString("autoUpdater_msg_terminated_title"),
                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                  lang.getString("autoUpdater_msg_failed"),
                                  lang.getString("autoUpdater_msg_failed_title"),
                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        /// <summary>
        /// Checks for/parses update.xml on server
        /// </summary>
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            AutoUpdatable application = (AutoUpdatable)e.Argument;

            // Check for update on server
            if (!AutoUpdateXml.ExistsOnServer(application.UpdateXmlLocation))
            {
                e.Cancel = true;
            }
            else             // Parse update xml
            {
                e.Result = AutoUpdateXml.Parse(application.UpdateXmlLocation, application.ApplicationID);
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates a new AutoUpdateAcceptForm
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="updateInfo"></param>
        internal AutoUpdateAcceptForm(AutoUpdatable applicationInfo, AutoUpdateXml updateInfo)
        {
            InitializeComponent();

            this.applicationInfo = applicationInfo;
            this.updateInfo      = updateInfo;
            this.lang            = applicationInfo.Lang;

            this.Text = lang.getString("update_found_title");

            this.lblAppName.Text          = lang.getString("app_name");
            this.lblUpdateAvail.Text      = lang.getString("update_found");
            this.lblNewVersion_label.Text = lang.getString("update_new");
            this.lblCurVersion_label.Text = lang.getString("update_cur");
            this.lblDescription.Text      = lang.getString("update_description");

            this.btnYes.Text = lang.getString("button_ok");
            this.btnNo.Text  = lang.getString("button_cancel");

            // Assigns the icon if it isn't null
            if (this.applicationInfo.ApplicationIcon != null)
            {
                this.Icon = this.applicationInfo.ApplicationIcon;
            }

            // Adds the current version # to the form
            this.lblCurVersion.Text = applicationInfo.ApplicationAssembly.GetName().Version.ToString();

            // Adds the update version # to the form
            this.lblNewVersion.Text = this.updateInfo.Version.ToString();

            // Fill in update info
            this.txtDescription.Text = updateInfo.Description;
            //this.txtDescription.ScrollBarAppearance = DevComponents.DotNetBar.eScrollBarAppearance.ApplicationScroll;
            //Size txtDescription_size = this.txtDescription.Size;
            //this.txtDescription.Size = new Size(txtDescription_size.Width /3, txtDescription_size.Height /3);

            // DotNetBar richTextBoxEx doesn't appear correctly under high DPI
            // Use normal richTextBox instead!
            this.richTextBox1.Text = updateInfo.Description;

            // DPI settings
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode       = AutoScaleMode.Dpi;

            // Set UI Font according to language
            lang.setFont(this.Controls);
            Font = new Font(lang.getFont(), Font.Size, Font.Style);
        }
コード例 #5
0
        /// <summary>
        /// Creates a new AutoUpdateAcceptForm
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="updateInfo"></param>
        internal AutoUpdateAcceptForm(AutoUpdatable applicationInfo, AutoUpdateXml updateInfo)
        {
            InitializeComponent();

            this.applicationInfo = applicationInfo;
            this.updateInfo = updateInfo;
            this.lang = applicationInfo.Lang;

            this.Text = lang.getString("update_found_title");

            this.lblAppName.Text = this.applicationInfo.ApplicationName;
            this.lblUpdateAvail.Text = lang.getString("update_found");
            this.lblNewVersion_label.Text = lang.getString("update_new");
            this.lblCurVersion_label.Text = lang.getString("update_cur");
            this.lblDescription.Text = lang.getString("update_description");

            this.btnYes.Text = lang.getString("button_ok");
            this.btnNo.Text = lang.getString("button_cancel");

            // Assigns the icon if it isn't null
            if (this.applicationInfo.ApplicationIcon != null)
                this.Icon = this.applicationInfo.ApplicationIcon;

            // Adds the current version # to the form
            this.lblCurVersion.Text = applicationInfo.ApplicationAssembly.GetName().Version.ToString();

            // Adds the update version # to the form
            this.lblNewVersion.Text = this.updateInfo.Version.ToString();

            // Fill in update info
            this.txtDescription.Text = updateInfo.Description;
            //this.txtDescription.ScrollBarAppearance = DevComponents.DotNetBar.eScrollBarAppearance.ApplicationScroll;
            //Size txtDescription_size = this.txtDescription.Size;
            //this.txtDescription.Size = new Size(txtDescription_size.Width /3, txtDescription_size.Height /3);

            // DotNetBar richTextBoxEx doesn't appear correctly under high DPI
            // Use normal richTextBox instead!
            this.richTextBox1.Text = updateInfo.Description;

            // DPI settings
            AutoScaleDimensions = new SizeF(96F, 96F);
            AutoScaleMode = AutoScaleMode.Dpi;

            // Set UI Font according to language
            lang.setFont(this.Controls);
            Font = new Font(lang.getFont(), Font.Size, Font.Style);
        }
コード例 #6
0
ファイル: AutoUpdater.cs プロジェクト: henryxrl/SimpleEpub2
        /// <summary>
        /// Downloads update and installs the update
        /// </summary>
        /// <param name="update">The update xml info</param>
        private void DownloadUpdate(AutoUpdateXml update)
        {
            AutoUpdateDownloadForm form = new AutoUpdateDownloadForm(this.applicationInfo, update.Uri, update.MD5, this.applicationInfo.ApplicationIcon);
            DialogResult result = form.ShowDialog(this.applicationInfo.Context);

            // Download update
            if (result == DialogResult.OK)
            {
                String currentPath = this.applicationInfo.ApplicationAssembly.Location;
                String newPath = Path.GetDirectoryName(currentPath) + "\\" + update.FileName;

                // "Install" it
                AutoClosingMessageBox.Show(this.applicationInfo.Context,
                                            lang.getString("autoUpdater_msg_success"),
                                            lang.getString("autoUpdater_msg_success_title"),
                                            5000);
                UpdateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs);

                Application.Exit();
            }
            else if (result == DialogResult.Abort)
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                    lang.getString("autoUpdater_msg_terminated"),
                                    lang.getString("autoUpdater_msg_terminated_title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                    lang.getString("autoUpdater_msg_failed"),
                                    lang.getString("autoUpdater_msg_failed_title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }