Represents a render target, which exposes the rendered report pages as UIElement objects.
Namespace: MindFusion.Reporting.Wpf
Assembly: MindFusion.Reporting.Wpf
Syntax
C#
Copy Code
|
---|
public interface IRenderTargetWithPages<T> : IRenderTarget where T : UIElement |
Visual Basic
Copy Code
|
---|
Public Interface IRenderTargetWithPages(Of T As UIElement) Implements IRenderTarget |
Example
Below is a sample implementation of this interface, which renders individual pages on separate Canvas objects.
C#
Copy Code
|
---|
/// <summary> /// This class renders individual pages in a report on separate Canvas objects. /// </summary> class PrintRenderTarget : IRenderTargetWithPages<Canvas> { /// <summary> /// Intializes a new instance of the PageRenderTarget class. /// </summary> public PrintRenderTarget() { pages = new List<Canvas>(); }
/// <summary> /// IRenderTarget.AddPage implementation. /// </summary> /// <param name="size"> /// The size of the new page. /// </param> public void AddPage(Size size) { pages.Add(currentPage = new Canvas()); }
/// <summary> /// IRenderTarget.BeginRender implementation. /// </summary> public void BeginRender() { }
/// <summary> /// IRenderTarget.Render implementation. /// </summary> /// <param name="element"> /// The UIElement to be rendered. /// </param> /// <param name="left"> /// The left position of the element being rendered relative to the current page. /// </param> /// <param name="top"> /// </param> public void Render(UIElement element, double left, double top) { Canvas.SetLeft(element, tx + left); Canvas.SetTop(element, ty + top); currentPage.Children.Add(element); }
/// <summary> /// IRenderTarget.EndRender implementation. /// </summary> public void EndRender() { }
/// <summary> /// IRenderTarget.Translate implementation. /// </summary> /// <param name="x"> /// The amount to translate along the x-axis. /// </param> /// <param name="y"> /// The amount to translate along the y-axis. /// </param> public void Translate(double x, double y) { tx += x; ty += y; }
/// <summary> /// Gets an enumerator of the rendered pages. /// </summary> public Canvas[] Pages { get { return pages.ToArray(); } }
/// <summary> /// The list of rendered pages. /// </summary> private List<Canvas> pages;
/// <summary> /// The page currently being rendered. /// </summary> private Canvas currentPage;
/// <summary> /// The currently accumulated translation along the x-axis. /// </summary> private double tx;
/// <summary> /// The currently accumulated translation along th y-axis. /// </summary> private double ty; } |
Visual Basic
Copy Code
|
---|
''' <summary> ''' This class renders individual pages on separate Canvas objects. ''' </summary> Class PrintRenderTarget Implements IRenderTargetWithPages(Of Canvas)
''' <summary> ''' Intializes a new instance of the PageRenderTarget class. ''' </summary> Public Sub New()
_pages = New List(Of Canvas)()
End Sub
''' <summary> ''' IRenderTarget.AddPage implementation. ''' </summary> ''' <param name="size"> ''' The size of the new page. ''' </param> Public Sub AddPage(ByVal size As Size) Implements IRenderTarget.AddPage currentPage = New Canvas() _pages.Add(currentPage)
End Sub
''' <summary> ''' IRenderTarget.BeginRender implementation. ''' </summary> Public Sub BeginRender() Implements IRenderTarget.BeginRender
End Sub
''' <summary> ''' IRenderTarget.Render implementation. ''' </summary> ''' <param name="element"> ''' The UIElement to be rendered. ''' </param> ''' <param name="left"> ''' The left position of the element being rendered relative to the current page. ''' </param> ''' <param name="top"> ''' </param> Public Sub Render(ByVal element As UIElement, ByVal left As Double, ByVal top As Double) Implements IRenderTarget.Render
Canvas.SetLeft(element, tx + left) Canvas.SetTop(element, ty + top) currentPage.Children.Add(element)
End Sub
''' <summary> ''' IRenderTarget.EndRender implementation. ''' </summary> Public Sub EndRender() Implements IRenderTarget.EndRender
End Sub
''' <summary> ''' IRenderTarget.Translate implementation. ''' </summary> ''' <param name="x"> ''' The amount to translate along the x-axis. ''' </param> ''' <param name="y"> ''' The amount to translate along the y-axis. ''' </param> Public Sub Translate(ByVal x As Double, ByVal y As Double) Implements IRenderTarget.Translate
tx = tx + x ty = ty + y
End Sub
''' <summary> ''' Gets an enumerator of the rendered pages. ''' </summary> Public ReadOnly Property Pages As Canvas() Implements IRenderTargetWithPages(Of Canvas).Pages
Get Return _pages.ToArray() End Get
End Property
''' <summary> ''' The list of rendered pages. ''' </summary> Private _pages As List(Of Canvas)
''' <summary> ''' The page currently being rendered. ''' </summary> Private currentPage As Canvas
''' <summary> ''' The currently accumulated translation along the x-axis. ''' </summary> Private tx As Double
''' <summary> ''' The currently accumulated translation along th y-axis. ''' </summary> Private ty As Double
End Class |
See Also