Share via


InkOverlay.Renderer Property

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

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public Property Renderer As Renderer
'Usage
Dim instance As InkOverlay 
Dim value As Renderer 

value = instance.Renderer

instance.Renderer = value
[BrowsableAttribute(false)]
public Renderer Renderer { get; set; }
[BrowsableAttribute(false)]
public:
property Renderer^ Renderer {
    Renderer^ get ();
    void set (Renderer^ value);
}
public function get Renderer () : Renderer 
public function set Renderer (value : Renderer)

Property Value

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

Examples

The following example shows how to use an alternate Renderer object to provide a zoomed view for either an InkCollector object, an InkOverlay object,or an InkPicture object.

Prior to using the alternate Renderer object, it is initialized to provide the zooming transformation desired, and the original Renderer object is saved in order to return to the default rendering behavior.

zoomRenderer = New Renderer()
Dim zoomBy2 As Matrix = New Matrix()
zoomBy2.Scale(2, 2)
zoomRenderer.SetObjectTransform(zoomBy2)
' mInkObject can be InkCollector, InkOverlay, or InkPicture
origRenderer = mInkObject.Renderer
zoomRenderer = new Renderer();
Matrix zoomBy2 = new Matrix();
zoomBy2.Scale(2, 2);
zoomRenderer.SetObjectTransform(zoomBy2);
// mInkObject can be InkCollector, InkOverlay, or InkPicture
origRenderer = mInkObject.Renderer;

In response to the CheckChanged event of a CheckBox object, the appropriate Renderer object is assigned, and the ink area is redrawn.

If DirectCast(sender, CheckBox).Checked Then 
    ' mInkObject can be InkCollector, InkOverlay, or InkPicture
    mInkObject.Renderer = zoomRenderer
Else
    mInkObject.Renderer = origRenderer
End If 
' refresh to show the transformed ink. In production code 
' you should invalidate only the necessary area that is  
' affected by the transformation but for simplicity here 
' we will invalidate the entire form 
Me.Refresh()
if (((CheckBox)sender).Checked)
{
    // mInkObject can be InkCollector, InkOverlay, or InkPicture
    mInkObject.Renderer = zoomRenderer;
}
else
{
    mInkObject.Renderer = origRenderer;
}
// refresh to show the transformed ink. In production code 
// you should invalidate only the necessary area that is  
// affected by the transformation but for simplicity here 
// we will invalidate the entire form 
this.Refresh();

The following example demonstates the use of an Renderer object to convert a rectangle expressed in ink space coordinates to one expressed in pixel coordinates.

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

    ' Convert using a Renderer object 
    Dim tGraphics As Graphics = CreateGraphics()
    Dim tRenderer As Renderer = New Renderer()
    tRenderer.InkSpaceToPixel(tGraphics, leftTop)
    tRenderer.InkSpaceToPixel(tGraphics, rightBottom)

    ' Clean up
    tGraphics.Dispose()

    ' Return new rectangle 
    Return New Rectangle(leftTop, New Size(rightBottom.X - leftTop.X, rightBottom.Y - leftTop.Y))
End Function
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 a Renderer object
    Graphics tGraphics = CreateGraphics();
    Renderer tRenderer = new Renderer();
    tRenderer.InkSpaceToPixel(tGraphics, ref leftTop);
    tRenderer.InkSpaceToPixel(tGraphics, ref rightBottom);

    // Clean up
    tGraphics.Dispose();

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

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkOverlay Class

InkOverlay Members

Microsoft.Ink Namespace

Renderer