/// <summary> /// Creates formatted FlowDocument /// </summary> protected virtual void GetFlowDocumentFromNavigatorAsync(XPathNavigator navigator, Story story, FlowDocumentStyleProvider styleProvider, object userState) { PrintableStoryFlowDocument flowDocument = new PrintableStoryFlowDocument(); MsdnStoryToFlowDocumentConverter.ApplyStyle(flowDocument, GetFlowDocumentStyle(styleProvider)); // Headline does not require async fetches, so the base class method can be used CreateHeadline(flowDocument, navigator, story, styleProvider); CreateBodyAsync(flowDocument, navigator, story, styleProvider, userState); }
protected virtual Paragraph CreateCodeParagraph(XPathNavigator codeNavigator, Story story, FlowDocumentStyleProvider styleProvider) { Paragraph paragraph = new Paragraph(new Run()); // Navigate paragraph using a duplicate navigator. Step inside paragraph's first child before beginning navigation XPathNavigator parsingNavigator = codeNavigator.CreateNavigator(); if (parsingNavigator.NodeType == XPathNodeType.Element && parsingNavigator.Name.ToLower(CultureInfo.InvariantCulture) == "code" && parsingNavigator.MoveToFirstChild()) { ParseContent(parsingNavigator.CreateNavigator(), paragraph.ContentStart, styleProvider); } MsdnStoryToFlowDocumentConverter.ApplyStyle(paragraph, GetArticleCodeStyle(styleProvider)); return(paragraph); }
/// <summary> /// Creates a paragraph with a PrintableStoryImageControl to display images, and adds the control to the list of pending image requests /// </summary> protected virtual Paragraph CreateImageParagraph(Story story, ImageReference imageReference, ImageData imageData, FlowDocumentStyleProvider styleProvider) { PrintableStoryImageControl imageControl = new PrintableStoryImageControl(); imageControl.ImageReference = imageReference; imageControl.ImageData = imageData; imageControl.Story = story; MsdnStoryToFlowDocumentConverter.ApplyStyle(imageControl, GetImageControlStyle(styleProvider)); // Add the image control to the list of pending image request states if (_pendingImageRequestStates == null) { _pendingImageRequestStates = new List <PrintableStoryImageControl>(); } _pendingImageRequestStates.Add(imageControl); HeightAligner heightAligner = CreateHeightAligner(imageControl, WhitespaceDistribution.Split, styleProvider); Figure imageFigure = new Figure(new BlockUIContainer(heightAligner)); // Image figure may not be styled since we need to set its content and anchoring if (imageData.Width < 600) { imageFigure.Width = new FigureLength(1, FigureUnitType.Column); imageFigure.VerticalAnchor = FigureVerticalAnchor.ContentBottom; imageFigure.HorizontalAnchor = FigureHorizontalAnchor.ColumnCenter; } else { imageFigure.Width = new FigureLength(2, FigureUnitType.Column); imageFigure.VerticalAnchor = FigureVerticalAnchor.ContentBottom; imageFigure.HorizontalAnchor = FigureHorizontalAnchor.ContentLeft; } Paragraph imageParagraph = new Paragraph(imageFigure); MsdnStoryToFlowDocumentConverter.ApplyStyle(imageParagraph, GetImageContainerStyle(styleProvider)); return(imageParagraph); }