) GetTextElementInsertionAndDeletionPositions()
        {
            // find the first block in FlowDocument that has to be exchanged

            var firstLevelTextElementsToDelete = new List <System.Windows.Documents.Block>();

            System.Windows.Documents.Block firstLevelTextElementToInsertBefore = null;
            System.Windows.Documents.Block firstLevelTextElementToInsertAfter  = null;
            System.Windows.Documents.Block previousBlockWithTag = null;
            foreach (var blk in FlowDocument.Blocks)
            {
                if (blk.Tag == null) // blk.Tag==null indicates that this is a block that has been changed and should be removed (during exchanging the of the tags the tag of this block is assigned null)
                {
                    if (null == firstLevelTextElementToInsertAfter)
                    {
                        firstLevelTextElementToInsertAfter = previousBlockWithTag;
                    }
                    firstLevelTextElementToInsertBefore = null;
                    firstLevelTextElementsToDelete.Add(blk);
                }
                else
                {
                    if (null == firstLevelTextElementToInsertBefore && firstLevelTextElementsToDelete.Count > 0)
                    {
                        firstLevelTextElementToInsertBefore = blk;
                    }
                    previousBlockWithTag = blk; // assign previous block here to make sure it is not in the list of elements to delete
                }
            }

            return(firstLevelTextElementToInsertBefore, firstLevelTextElementToInsertAfter, firstLevelTextElementsToDelete);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">report data</param>
        /// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
        /// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report header section</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception>
        public ReportPaginator(ReportDocument report, ReportData data)
        {
            _report = report;
            _data = data;

            _flowDocument = report.CreateFlowDocument();
            _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight);

            if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height");
            if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width");

            _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument);
            ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader));
            if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section");
            if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0];
            ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter));
            if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section");
            if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0];

            _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator;

            // remove header and footer in our working copy
            Block block = _flowDocument.Blocks.FirstBlock;
            while (block != null)
            {
                Block thisBlock = block;
                block = block.NextBlock;
                if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock);
            }

            // get report context values
            _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue));

            FillData();
        }
示例#3
0
 private void AddBlock(Block block, TextSelection selection)
 {
     if (selection == null || selection.End == null)
         AddBlockToEnd(block);
     else
         _flowDocument.Blocks.InsertAfter(selection.End.GetInsertionPosition(LogicalDirection.Forward).Paragraph, block);
 }
示例#4
0
        //-------------------------------------------------------------------
        //
        // Constructors
        //
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Creates a new AnchoredBlock instance.
        /// </summary>
        /// <param name="block">
        /// Optional child of the new AnchoredBlock, may be null.
        /// </param>
        /// <param name="insertionPosition">
        /// Optional position at which to insert the new AnchoredBlock. May
        /// be null.
        /// </param>
        protected AnchoredBlock(Block block, TextPointer insertionPosition)
        {
            if (insertionPosition != null)
            {
                insertionPosition.TextContainer.BeginChange();
            }
            try
            {
                if (insertionPosition != null)
                {
                    // This will throw InvalidOperationException if schema validity is violated.
                    insertionPosition.InsertInline(this);
                }

                if (block != null)
                {
                    this.Blocks.Add(block);
                }
            }
            finally
            {
                if (insertionPosition != null)
                {
                    insertionPosition.TextContainer.EndChange();
                }
            }
        }
示例#5
0
        public static void AddBlock(Block from, FlowDocument to)
        {
            if (from != null)
              {
            //if (from is ItemsContent)
            //{
            //  ((ItemsContent)from).RunBeforeCopy();
            //}
            //else
            {
              TextRange range = new TextRange(from.ContentStart, from.ContentEnd);

              MemoryStream stream = new MemoryStream();

              System.Windows.Markup.XamlWriter.Save(range, stream);

              range.Save(stream, DataFormats.XamlPackage);

              TextRange textRange2 = new TextRange(to.ContentEnd, to.ContentEnd);

              textRange2.Load(stream, DataFormats.XamlPackage);
            }

              }
        }
        public BlockComponent(Block block)
        {
            if (block == null) throw new ArgumentNullException(nameof(block));

            Block = block;

            SubscribeForEvents();
        }
        public BlockComponent(string title, Block block)
            : base(title)
        {
            if (block == null) throw new ArgumentNullException(nameof(block));

            Block = block;

            SubscribeForEvents();
        }
