StylusPointDescription.HasProperty(StylusPointProperty) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个指示当前 StylusPointDescription 是否具有指定属性的值。
public:
bool HasProperty(System::Windows::Input::StylusPointProperty ^ stylusPointProperty);
public bool HasProperty (System.Windows.Input.StylusPointProperty stylusPointProperty);
member this.HasProperty : System.Windows.Input.StylusPointProperty -> bool
Public Function HasProperty (stylusPointProperty As StylusPointProperty) As Boolean
参数
- stylusPointProperty
- StylusPointProperty
返回
如果 StylusPointDescription 具有指定 StylusPointProperty,则为 true
;否则为 false
。
示例
以下示例演示如何从 StylusPointDescription获取有关 属性的信息。 此示例假定 StylusMove 事件已连接到事件处理程序。
void inkCanvas1_StylusMove(object sender, StylusEventArgs e)
{
StylusPointCollection points = e.GetStylusPoints(inkCanvas1);
StylusPointDescription description = points.Description;
StringWriter normalPressureInfo = new StringWriter();
if (description.HasProperty(StylusPointProperties.NormalPressure))
{
StylusPointPropertyInfo propertyInfo =
description.GetPropertyInfo(StylusPointProperties.NormalPressure);
normalPressureInfo.WriteLine(" Guid = {0}", propertyInfo.Id.ToString());
normalPressureInfo.Write(" Min = {0}", propertyInfo.Minimum.ToString());
normalPressureInfo.Write(" Max = {0}", propertyInfo.Maximum.ToString());
normalPressureInfo.Write(" Unit = {0}", propertyInfo.Unit.ToString());
normalPressureInfo.WriteLine(" Res = {0}", propertyInfo.Resolution.ToString());
}
}
Private Sub inkCanvas1_StylusMove(ByVal sender As Object, ByVal e As StylusEventArgs)
Dim points As StylusPointCollection = e.GetStylusPoints(inkCanvas1)
Dim description As StylusPointDescription = points.Description
Dim normalPressureInfo As New StringWriter()
If description.HasProperty(StylusPointProperties.NormalPressure) Then
Dim propertyInfo As StylusPointPropertyInfo = _
description.GetPropertyInfo(StylusPointProperties.NormalPressure)
normalPressureInfo.WriteLine(" Guid = {0}", propertyInfo.Id.ToString())
normalPressureInfo.Write(" Min = {0}", propertyInfo.Minimum.ToString())
normalPressureInfo.Write(" Max = {0}", propertyInfo.Maximum.ToString())
normalPressureInfo.Write(" Unit = {0}", propertyInfo.Unit.ToString())
normalPressureInfo.WriteLine(" Res = {0}", propertyInfo.Resolution.ToString())
End If
End Sub