InkOverlay.Renderer 属性
获取或设置用于绘制墨迹 的 Renderer 对象。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
<BrowsableAttribute(False)> _
Public Property Renderer As Renderer
用法
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);
}
/** @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