示例#8
0
 private static IEnumerable<string> ReadRuns(Block block)
 {
     var result = new List<string>();
     if (block is Paragraph)
     {
         result.AddRange((block as Paragraph).Inlines.OfType<Run>().Select(inline => inline.Text.Trim()));
     }
     return result;
 }
 public XmlElement Serialize(Block block, XmlDocument xmlDocument)
 {
     var image = (ImageBlock)block;
     var imageElement = xmlDocument.CreateElement("Image");
     var srcAttribute = xmlDocument.CreateAttribute("Src");
     srcAttribute.InnerText = Path.GetFileName(image.Source.ToString());
     imageElement.Attributes.Append(srcAttribute);
     return imageElement;
 }
示例#10
0
 public Block readSocket(Block source, Block destination)
 {
     StackPanel innards = (StackPanel)source.innerPane.Children.ElementAt(0);
     List<System.Windows.UIElement> components = innards.Children.ToList();
     Debug.WriteLine("+" + components.ElementAt(0));
     destination.innerPane.Children.Clear();
     destination.innerPane.Children.Insert(0, source.innerPane.Children.ElementAt(0));
     return destination;
 }
 public XmlElement Serialize(Block block, XmlDocument xmlDocument)
 {
     var formula = (FormulaBlock)block;
     var formulaElement = xmlDocument.CreateElement("Formula");
     var texAttribute = xmlDocument.CreateAttribute("Tex");
     texAttribute.InnerText = formula.Formula;
     formulaElement.Attributes.Append(texAttribute);
     return formulaElement;
 }
示例#12
0
文件: Section.cs 项目: JianwenSun/cc
        /// <summary>
        /// Initializes a new instance of a Section class specifying a first Block child for it.
        /// </summary>
        /// <param name="block">
        /// Block element added to a Section as its first child.
        /// </param>
        public Section(Block block)
            : base()
        {
            if (block == null)
            {
                throw new ArgumentNullException("block");
            }

            this.Blocks.Add(block);
        }
        public void Push(Block block, BlockCollection blocks, IEnumerable <MarkdownObject> children)
        {
            var currentBlocks = Blocks;

            Blocks.Add(block);
            Blocks = blocks;
            foreach (var child in children)
            {
                Write(child);
            }
            Blocks = currentBlocks;
        }
示例#14
0
 private void AddBlock(Block block)
 {
     if (scroll == null)
     scroll = reportViewer.Template.FindName("PART_ContentHost", reportViewer) as ScrollViewer;
       if (scroll.ScrollableHeight - scroll.ExtentHeight < 5)
       {
     report.Blocks.Add(block);
     scroll.ScrollToEnd();
       }
       else
     report.Blocks.Add(block);
 }
