Пример #1
0
        private async void downloadAndDisplayAllReleaseNotes(AppCastItem[] items, AppCastItem latestVersion, string initialHTML)
        {
            _sparkle.LogWriter.PrintMessage("Preparing to initialize release notes...");
            StringBuilder sb = new StringBuilder(initialHTML);

            foreach (AppCastItem castItem in items)
            {
                _sparkle.LogWriter.PrintMessage("Initializing release notes for {0}", castItem.Version);
                // TODO: could we optimize this by doing multiple downloads at once?
                var releaseNotes = await GetReleaseNotes(castItem);

                sb.Append(string.Format(_separatorTemplate,
                                        castItem.Version,
                                        castItem.PublicationDate.ToString("D"), // was dd MMM yyyy
                                        releaseNotes,
                                        latestVersion.Version.Equals(castItem.Version) ? "#ABFF82" : "#AFD7FF"));
            }
            sb.Append("</body>");

            string fullHTML = sb.ToString();

            ReleaseNotesBrowser.Invoke((MethodInvoker) delegate
            {
                // see https://stackoverflow.com/a/15209861/3938401
                ReleaseNotesBrowser.Navigate("about:blank");
                ReleaseNotesBrowser.Document.OpenNew(true);
                ReleaseNotesBrowser.Document.Write(fullHTML);
                ReleaseNotesBrowser.DocumentText = fullHTML;
            });
            _sparkle.LogWriter.PrintMessage("Done initializing release notes!");
        }
Пример #2
0
        private async void LoadReleaseNotes(List <AppCastItem> items, bool isforallversions)
        {
            AppCastItem latestVersion = items.OrderByDescending(p => p.Version).FirstOrDefault();
            string      releaseNotes  = null;

            if (!isforallversions)
            {
                releaseNotes = await _releaseNotesGrabber.DownloadAllReleaseNotes(items, latestVersion, _cancellationToken);
            }
            else
            {
                releaseNotes = await _releaseNotesGrabber.DownloadAllReleaseNotesWithButtons(items, latestVersion, _cancellationToken);
            }
            ReleaseNotesBrowser.Invoke((MethodInvoker) delegate
            {
                // see https://stackoverflow.com/a/15209861/3938401
                ReleaseNotesBrowser.ObjectForScripting = this;


                ReleaseNotesBrowser.Navigate("about:blank");
                ReleaseNotesBrowser.Document.OpenNew(true);
                ReleaseNotesBrowser.Document.Write(releaseNotes);
                ReleaseNotesBrowser.DocumentText = releaseNotes;
            });
        }
 private void ReleaseNotesBrowser_Navigated(object sender, NavigationEventArgs e)
 {
     if (!_hasFinishedNavigatingToAboutBlank)
     {
         ReleaseNotesBrowser.NavigateToString(_notes);
         _hasFinishedNavigatingToAboutBlank = true;
     }
 }
 private void ReleaseNotesBrowser_Loaded(object sender, RoutedEventArgs e)
 {
     // see https://stackoverflow.com/a/15209861/3938401
     ReleaseNotesBrowser.Loaded -= ReleaseNotesBrowser_Loaded;
     ReleaseNotesBrowser.Dispatcher.Invoke(() =>
     {
         ReleaseNotesBrowser.NavigateToString("about:blank");
     });
 }
 /// <summary>
 /// Show the release notes to the end user. Release notes should be in HTML.
 ///
 /// There is some bizarre thing where the WPF browser doesn't navigate to the release notes unless you successfully navigate to
 /// about:blank first. I don't know why. I feel like this is a Terrible Bad Fix, but...it works for now...
 /// </summary>
 /// <param name="htmlNotes">The HTML notes to show to the end user</param>
 public void ShowReleaseNotes(string htmlNotes)
 {
     _notes = htmlNotes;
     ReleaseNotesBrowser.Dispatcher.Invoke(() =>
     {
         if (ReleaseNotesBrowser.IsLoaded)
         {
             if (_hasFinishedNavigatingToAboutBlank)
             {
                 ReleaseNotesBrowser.NavigateToString(_notes);
             }
             // else will catch up when navigating to about:blank is done
         }
         else
         {
             // don't do anything until the web browser is loaded
             ReleaseNotesBrowser.Loaded += ReleaseNotesBrowser_Loaded;
         }
     });
 }