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.DeleteStrokeInk.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

另请参见

参考

InkOverlay 类

InkOverlay 成员

Microsoft.Ink 命名空间

InkOverlay.Ink

InkOverlay.StrokesDeleted

InkOverlayStrokesDeletingEventArgs