InkOverlay.StrokesDeleting 事件
會在從 Ink 屬性刪除筆劃之前發生。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public Event StrokesDeleting As InkOverlayStrokesDeletingEventHandler
'用途
Dim instance As InkOverlay
Dim handler As InkOverlayStrokesDeletingEventHandler
AddHandler instance.StrokesDeleting, handler
public event InkOverlayStrokesDeletingEventHandler StrokesDeleting
public:
event InkOverlayStrokesDeletingEventHandler^ StrokesDeleting {
void add (InkOverlayStrokesDeletingEventHandler^ value);
void remove (InkOverlayStrokesDeletingEventHandler^ value);
}
/** @event */
public void add_StrokesDeleting (InkOverlayStrokesDeletingEventHandler value)
/** @event */
public void remove_StrokesDeleting (InkOverlayStrokesDeletingEventHandler value)
JScript 不支援事件。
備註
當您為已附加至 InkOverlay 物件的筆墨呼叫 Ink.DeleteStroke 或 Ink.DeleteStrokes 方法時,便會引發這個事件。
事件處理常式會收到 InkOverlayStrokesDeletingEventArgs 型別的引數,其中包含這個事件的相關資料。
在建立 InkOverlayStrokesDeletingEventHandler 委派時,您要識別處理事件的方法。若要使事件與您的事件處理常式產生關聯,請將委派的執行個體加入至事件。除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。基於效能考量,相關事件的預設是關閉的,但會在您加入事件處理常式時自動開啟。
範例
這個範例會示範如何訂閱 StrokesDeleting 事件,讓您還原最後刪除的筆劃。
當 StrokesDeleting 事件引發時,會儲存即將刪除的 Stroke 物件。
Private Sub mInkObject_StrokesDeleting(ByVal sender As Object, ByVal e As InkOverlayStrokesDeletingEventArgs)
' Store strokes for later undo. They must be stored in
' a separate Ink object.
mInkDeleted = New Ink()
mInkDeleted.AddStrokesAtRectangle(e.StrokesToDelete, e.StrokesToDelete.GetBoundingBox())
End Sub
private void mInkObject_StrokesDeleting(object sender, InkOverlayStrokesDeletingEventArgs e)
{
// Store strokes for later undo. They must be stored in
// a separate Ink object.
mInkDeleted = new Ink();
mInkDeleted.AddStrokesAtRectangle(e.StrokesToDelete, e.StrokesToDelete.GetBoundingBox());
}
為回應使用者動作,例如按一下 MenuItem,先前已刪除的 Stroke 物件會重新加入至原始的 Ink 物件。
If Not mInkDeleted Is Nothing Then
' Add strokes back. (You need to use Ink.AddStrokesAtRectangle as opposed
' to Strokes.Add because you are dealing with two different Ink objects.)
mInkObject.Ink.AddStrokesAtRectangle(mInkDeleted.Strokes, mInkDeleted.Strokes.GetBoundingBox())
mInkDeleted = Nothing
' For best performance, you should Invalidate the rectangle created by the
' bounding box (converted from ink space to pixel space). For simplicity,
' we will just refresh the entire control.
Refresh()
End If
if (mInkDeleted != null)
{
// Add strokes back. (You need to use Ink.AddStrokesAtRectangle as opposed
// to Strokes.Add because you are dealing with two different Ink objects.)
mInkObject.Ink.AddStrokesAtRectangle(mInkDeleted.Strokes, mInkDeleted.Strokes.GetBoundingBox());
mInkDeleted = null;
// For best performance, you should Invalidate the rectangle created by the
// bounding box (converted from ink space to pixel space). For simplicity,
// we will just refresh the entire control.
Refresh();
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0