Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

InkPicture.Renderer Property

InkPicture.Renderer Property

Gets or sets the Renderer object that is used to draw ink.

Definition

Visual Basic .NET Public Property Renderer As Renderer
C# public Renderer Renderer { get; set; }
Managed C++ public: __property Renderer* get_Renderer();
public: __property void set_Renderer(Renderer*);

Property Value

Microsoft.Ink.Renderer. The Renderer object that is used to draw ink.

This property is read/write. This property has no default value.

Exceptions

ArgumentNullException Leave Site:
COMException Leave Site:
ObjectDisposedException Leave Site:

Examples

[C#]

This C# example creates an InkPicture control, theInkPicture, and two Renderer objects: originalRenderer, for the default view, and zoomedRenderer, for a zoomed view. The application determines which Renderer object is attached to theInkPicture in a click event, menuItemZoomed_Click.


using Microsoft.Ink;
using System.Drawing.Drawing2D;
//...
    private Renderer zoomedRenderer;
    private Renderer originalRenderer;
//...
    public Form1()
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();

        // ...
        // Initialize renderers
        zoomedRenderer = new Renderer();
        Matrix zoomBy2 = new Matrix();
        zoomBy2.Scale(2, 2);
        zoomedRenderer.SetObjectTransform(zoomBy2);
        originalRenderer = theInkPicture.Renderer;
    }
// ...
    private void menuItemZoomed_Click(object sender, System.EventArgs e)
    {
        if (theInkPicture.Renderer == originalRenderer)
        {
            theInkPicture.Renderer = zoomedRenderer;
            menuItemZoomed.Checked = true;
        }
        else
        {
            theInkPicture.Renderer = originalRenderer;
            menuItemZoomed.Checked = false;
        }
    Refresh();
    }
			

[VB.NET]

This Microsoft® Visual Basic® .NET example creates an InkPicture control, theInkPicture, and two Renderer objects: originalRenderer, for the default view, and zoomedRenderer, for a zoomed view. The application determines which Renderer object is attached to theInkPicture in a click event, menuItemZoomed_Click.


Imports Microsoft.Ink
Imports System.Drawing.Drawing2D
'...
    Private zoomedRenderer As Renderer
    Private originalRenderer As Renderer
'...
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    {
        // Initialize renderers
        zoomedRenderer = New Renderer()
        Matrix zoomBy2 = New Matrix()
        zoomBy2.Scale(2, 2)
        zoomedRenderer.SetObjectTransform(zoomBy2)
        originalRenderer = theInkPicture.Renderer
    }
'...
    Private Sub MenuItemZoomed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
	Handles MenuItemInk.Click
    {
        If theInkPicture.Renderer Is originalRenderer Then
            theInkPicture.Renderer = zoomedRenderer
            MenuItemZoomed.Checked = True
        Else
            theInkPicture.Renderer = originalRenderer
            MenuItemZoomed.Checked = False
        End If
        Refresh()
    }
		

[C#]

This C# example contains a function that uses the Renderer property to convert a rectangle in ink space coordinates to pixel coordinates.


using Microsoft.Ink;
//...
private Rectangle InkSpaceToPixelRectangle(Rectangle inkRectangle)
{
    // Get points for corners of rectangle
    Point leftTop = inkRectangle.Location;
    Point rightBottom = new Point(inkRectangle.Right, inkRectangle.Bottom);

    // Convert using Renderer
    Graphics tempGraphics = CreateGraphics();
    theInkPicture.Renderer.InkSpaceToPixel(tempGraphics, ref leftTop);
    theInkPicture.Renderer.InkSpaceToPixel(tempGraphics, ref rightBottom);

    // Clean up
    tempGraphics.Dispose();

    // Return new rectangle
    return new Rectangle(leftTop,
        new Size(rightBottom.X - leftTop.X, rightBottom.Y - leftTop.Y));
}
			

[VB.NET]

This Visual Basic .NET example contains a function that uses the Renderer property to convert a rectangle in ink space coordinates to pixel coordinates.


Imports Microsoft.Ink
'...
Private Function InkSpaceToPixelRectangle(ByVal inkRectangle As Rectangle) As Rectangle
    ' Get points for corners of rectangle
    Dim leftTop As Point = inkRectangle.Location
    Dim rightBottom As New Point(inkRectangle.Right, inkRectangle.Bottom)

    ' Convert using Renderer
    Dim tempGraphics As Graphics = CreateGraphics()
    theInkPicture.Renderer.InkSpaceToPixel(tempGraphics, leftTop)
    theInkPicture.Renderer.InkSpaceToPixel(tempGraphics, rightBottom)

    ' Clean up
    tempGraphics.Dispose()

    ' Return new rectangle
    Return New Rectangle(leftTop, _
        New Size(rightBottom.X - leftTop.X, rightBottom.Y - leftTop.Y))
End Function
		

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.