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