示例#15
0
 public MultiPartBit(string[] strings, Brush[] brushes)
 {
     int iC = Math.Min(strings.Length, brushes.Length);
     Span s = new Span();
     for (int i = 0; i < iC; i++)
     {
         Span s2 = new Span(new Run(strings[i]));
         s2.Foreground = brushes[i];
         s.Inlines.Add(s2);
     }
     _b = new Paragraph(s);
     
 }
 /// <summary>Adds XAML content to a RichTextBox.</summary>
 /// <param name="richTextBox">The textbox to add to.</param>
 /// <param name="xaml">The block to add.</param>
 /// <remarks>This method effectively handles a Section block element if specified (adding all child Blocks to the textbox).</remarks>
 public static void AddXaml(this RichTextBox richTextBox, Block xaml)
 {
     if (richTextBox == null) throw new ArgumentNullException("richTextBox");
     if (xaml == null) throw new ArgumentNullException("xaml");
     if (xaml is Section)
     {
         AddBlocks(richTextBox, ((Section)xaml).Blocks);
     }
     else
     {
         richTextBox.Blocks.Add(xaml);
     }
 }
        // ReSharper restore InconsistentNaming

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">report data</param>
        /// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
        /// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report header section</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception>
        public ReportPaginator(ReportDocument report, ReportData data, Action<int, int> PageGeneratedCallBack = null, FlowDocument flowDocument = null)
        {
            _report = report;
            _data = data;
            _pageGeneratedCallBack = PageGeneratedCallBack;

            _flowDocument = flowDocument;
            if (_flowDocument == null) 
                _flowDocument = report.CreateFlowDocument();

            _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight);

            if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height");
            if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width");

            _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument);
            ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader));
            if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section");
            if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0];
            ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter));
            if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section");
            if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0];

            _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator;

            // remove header and footer in our working copy
            Block block = _flowDocument.Blocks.FirstBlock;
            while (block != null)
            {
                Block thisBlock = block;
                block = block.NextBlock;
                if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock);
            }

            // get report context values
            _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue));

            FillData();

            /*Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    Window aa = new Window();
                    FlowDocumentPageViewer bb = new FlowDocumentPageViewer();
                    bb.Document = _flowDocument;
                    aa.Content = bb;
                    aa.SizeToContent = SizeToContent.WidthAndHeight;
                    aa.ShowDialog();
                }));*/
        }
        /// <summary>
        /// Create a new <see cref="PowerEntry"/>. All arguments to this method are assumed 
        /// to be escaped for HTML already.
        /// </summary>
        /// <param name="heading">
        /// The heading <see cref="Block"/>. This cannot be null.
        /// </param>
        /// <param name="flavorText">
        /// The flavor text <see cref="Block"/>. This may be null.
        /// </param>
        /// <param name="detail">
        /// The detail <see cref="Block"/>.  This cannot be null.
        /// </param>
        /// <param name="modifierSource">
        /// The <see cref="ModifierSource"/> that this <see cref="PowerEntry"/> was created for.
        /// This may be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Only <paramref name="modifierSource"/> can be null.
        /// </exception>
        public PowerEntry(Block heading, Block flavorText, Block detail, ModifierSource modifierSource)
        {
            if (heading == null)
            {
                throw new ArgumentNullException("heading");
            }
            if (detail == null)
            {
                throw new ArgumentNullException("detail");
            }

            Heading = heading;
            FlavorText = flavorText;
            Detail = detail;
            ModifierSource = modifierSource;
        }
        private bool Accept(Block block)
        {
            if (!TryMatch(block)) return false;

            if (block is Table)
            {
                foreach (var inner in ((Table) block).RowGroups
                    .SelectMany(x => x.Rows)
                    .SelectMany(x => x.Cells)
                    .SelectMany(x => x.Blocks))
                {
                    if (!Accept(inner)) return false;
                }

                return true;
            }

            if (block is Paragraph)
            {
                foreach (var inner in  ((Paragraph) block).Inlines)
                {
                    if (!TryMatch(inner)) return false;
                }

                return true;
            }

            if (block is BlockUIContainer)
            {
                // ignore children
                return true;
            }

            if (block is List)
            {
                foreach (var inner in  ((List) block).ListItems.SelectMany(listItem => listItem.Blocks))
                {
                    if (!Accept(inner)) return false;
                }

                return true;
            }

            throw new InvalidOperationException("Unknown block type: " + block.GetType());
        }
 public XmlElement Serialize(Block block, XmlDocument xmlDocument)
 {
     var drawerBlock = (DrawerBlock) block;
     var drawerElement = xmlDocument.CreateElement("Drawing");
     foreach(SmoothableStroke stroke in drawerBlock.Drawer.Strokes)
     {
         var strokeElement = xmlDocument.CreateElement("Stroke");
         foreach (var point in stroke.Points)
         {
             var pointElement = xmlDocument.CreateElement("Point");
             pointElement.SetAttribute("X", point.X.ToString()); //TODO DrawingAttributes
             pointElement.SetAttribute("Y", point.Y.ToString());
             strokeElement.AppendChild(pointElement);
         }
         drawerElement.AppendChild(strokeElement);
     }
     return drawerElement;
 }
示例#21
0
 public void FormatBlock(FlowDocument doc, Block block, StringBuilder buf, int indent)
 {
     // indent
      buf.Append (' ', indent);
      buf.AppendFormat (
     "{0} {1} to {2}",
     block.GetType ().Name + block.GetHashCode (),
     block.ContentStart.CompareTo (doc.ContentStart),
     block.ContentEnd.CompareTo (doc.ContentStart));
      buf.AppendLine ();
      if (block is Section)
      {
     FormatBlocks (doc, ((Section)block).Blocks, buf, indent + 3);
      }
      else if (block is Paragraph)
      {
     FormatInlines (doc, ((Paragraph)block).Inlines, buf, indent + 3);
      }
 }
