InkPicture.Renderer 屬性
取得或設定用來繪製筆墨的 Renderer 物件。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
<BrowsableAttribute(False)> _
Public Property Renderer As Renderer
'用途
Dim instance As InkPicture
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);
}
/** @property */
/** @attribute BrowsableAttribute(false) */
public Renderer get_Renderer()
/** @property */
/** @attribute BrowsableAttribute(false) */
public void set_Renderer(Renderer value)
public function get Renderer () : Renderer
public function set Renderer (value : Renderer)
屬性值
型別:Microsoft.Ink.Renderer
用來繪製筆墨的 Renderer 物件。
範例
下列範例說明如何使用替代的 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