Strokes.StrokesAdded 事件
当一个或多个 Stroke 对象添加到 Strokes 集合时发生。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Event StrokesAdded As StrokesEventHandler
用法
Dim instance As Strokes
Dim handler As StrokesEventHandler
AddHandler instance.StrokesAdded, handler
public event StrokesEventHandler StrokesAdded
public:
event StrokesEventHandler^ StrokesAdded {
void add (StrokesEventHandler^ value);
void remove (StrokesEventHandler^ value);
}
/** @event */
public void add_StrokesAdded (StrokesEventHandler value)
/** @event */
public void remove_StrokesAdded (StrokesEventHandler value)
JScript 不支持事件。
备注
事件处理程序接收 StrokesEventArgs 类型的参数,该参数包含有关此事件的数据。
创建 StrokesEventHandler 委托时,需要标识处理该事件的方法。若要将该事件与事件处理程序关联,请将该委托的一个实例添加到事件中。除非移除了该委托,否则每当发生该事件时就会调用此事件处理程序。
示例
在此示例中,StrokesAdded 事件处理程序将新添加的笔画顺时针旋转 90 度。旋转围绕新添加的 Stroke 对象的边界框的中心进行。
' Reminder: To avoid a memory leak, you must explicitly call the Dispose() method
' on any Strokes collection to which an event handler has been attached before
' the collection goes out of scope.
Private Sub Strokes_StrokesAdded(ByVal sender As Object, ByVal e As StrokesEventArgs)
' check each stroke id passed to the handler
For Each id As Integer In e.StrokeIds
' find the Stroke
For Each oneStroke As Stroke In DirectCast(sender, Strokes)
' when we find the added stroke, rotate it
If (oneStroke.Id = id) Then
Dim bounds As Rectangle = oneStroke.GetBoundingBox()
' create a point at the center of bounding box
Dim center As Point = New Point(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2))
' rotate the stroke
oneStroke.Rotate(90, center)
End If
Next
Next
End Sub
// Reminder: To avoid a memory leak, you must explicitly call the Dispose() method
// on any Strokes collection to which an event handler has been attached before
// the collection goes out of scope.
private void Strokes_StrokesAdded(object sender, StrokesEventArgs e)
{
// check each stroke id passed to the handler
foreach (int id in e.StrokeIds)
{
// find the Stroke
foreach (Stroke oneStroke in (Strokes)sender)
{
// when we find the added stroke, rotate it
if (oneStroke.Id == id)
{
Rectangle bounds = oneStroke.GetBoundingBox();
// create a point at the center of bounding box
Point center = new Point(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2));
// rotate the stroke
oneStroke.Rotate(90, center);
}
}
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0