示例#22
0
		private Block Clone(Block block)
		{
			var paragraph = block as Paragraph;
			if (paragraph != null)
			{
				var newParagraph = new Paragraph();
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.PaddingProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.PaddingProperty, paragraph.Padding);
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.MarginProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.MarginProperty, paragraph.Margin);
				if (DependencyPropertyHelper.GetValueSource(paragraph, Paragraph.TextAlignmentProperty).BaseValueSource != BaseValueSource.Default)
					newParagraph.SetValue(Paragraph.TextAlignmentProperty, paragraph.TextAlignment);
				CopyProperties(paragraph, newParagraph);
				foreach (var inline in paragraph.Inlines)
					newParagraph.Inlines.Add(Clone(inline));
				return newParagraph;
			}
			throw new NotSupportedException();
		}
      protected override void BeginProcessing()
      {
         _xamlUI = ((PoshConsole.Host.PoshOptions)Host.PrivateData.BaseObject).WpfConsole;
         _xamlUI.Dispatcher.Invoke((Action)(() =>
         {
            _window = _xamlUI.RootWindow;
            Block b = _xamlUI.CurrentBlock;
            while (b.Tag == null && b.PreviousBlock != null)
            {
               b = b.PreviousBlock;
            }
            if (b.Tag is int)
            {
               _id = (int)b.Tag;
               _numbered = b;
            }
         }));

         base.BeginProcessing();
      }
 public IDKin.IM.Core.Message[] GetMessageGroup(bool send = false)
 {
     FlowDocument doc = this.inputMsgBox.Document;
     Block[] blocks = new Block[doc.Blocks.Count];
     doc.Blocks.CopyTo(blocks, 0);
     bool empty = this.IsMessageEmpty();
     IDKin.IM.Core.Message[] messages = null;
     IDKin.IM.Core.Message[] result;
     if (!empty)
     {
         result = this.ChatContentMaxLengthProcessor(send, doc, blocks, ref messages);
     }
     else
     {
         result = messages;
     }
     return result;
 }
示例#25
0
 public void WriteBlock(Block block)
 {
     stack.Peek().AddChild(block);
 }
        /// <summary>
        /// Initialized the new instance of a FlowDocument specifying a Block added
        /// as its first child.
        /// </summary>
        /// <param name="block">
        /// Block added as a first initial child of the FlowDocument.
        /// </param>
        public FlowDocument(Block block)
            : base()
        {
            Initialize(null); // null means to create its own TextContainer

            if (block == null)
            {
                throw new ArgumentNullException("block");
            }

            this.Blocks.Add(block);
        }
 public bool IsBlockInTopLevelOrSection(Block par)
 {
     if (par.Parent == ImportDocument) return true;
     if (par.Parent is Section) return IsBlockInTopLevelOrSection(par.Parent as Block);
     return false;
 }
		public void AddBlock(Block block)
		{
			FlushAddedText(true);
			blockCollection.Add(block);
		}
示例#29
0
 internal void WriteBlock([NotNull] Block block)
 {
     stack.Peek().AddChild(block);
 }
 public int GetHeadingDepth(Block b)
 {
     if (b is Paragraph) return GetHeadingDepth(b.Tag as string);
     return 0;
 }
示例#31
0
 public void WriteBlock([NotNull] Block block)
 {
     stack.Peek().AddChild(block);
 }
 public TableRow CreateTableRowCooperationStaff(Message message, Block[] blocks, CooperationStaff staff)
 {
     TableRow tableRow = new TableRow();
     if (this.tableRowColor)
     {
         tableRow.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(221, 253, 214));
     }
     else
     {
         tableRow.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(241, 250, 255));
     }
     this.tableRowColor = !this.tableRowColor;
     TableCell tableCell = new TableCell();
     tableRow.Cells.Add(tableCell);
     tableCell.Blocks.Add(this.GetNameInfo(staff.Name, message.CreateTime, staff.Uid == this.sessionService.Uid));
     for (int i = 0; i < blocks.Length; i++)
     {
         Paragraph block = (Paragraph)blocks[i];
         this.SetParagraphStyle(block, message.Style);
         tableCell.Blocks.Add(block);
     }
     return tableRow;
 }
示例#33
0
 public void AddBlock(Block newBlock)
 {
     Blocks.Add(newBlock);
 }
示例#34
0
        public void ReplaceOrAdd(Block block, Block replaceThisBlock = null)
        {
            if (block == null)
                return;

            if (replaceThisBlock == null)
            {
                // replace the first block with the same name
                var firstMatchingBlock = Blocks.FirstOrDefault(_b => _b.Name == block.Name);
                if (firstMatchingBlock != null)
                {
                    Blocks.InsertAfter(firstMatchingBlock, block);
                    Blocks.Remove(firstMatchingBlock);
                    return;
                }
            }

            else if (Blocks.Contains(replaceThisBlock))
            {
                Blocks.InsertAfter(replaceThisBlock, block);
                Blocks.Remove(replaceThisBlock);
                return;
            }

            // no replace action is poassible - add as new block
            Blocks.Add(block);
        }
