Tablet.GetPropertyMetrics 方法

返回已知 PacketProperty 对象的度量数据。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function GetPropertyMetrics ( _
    id As Guid _
) As TabletPropertyMetrics
用法
Dim instance As Tablet
Dim id As Guid
Dim returnValue As TabletPropertyMetrics

returnValue = instance.GetPropertyMetrics(id)
public TabletPropertyMetrics GetPropertyMetrics(
    Guid id
)
public:
TabletPropertyMetrics GetPropertyMetrics(
    Guid id
)
public TabletPropertyMetrics GetPropertyMetrics(
    Guid id
)
public function GetPropertyMetrics(
    id : Guid
) : TabletPropertyMetrics

参数

返回值

类型:Microsoft.Ink.TabletPropertyMetrics
此方法返回 Tablet 支持的所请求属性的 TabletPropertyMetrics 对象。

备注

您检索其度量的属性可能包括数据包 的生成时间,或者笔尖在 Tablet 表面上的向下压力。

备注

如果在某些消息处理程序内调用此函数,则可以重新进入此函数,从而导致意外的结果。在处理以下任一消息时,请注意避免可重入调用:WM_ACTIVATEWM_ACTIVATEAPPWM_NCACTIVATEWM_PAINTWM_SYSCOMMAND(如果 wParam 设置为 SC_HOTKEY 或 SC_TASKLIST);以及 WM_SYSKEYDOWN(处理 Alt-Tab 或 Alt-Esc 组合键时)。这是单线程单元模型应用程序的问题。

示例

此示例报告 Tablets 集合的默认 Tablet 对象的每一个受支持属性的属性度量。

Public Function Report_PropertyMetrics_DefaultTablet() As String

    Dim SB As StringBuilder = New StringBuilder(1024)
    Dim defTablet As Tablet = New Tablets().DefaultTablet


    ' Report on each of the property metrics for the default tablet
    SB.AppendLine("Propert metrics of the default tablet: " + defTablet.Name)
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.AltitudeOrientation, "AltitudeOrientation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.AzimuthOrientation, "AzimuthOrientation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.ButtonPressure, "ButtonPressure"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.NormalPressure, "NormalPressure"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.PacketStatus, "PacketStatus"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.PitchRotation, "PitchRotation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.RollRotation, "RollRotation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.SerialNumber, "SerialNumber"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.TangentPressure, "TangentPressure"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.TimerTick, "TimerTick"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.TwistOrientation, "TwistOrientation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.X, "X"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.XTiltOrientation, "XTiltOrientation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.Y, "Y"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.YawRotation, "YawRotation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.YTiltOrientation, "YTiltOrientation"))
    SB.Append(GetPropertyMetrics(defTablet, PacketProperty.Z, "Z"))

    Return SB.ToString()

End Function


Public Function GetPropertyMetrics( _
    ByVal theTablet As Tablet, _
    ByVal PropertyID As Guid, _
    ByVal PropertyName As String) As String

    Dim SB As StringBuilder = New StringBuilder(1024)

    ' If this particular property is supported,
    ' report the name and property metrics information.
    If theTablet.IsPacketPropertySupported(PropertyID) Then
        SB.AppendLine(PropertyName)
        Dim theMetrics As TabletPropertyMetrics = theTablet.GetPropertyMetrics(PropertyID)
        SB.AppendLine(" Max: " + theMetrics.Maximum.ToString())
        SB.AppendLine(" Min: " + theMetrics.Minimum.ToString())
        SB.AppendLine(" Resolution: " + theMetrics.Resolution.ToString())
        SB.AppendLine(" Units: " + theMetrics.Units.ToString())

    Else
        SB.AppendLine(PropertyName + " [not supported]")
    End If

    Return SB.ToString()
End Function
public string Report_PropertyMetrics_DefaultTablet()
{
    StringBuilder SB = new StringBuilder(1024);
    Tablet defTablet = new Tablets().DefaultTablet;

    // Report on each of the property metrics for the default tablet
    SB.AppendLine("Propert metrics of the default tablet: " + defTablet.Name);
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.AltitudeOrientation, "AltitudeOrientation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.AzimuthOrientation, "AzimuthOrientation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.ButtonPressure, "ButtonPressure"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.NormalPressure, "NormalPressure"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.PacketStatus, "PacketStatus"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.PitchRotation, "PitchRotation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.RollRotation, "RollRotation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.SerialNumber, "SerialNumber"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.TangentPressure, "TangentPressure"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.TimerTick, "TimerTick"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.TwistOrientation, "TwistOrientation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.X, "X"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.XTiltOrientation, "XTiltOrientation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.Y, "Y"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.YawRotation, "YawRotation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.YTiltOrientation, "YTiltOrientation"));
    SB.Append( GetPropertyMetrics(defTablet, PacketProperty.Z, "Z"));

    return SB.ToString();
}


public string GetPropertyMetrics(Tablet theTablet, Guid PropertyID, string PropertyName)
{
    StringBuilder SB = new StringBuilder(1024);

    // If this particular property is supported,
    // report the name and property metrics information.
    if (theTablet.IsPacketPropertySupported(PropertyID))
    {
        SB.AppendLine(PropertyName);
        TabletPropertyMetrics theMetrics = theTablet.GetPropertyMetrics(PropertyID);
        SB.AppendLine(" Max: " + theMetrics.Maximum.ToString());
        SB.AppendLine(" Min: " + theMetrics.Minimum.ToString());
        SB.AppendLine(" Resolution: " + theMetrics.Resolution.ToString());
        SB.AppendLine(" Units: " + theMetrics.Units.ToString());
    }
    else
    {
        SB.AppendLine(PropertyName + " [not supported]");
    }

    return SB.ToString();
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

Tablet 类

Tablet 成员

Microsoft.Ink 命名空间

TabletPropertyMetricUnit

Stroke.GetPacketValuesByProperty

Stroke.SetPacketValuesByProperty

Stroke.GetPacketDescriptionPropertyMetrics