예제 #1
0
        /// <summary>
        /// Loads HTML file from resource assembly and replace it's key values by base64 files
        /// </summary>
        /// <param name="htmlPage">Contains filename and resources to be loaded in page</param>
        private void LoadWebBrowser(HtmlPage htmlPage)
        {
            var bodyHtmlPage = ResourceUtilities.LoadContentFromResources(htmlPage.FileName, GetType().Assembly, false, false);

            bodyHtmlPage = LoadResouces(bodyHtmlPage, htmlPage.Resources);
            bodyHtmlPage = LoadResourceAndReplaceByKey(bodyHtmlPage, "#fontStyle", mainFontStylePath);

            webBrowser.NavigateToString(bodyHtmlPage);
        }
        /// <summary>
        /// If target is local file, we load & cache the content of the file
        /// avoiding doing IO in the View layer
        /// </summary>
        /// <param name="e">The event to handle.</param>
        private void HandleLocalResource(OpenDocumentationLinkEventArgs e)
        {
            try
            {
                string targetContent;
                Uri    link;
                switch (e)
                {
                case OpenNodeAnnotationEventArgs openNodeAnnotationEventArgs:
                    var mdLink = packageManagerDoc.GetAnnotationDoc(
                        openNodeAnnotationEventArgs.MinimumQualifiedName,
                        openNodeAnnotationEventArgs.PackageName);

                    link          = string.IsNullOrEmpty(mdLink) ? new Uri(String.Empty, UriKind.Relative) : new Uri(mdLink);
                    targetContent = CreateNodeAnnotationContent(openNodeAnnotationEventArgs);
                    break;

                case OpenDocumentationLinkEventArgs openDocumentationLink:
                    link          = openDocumentationLink.Link;
                    targetContent = ResourceUtilities.LoadContentFromResources(openDocumentationLink.Link.ToString(), GetType().Assembly);
                    break;

                default:
                    // Navigate to unsupported
                    targetContent = null;
                    link          = null;
                    break;
                }

                if (targetContent == null)
                {
                    NavigateToContentMissingPage();
                }
                else
                {
                    this.content = targetContent;
                    this.Link    = link;
                }
            }
            catch (FileNotFoundException)
            {
                NavigateToContentMissingPage();
                return;
            }
            catch (TargetException)
            {
                NavigateToNoContentPage();
                return;
            }
            catch (Exception ex)
            {
                NavigateToInternalErrorPage(ex.Message + "<br>" + ex.StackTrace);
                return;
            }
            this.shouldLoadDefaultContent = false;
        }
        public void NavigateToInternalErrorPage(string errorDetails)
        {
            this.content = ResourceUtilities.LoadContentFromResources(BUILT_IN_CONTENT_INTERNAL_ERROR_FILENAME, GetType().Assembly);

            // if additional details about the error were passed in,
            // update the error page HTML with that content
            if (!string.IsNullOrWhiteSpace(errorDetails))
            {
                this.content = ReplaceTemplateInContentWithString(errorDetails);
            }
            else
            {
                this.content = ReplaceTemplateInContentWithString(Resources.InternalErrorNoDetailsAvailable);
            }

            UpdateLinkSafely(BUILT_IN_CONTENT_INTERNAL_ERROR_FILENAME);
        }
 public void NavigateToNoContentPage()
 {
     this.content = ResourceUtilities.LoadContentFromResources(BUILT_IN_CONTENT_NO_CONTENT_FILENAME, GetType().Assembly);
     UpdateLinkSafely(BUILT_IN_CONTENT_NO_CONTENT_FILENAME);
 }