示例#35
0
        /// <summary>
        /// Deletes the old top level blocks in <see cref="FlowDocument"/> and inserts new elements.
        /// </summary>
        /// <param name="firstLevelTextElementsToDelete">The first level text elements to delete in the <see cref="FlowDocument"/>.</param>
        /// <param name="firstLevelTextElementsToInsert">The first level text elements to insert in <see cref="FlowDocument"/>. The insert position depends on the next two parameters</param>
        /// <param name="firstLevelTextElementToInsertBefore">The first level text element to insert before. Can be null.</param>
        /// <param name="firstLevelTextElementToInsertAfter">The first level text element to insert after. Can be null.</param>
        private void DeleteOldAndInsertNewElementsInFlowDocument(List <System.Windows.Documents.Block> firstLevelTextElementsToDelete, IList <TextElement> firstLevelTextElementsToInsert, System.Windows.Documents.Block firstLevelTextElementToInsertBefore, System.Windows.Documents.Block firstLevelTextElementToInsertAfter)
        {
            var blocks = FlowDocument.Blocks;

            foreach (var textEle in firstLevelTextElementsToDelete)
            {
                blocks.Remove(textEle);
            }

            if (firstLevelTextElementsToInsert.Count > 0)
            {
                if (firstLevelTextElementToInsertAfter != null)
                {
                    for (int i = firstLevelTextElementsToInsert.Count - 1; i >= 0; --i)
                    {
                        blocks.InsertAfter(firstLevelTextElementToInsertAfter, (System.Windows.Documents.Block)firstLevelTextElementsToInsert[i]);
                    }
                }
                else if (null != firstLevelTextElementToInsertBefore)
                {
                    for (int i = 0; i < firstLevelTextElementsToInsert.Count; ++i)
                    {
                        blocks.InsertBefore(firstLevelTextElementToInsertBefore, (System.Windows.Documents.Block)firstLevelTextElementsToInsert[i]);
                    }
                }
                else
                {
                    // the insert position could not be determined, because none of the old blocks have been deleted
                    // we have to decide either (i) the blocks have to be added before all the other blocks, or
                    // (ii) the blocks have to be added after all the other blocks
                    // we do this using the markdig tags of the last block to insert, and the first of the old blocks

                    var  lastToInsert    = firstLevelTextElementsToInsert[firstLevelTextElementsToInsert.Count - 1];
                    var  firstBlock      = blocks.FirstBlock;
                    bool isAddedAtStart  = firstBlock != null;
                    var  lastToInsertTag = lastToInsert?.Tag as MarkdownObject;
                    var  firstBlockTag   = firstBlock?.Tag as MarkdownObject;
                    isAddedAtStart &= (null != lastToInsertTag && null != firstBlockTag);
                    isAddedAtStart  = isAddedAtStart && (lastToInsertTag.Span.End <= firstBlockTag.Span.Start);

                    if (isAddedAtStart)
                    {
                        for (int i = 0; i < firstLevelTextElementsToInsert.Count; ++i)
                        {
                            blocks.InsertBefore(firstBlock, (System.Windows.Documents.Block)firstLevelTextElementsToInsert[i]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < firstLevelTextElementsToInsert.Count; ++i)
                        {
                            blocks.Add((System.Windows.Documents.Block)firstLevelTextElementsToInsert[i]);
                        }
                    }
                }
            }
        }
 public void Push(Block block)
 {
     Blocks.Add(block);
 }
        ContainerVisual CloneVisualBlock(Block block, int pageNumber)
        {
            FlowDocument tmpDoc = new FlowDocument();
            tmpDoc.ColumnWidth = double.PositiveInfinity;
            tmpDoc.PageHeight = _report.PageHeight;
            tmpDoc.PageWidth = _report.PageWidth;
            tmpDoc.PagePadding = new Thickness(0);

            string xaml = XamlWriter.Save(block);
            Block newBlock = XamlReader.Parse(xaml) as Block;
            tmpDoc.Blocks.Add(newBlock);

            DocumentWalker walkerBlock = new DocumentWalker();
            ArrayList blockValues = new ArrayList();
            blockValues.AddRange(walkerBlock.Walk<IInlineContextValue>(tmpDoc));

            // fill context values
            FillContextValues(blockValues, pageNumber);

            DocumentPage dp = ((IDocumentPaginatorSource)tmpDoc).DocumentPaginator.GetPage(0);
            return (ContainerVisual)dp.Visual;
        }