Exemplo n.º 1
0
        /// <summary>
        /// If we have a valid release and it is later than the current running release
        /// then display the Upgrade dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        static void DoWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            UpgradeRelease release = e.Result as UpgradeRelease;

            if (release == null)
            {
                isRunning = false;

                if (isUserInvoked)
                {
                    isUserInvoked = false;

                    MessageWindow.Show(
                        Resx.NoUpdateConnection, Resx.I_ApplicationTitle,
                        MessageBoxButton.OK, MessageWindowImage.OK);
                }

                return;
            }

            if (!release.Dispatcher.CheckAccess())
            {
                release.Dispatcher.BeginInvoke((Action) delegate { DoWorkCompleted(sender, e); });
                return;
            }

            if (release.IsUpgradeAvailable)
            {
                Logger.WriteLine(Logger.Level.Info, "Upgrade",
                                 $"Upgrade is available, {release.CurrentVersion} -> {release.ReleaseVersion}");

                isRunning = false;
                UpgradeWindow dialog = new UpgradeWindow(release);
                dialog.ShowDialog();
            }
            else if (isUserInvoked)
            {
                Logger.WriteLine(Logger.Level.Info, "Upgrade",
                                 $"Upgrade is not available for {release.CurrentVersion}");

                isRunning     = false;
                isUserInvoked = false;

                MessageWindow.Show(
                    Resx.NoUpgrades, Resx.I_ApplicationTitle,
                    MessageBoxButton.OK, MessageWindowImage.OK);
            }
            else
            {
                Logger.WriteLine(Logger.Level.Info, "Upgrade",
                                 $"Running version {release.CurrentVersion}");

                isRunning = false;
            }
        }
Exemplo n.º 2
0
        //========================================================================================
        // Mehtods
        //========================================================================================

        /// <summary>
        /// Open a Web browser and navigate to the release download page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void DoUpgrade(object sender, RoutedEventArgs e)
        {
            UpgradeRelease release = this.DataContext as UpgradeRelease;

            ProcessStartInfo info = new ProcessStartInfo(release.Uri);

            info.WindowStyle = ProcessWindowStyle.Normal;

            try
            {
                Process.Start(info);
            }
            catch (Exception) { }

            //Application.Current.Shutdown();

            this.Close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance with the specified upgrade release details.
        /// </summary>
        /// <param name="release"></param>

        public UpgradeWindow(UpgradeRelease release)
            : this()
        {
            this.DataContext = release;

            // generate a local temporary
            string tmp  = Path.GetTempFileName();
            string path = Path.Combine(
                Path.GetDirectoryName(tmp),
                Path.GetFileNameWithoutExtension(tmp) + ".htm");

            // rename the file from .tmp to .htm
            File.Move(tmp, path);

            // populate the file with our custom HTML
            File.WriteAllText(path,
                              String.Format(Properties.Resources.I_ReleaseHtmFormat, release.Description));

            // navigate to the temporary HTML file
            this.notesBox.Navigate(new Uri(path, UriKind.RelativeOrAbsolute));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialize a new instance with the specified upgrade release details.
        /// </summary>
        /// <param name="release"></param>
        public UpgradeWindow(UpgradeRelease release)
            : this()
        {
            this.DataContext = release;

            // generate a local temporary
            string tmp = Path.GetTempFileName();
            string path = Path.Combine(
                Path.GetDirectoryName(tmp),
                Path.GetFileNameWithoutExtension(tmp) + ".htm");

            // rename the file from .tmp to .htm
            File.Move(tmp, path);

            // populate the file with our custom HTML
            File.WriteAllText(path,
                String.Format(Properties.Resources.I_ReleaseHtmFormat, release.Description));

            // navigate to the temporary HTML file
            this.notesBox.Navigate(new Uri(path, UriKind.RelativeOrAbsolute));
        }