Esempio n. 1
0
        /// <summary>
        /// Handles the UpdateAvailable event of the applicationUpdater control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UpdatesAvailableEventArgs"/> instance containing the event data.</param>
        void applicationUpdater_UpdateAvailable(object sender, UpdatesAvailableEventArgs e)
        {
            ApplicationUpdater ai = (ApplicationUpdater)sender;

            if (ai.UpdatesAvailable)
            {
                // hide the splash if its visible
                Util.HideSplashScreen( );
                UpdateInformationForm uif = new UpdateInformationForm(ai);
                if (uif.ShowDialog(_owner) == DialogResult.OK)
                {
                    string thisPath   = this.GetType( ).Assembly.Location;
                    string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath, ai.UpdateInfoList.GetLatestVersion( ), string.Empty);
                    Console.WriteLine(attrString);
                    Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString);
                    Application.Exit( );
                }
            }
        }
Esempio n. 2
0
        private void updatePlugin_Click(object sender, EventArgs e)
        {
            if (this.pluginsList.SelectedItems.Count > 0)
            {
                AssemblyListViewItem alvi = this.pluginsList.SelectedItems[0] as AssemblyListViewItem;
                ApplicationUpdater   au   = new ApplicationUpdater();
                au.Version = alvi.Version;

                this.pluginUpdateStatus.Text = "Checking updates for " + alvi.Text;

                au.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (delegate(object s, UpdatesAvailableEventArgs uae) {
                    ApplicationUpdater ai        = (ApplicationUpdater)s;
                    ai.UpdateName                = alvi.Text;
                    this.pluginUpdateStatus.Text = "Updates available...";
                    if (ai.UpdatesAvailable)
                    {
                        UpdateInformationForm uif = new UpdateInformationForm(ai);
                        if (uif.ShowDialog(null) == DialogResult.OK)
                        {
                            string thisPath   = this.GetType().Assembly.Location;
                            string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat,
                                                              CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath,
                                                              ai.UpdateInfoList.GetLatestVersion());
                            Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString);
                            Application.Exit();
                        }
                    }
                });

                au.UpdateException += new EventHandler <ExceptionEventArgs> (delegate(object s, ExceptionEventArgs ex) {
                    MessageBox.Show(ex.Exception.Message, "Update of plugin error");
                });

                au.CheckForUpdatesByUrl(alvi.UpdateUrl);
                this.pluginUpdateStatus.Text = string.Empty;
            }
        }