InkEditStrokeEventHandler 委托
表示处理 InkEdit 控件的 Stroke 事件的方法。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Delegate Sub InkEditStrokeEventHandler ( _
sender As Object, _
e As InkEditStrokeEventArgs _
)
用法
Dim instance As New InkEditStrokeEventHandler(AddressOf HandlerMethod)
public delegate void InkEditStrokeEventHandler(
Object sender,
InkEditStrokeEventArgs e
)
public delegate void InkEditStrokeEventHandler(
Object^ sender,
InkEditStrokeEventArgs^ e
)
/** @delegate */
public delegate void InkEditStrokeEventHandler(
Object sender,
InkEditStrokeEventArgs e
)
JScript 不支持委托。
参数
- sender
类型:System.Object
此事件的源 InkEdit 控件。
- e
类型:Microsoft.Ink.InkEditStrokeEventArgs
包含事件数据的 InkEditStrokeEventArgs 对象。
备注
- 创建 InkEditStrokeEventHandler 委托时,需要标识将处理该事件的方法。若要将该事件与事件处理程序关联,请将该委托的一个实例添加到事件中。除非移除了该委托,否则每当发生该事件时就会调用此事件处理程序。
示例
此示例演示如何订阅 Gesture 事件和 Stroke 事件,以扩充 ApplicationGesture 的功能。
激发 Gesture 事件时,它会检查 InkEdit 控件的笔势和当前状态。如果有必要,将修改笔势的行为,并取消该事件。
Private Sub mInkEdit_Gesture(ByVal sender As Object, ByVal e As InkEditGestureEventArgs)
' There might be more than one gesture passed in InkEditGestureEventArgs
' The gestures are arranged in order of confidence from most to least
' This event handler is only concerned with the first (most confident) gesture
' and only if the gesture is ApplicationGesture.Left with strong confidence
Dim G As Gesture = e.Gestures(0)
If (ApplicationGesture.Left = G.Id And RecognitionConfidence.Strong = G.Confidence) Then
Dim pInkEdit As InkEdit = DirectCast(sender, InkEdit)
' by default, ApplicationGesture.Left maps to Backspace
' If the insertion point is at the beginning of the text
' and there is no text selected, then Backspace does not do anything.
' In this case, we will alter the gesture to map to Delete instead
If (0 = pInkEdit.SelectionStart And 0 = pInkEdit.SelectionLength And pInkEdit.Text.Length > 0) Then
' take out the first character of the string
pInkEdit.Text = pInkEdit.Text.Remove(0, 1)
' save the stroke ID in a class level var for use in the Stroke event
Me.mStrokeID = e.Strokes(0).Id
' cancel the gesture so it won't perform the default action
e.Cancel = True
End If
End If
End Sub
private void mInkEdit_Gesture(object sender, InkEditGestureEventArgs e)
{
// There might be more than one gesture passed in InkEditGestureEventArgs
// The gestures are arranged in order of confidence from most to least
// This event handler is only concerned with the first (most confident) gesture
// and only if the gesture is ApplicationGesture.Left with strong confidence
Gesture G = e.Gestures[0];
if (ApplicationGesture.Left == G.Id && RecognitionConfidence.Strong == G.Confidence)
{
InkEdit pInkEdit = (InkEdit)sender;
// by default, ApplicationGesture.Left maps to Backspace
// If the insertion point is at the beginning of the text
// and there is no text selected, then Backspace does not do anything.
// In this case, we will alter the gesture to map to Delete instead
if (0 == pInkEdit.SelectionStart && 0 == pInkEdit.SelectionLength && pInkEdit.Text.Length > 0)
{
// take out the first character of the string
pInkEdit.Text = pInkEdit.Text.Remove(0, 1);
// save the stroke ID in a class level var for use in the Stroke event
this.mStrokeID = e.Strokes[0].Id;
// cancel the gesture so it won't perform the default action
e.Cancel = true;
}
}
}
激发 Stroke 事件时,如果笔画是用于生成已在 Gesture 事件中修改其行为的笔势的那个笔画,则取消该事件。这将使笔画无法呈现。
Private Sub mInkEdit_Stroke(ByVal sender As Object, ByVal e As InkEditStrokeEventArgs)
e.Cancel = (e.Stroke.Id = Me.mStrokeID)
End Sub
private void mInkEdit_Stroke(object sender, InkEditStrokeEventArgs e)
{
e.Cancel = (e.Stroke.Id == this.mStrokeID);
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0