Ink.AddStrokesAtRectangle 方法
指定在指定矩形中将已知 Strokes 集合插入此 Ink 对象。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Sub AddStrokesAtRectangle ( _
strokes As Strokes, _
destinationRectangle As Rectangle _
)
用法
Dim instance As Ink
Dim strokes As Strokes
Dim destinationRectangle As Rectangle
instance.AddStrokesAtRectangle(strokes, _
destinationRectangle)
public void AddStrokesAtRectangle(
Strokes strokes,
Rectangle destinationRectangle
)
public:
void AddStrokesAtRectangle(
Strokes^ strokes,
Rectangle destinationRectangle
)
public void AddStrokesAtRectangle(
Strokes strokes,
Rectangle destinationRectangle
)
public function AddStrokesAtRectangle(
strokes : Strokes,
destinationRectangle : Rectangle
)
参数
- strokes
类型:Microsoft.Ink.Strokes
要添加到 Ink 对象的 Strokes 集合。
- destinationRectangle
类型:System.Drawing.Rectangle
要添加笔画的矩形,以墨迹空间坐标表示。
备注
如果矩形坐标为 {0,0,0,0},则会引发运行时错误。
插入后,笔画从 Strokes 集合的边框缩放至矩形。
此方法可用于复制单个 Ink 对象中的笔画。源笔画无需来自另一个 Ink 对象。
示例
此 C# 示例使用 AddStrokesAtRectangle 方法将墨迹 副本从一个主 InkCollector 对象 panelMain 放入一个 InkCollector 对象 panelThumb,同时保持适当的缩放和长宽比。为保持缩略图面板为当前值。将一个 Stroke 事件处理程序 panelMain_Stroke 添加到 panelMain。
private void panelMain_Stroke(object sender, Microsoft.Ink.InkCollectorStrokeEventArgs e)
{
// Create a bounding rectangle for panelThumb in ink space coordinates
Point thePoint = Point.Empty;
using (Graphics g = Graphics.FromHwnd(Handle))
{
thePoint = new Point(panelThumb.Width, panelThumb.Height);
panelMain.Renderer.PixelToInkSpace(g, ref thePoint);
}
Rectangle theRectangle = new Rectangle(0, 0, thePoint.X, thePoint.Y);
// Delete the old strokes in the thumbnail, and add the new strokes.
panelThumb.Ink.DeleteStrokes();
// The strokes are automatically scaled to the destination rectangle
panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle);
Refresh();
}
此 Microsoft Visual Basic.NET 示例使用 AddStrokesAtRectangle 方法将墨迹 副本从一个主 InkCollector 对象 panelMain 复制到一个 InkCollector 对象 panelThumb,同时保持适当的缩放和长宽比。为保持缩略图面板为当前值。将一个 Stroke 事件处理程序 panelMain_Stroke 添加到 panelMain。
Private Sub panelMain_Stroke(ByVal sender As System.Object, _
ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) Handles panelMain.Stroke
'Create a bounding rectangle for panelThumb in ink space coordinates
Dim g As Graphics = Graphics.FromHwnd(Handle)
Dim thePoint As Point = New Point(panelThumb.Width, panelThumb.Height)
panelMain.Renderer.PixelToInkSpace(g, thePoint)
'Dispose of the Graphics object
g.Dispose()
Dim theRectangle As Rectangle = New Rectangle(0, 0, thePoint.X, thePoint.Y)
'Delete the old strokes in the thumbnail, and add the new strokes.
panelThumb.Ink.DeleteStrokes()
'The strokes are automatically scaled to the destination rectangle
panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle)
Refresh()
End Sub
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0