コード例 #1
0
        protected void AddWebFigureLinkToBody(FlowDocument flowDocument, XPathNavigator navigator, Story story, FlowDocumentStyleProvider styleProvider)
        {
            MsdnStoryImageHyperlink hyperlink = GetLinkToWebFigures(story, navigator, styleProvider);

            if (hyperlink != null)
            {
                Paragraph webFigureDownloadPara = new Paragraph();
                ApplyStyle(webFigureDownloadPara, GetBodyTextParagraphStyle(styleProvider, 0));
                webFigureDownloadPara.Inlines.Add(hyperlink);
                flowDocument.Blocks.Add(webFigureDownloadPara);
            }
        }
コード例 #2
0
        protected MsdnStoryImageHyperlink GetLinkToWebFigures(Story story, XPathNavigator navigator, FlowDocumentStyleProvider styleProvider)
        {
            MsdnStoryImageHyperlink hyperlink        = null;
            XPathNavigator          figuresNavigator = navigator.SelectSingleNode("Figures");

            if (figuresNavigator != null)
            {
                // Figures exist, add link
                hyperlink = new MsdnStoryImageHyperlink(GetMagazineArticleWebFigureUri(story), story);
                hyperlink.Inlines.Add(new Run("See all code figures for this article"));
                hyperlink.ToolTip          = "View Code Figures In Browser";
                hyperlink.RequestNavigate += ((MsdnViewManager)ServiceProvider.ViewManager).OnImageHyperlinkRequestNavigate;
            }
            return(hyperlink);
        }
コード例 #3
0
        /// <summary>
        /// Static handler for image hyperlink's request navigate event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnImageHyperlinkRequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            // Always set handled to true because hyperlinks to which this event is attached are not real weblinks and require special handling.
            // Don't let this go up to the navigation service
            e.Handled = true;
            MsdnStoryImageHyperlink hyperlink = sender as MsdnStoryImageHyperlink;

            if (hyperlink != null)
            {
                if (hyperlink.IsImageReferenceLink)
                {
                    // Link to an image reference, open view
                    OpenImageViewerWindow(hyperlink.ImageReference, hyperlink.Story);
                }
                else
                {
                    // Not an image reference, this is a web link. Open web figure viewer window
                    OpenWebFigureViewerWindow(hyperlink.NavigateUri, hyperlink.Story);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates a an MsdnStoryImageHyperlink element with a link to the image Uri/ImageReference
        /// </summary>
        protected MsdnStoryImageHyperlink CreateImageHyperlink(XPathNavigator navigator, TextPointer textPointer, FlowDocumentStyleProvider styleProvider)
        {
            MsdnStoryImageHyperlink hyperlink = null;

            if (navigator != null)
            {
                // If it's a figure containing code/ javascript, it will be referenced using the "ref" attribute
                Run    run          = new Run(XmlHelper.GetNavigatorText(navigator));
                string webFigureRef = navigator.GetAttribute("ref", String.Empty);
                if (!String.IsNullOrEmpty(webFigureRef) && _webFigureStore.ContainsKey(webFigureRef))
                {
                    // 'ref' attribute found, try to match it with a web figure Uri
                    Uri uri = _webFigureStore[webFigureRef];
                    hyperlink         = new MsdnStoryImageHyperlink(uri, Story, run, textPointer);
                    hyperlink.ToolTip = "View Code In Browser";
                }
                else
                {
                    // No attribute matched. Try to match figure text to an image caption from an Image element in the doc
                    string text = XmlHelper.GetNavigatorText(navigator);
                    if (!String.IsNullOrEmpty(text) && _imageReferenceFigureStore.ContainsKey(text))
                    {
                        ImageReference imageReference = _imageReferenceFigureStore[text];
                        hyperlink         = new MsdnStoryImageHyperlink(imageReference, Story, run, textPointer);
                        hyperlink.ToolTip = "View Image";
                    }
                }

                if (hyperlink != null)
                {
                    ApplyStyle(hyperlink, GetHyperlinkStyle(styleProvider));
                    hyperlink.RequestNavigate += ((MsdnViewManager)ServiceProvider.ViewManager).OnImageHyperlinkRequestNavigate;
                }
            }

            return(hyperlink);
        }