InkCollector.Renderer 屬性
取得或設定用來繪製筆墨的 Renderer 物件。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public Property Renderer As Renderer
'用途
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)
屬性值
型別:Microsoft.Ink.Renderer
用來繪製筆墨的 Renderer 物件。
備註
處理某些視窗訊息時,變更與 InkCollector 關聯的 Renderer 會造成重新進入函式呼叫,而產生非預期的結果。例如,變更為不同的 Renderer 或修改其在訊息處理常式內的轉換,則可能會重新進入呼叫。這會影響到下列訊息:WM_ACTIVATE、WM_ACTIVATEAPP、WM_NCACTIVATE、WM_PAINT、WM_SYSCOMMAND (如果 wParam 設定為 SC_HOTKEY 或 SC_TASKLIST) 和 WM_SYSKEYDOWN (處理 Alt-Tab 或 Alt-Esc key 組合鍵時)。不過在單一執行緒 Apartment Model (STA) 應用程式中會發生問題。
範例
下列範例說明如何使用替代 Renderer 物件提供 InkCollector 物件、InkOverlay 物件或 InkPicture 物件的縮放檢視。
在使用替代 Renderer 物件之前,會先將它初始化以提供所需的縮放轉換,而且會儲存原始 Renderer 物件以恢復預設呈現行為。
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;
為回應 CheckBox 物件的 CheckChanged 事件,會指派適當的 Renderer 物件,而且會重新繪製筆墨區域。
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();
在下列範例中,會示範 Renderer 物件的用法,將以筆墨空間座標表示的矩形轉換為以像素座標表示。
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));
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0