InkEdit.Stroke 事件
当用户在任何 Tablet 上绘制完一个新笔画 时发生。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink(在 Microsoft.Ink.dll 中)
语法
声明
Public Event Stroke As InkEditStrokeEventHandler
用法
Dim instance As InkEdit
Dim handler As InkEditStrokeEventHandler
AddHandler instance.Stroke, handler
public event InkEditStrokeEventHandler Stroke
public:
event InkEditStrokeEventHandler^ Stroke {
void add (InkEditStrokeEventHandler^ value);
void remove (InkEditStrokeEventHandler^ value);
}
/** @event */
public void add_Stroke (InkEditStrokeEventHandler value)
/** @event */
public void remove_Stroke (InkEditStrokeEventHandler value)
JScript 不支持事件。
备注
事件处理程序接收 InkCollectorStrokeEventArgs 类型的参数,该参数包含有关此事件的数据。
创建 InkCollectorStrokeEventHandler 委托时,需要标识将处理该事件的方法。若要将该事件与事件处理程序关联,请将该委托的一个实例添加到事件中。除非移除了该委托,否则每当发生该事件时就会调用此事件处理程序。默认事件关注处于打开状态。
示例
此示例演示如何订阅 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