다음을 통해 공유


InkCollector.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
Public Property Renderer As Renderer
'Usage
Dim instance As InkCollector
Dim value As Renderer

value = instance.Renderer

instance.Renderer = value
public Renderer Renderer { get; set; }
public:
property Renderer^ Renderer {
    Renderer^ get ();
    void set (Renderer^ value);
}
/** @property */
public Renderer get_Renderer ()

/** @property */
public void set_Renderer (Renderer value)
public function get Renderer () : Renderer

public function set Renderer (value : Renderer)
Not applicable.

Property Value

The Renderer object that is used to draw ink.

Remarks

When handling certain window messages, changing the Renderer associated with the InkCollector can cause a reentrant function call, generating unexpected results. For example, changing to a different Renderer or modifying its transforms within a message handler can result in a reentrant call. This affects the following messages: WM_ACTIVATE, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_PAINT; WM_SYSCOMMAND if wParam is set to SC_HOTKEY or SC_TASKLIST; and WM_SYSKEYDOWN (when processing Alt-Tab or Alt-Esc key combinations). It is an issue with single-threaded apartment model applications.

Example

The following example creates an InkCollector object, theInkCollector, and two Renderer objects: originalRenderer, for the default view, and zoomedRenderer, for a zoomed view. The application determines which Renderer object is attached to theInkCollector in a click event.

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 = theInkCollector.Renderer;
    }
// ...
    private void menuItemZoomed_Click(object sender, System.EventArgs e)
    {
        if (theInkCollector.Renderer == originalRenderer)
        {
            theInkCollector.Renderer = zoomedRenderer;
            menuItemZoomed.Checked = true;
        }
        else
        {
            theInkCollector.Renderer = originalRenderer;
            menuItemZoomed.Checked = false;
        }
    Refresh();
    }
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 = theInkCollector.Renderer
    }
'...
    Private Sub MenuItemZoomed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MenuItemInk.Click
    {
        If theInkCollector.Renderer Is originalRenderer Then
            theInkCollector.Renderer = zoomedRenderer
            MenuItemZoomed.Checked = True
        Else
            theInkCollector.Renderer = originalRenderer
            MenuItemZoomed.Checked = False
        End If
        Refresh()
    }

The following 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();
    theInkCollector.Renderer.InkSpaceToPixel(tempGraphics, ref leftTop);
    theInkCollector.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));
}
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()
    theInkCollector.Renderer.InkSpaceToPixel(tempGraphics, leftTop)
    theInkCollector.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

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkCollector Class
InkCollector Members
Microsoft.Ink Namespace
Renderer