Tablet.GetPropertyMetrics Method
Returns the metrics data for a known PacketProperty object.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Function GetPropertyMetrics ( _
id As Guid _
) As TabletPropertyMetrics
'Usage
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 function GetPropertyMetrics(
id : Guid
) : TabletPropertyMetrics
Parameters
id
Type: System.GuidThe Guid identifier for the PacketProperty that you are requesting.
Return Value
Type: Microsoft.Ink.TabletPropertyMetrics
This method returns a TabletPropertyMetrics object for the requested property that is supported by the tablet.
Remarks
The properties for which you retrieve metrics may include the time that a packet was generated or the downward pressure of the pen tip on the tablet surface.
Note
This function can be re-entered if called within certain message handlers, causing unexpected results. Take care to avoid a reentrant call when handling any of the following messages: WM_ACTIVATE, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_PAINT; WM_SYSCOMMAND if wParam is set to SC_HOTKEY or SC_TASKLIST; and WM_SYSKEYDOWN (when processing Alt-Tab or Alt-Esc key combinations). This is an issue with single-threaded apartment model applications.
Examples
This example reports on the property metrics of each supported property of the default Tablet object of the Tablets collection.
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();
}
Platforms
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
Stroke.GetPacketValuesByProperty