StylusPointDescription.PropertyCount Property
.NET Framework 4
Gets the number of properties in the StylusPointDescription.
Assembly: PresentationCore (in PresentationCore.dll)
The following example demonstrates how to get the properties of each StylusPoint in a StylusPointCollection. This example assumes there is a TextBlock called packetOutput.
private void WriteStylusPointValues(StylusPointCollection points) { StylusPointDescription pointsDescription = points.Description; ReadOnlyCollection<StylusPointPropertyInfo> properties = pointsDescription.GetStylusPointProperties(); // Write the name and and value of each property in // every stylus point. StringWriter packetWriter = new StringWriter(); packetWriter.WriteLine("{0} stylus points", points.Count.ToString()); foreach (StylusPoint stylusPoint in points) { packetWriter.WriteLine("Stylus Point info"); packetWriter.WriteLine("X: {0}", stylusPoint.X.ToString()); packetWriter.WriteLine("Y: {0}", stylusPoint.Y.ToString()); packetWriter.WriteLine("Pressure: {0}", stylusPoint.PressureFactor.ToString()); // Get the property name and value for each StylusPoint. // Note that this loop reports the X, Y, and pressure values differantly than // getting their values above. for (int i = 0; i < pointsDescription.PropertyCount; ++i) { StylusPointProperty currentProperty = properties[i]; // GetStylusPointPropertyName is defined below and returns the // name of the property. packetWriter.Write("{0}: ", GetStylusPointPropertyName(currentProperty)); packetWriter.WriteLine(stylusPoint.GetPropertyValue(currentProperty).ToString()); } packetWriter.WriteLine(); } packetOutput.Text = packetWriter.ToString(); } ... // Use reflection to get the name of currentProperty. private string GetStylusPointPropertyName(StylusPointProperty currentProperty) { Guid guid = currentProperty.Id; // Iterate through the StylusPointProperties to find the StylusPointProperty // that matches currentProperty, then return the name. foreach (FieldInfo theFieldInfo in typeof(StylusPointProperties).GetFields()) { StylusPointProperty property = (StylusPointProperty) theFieldInfo.GetValue(currentProperty); if (property.Id == guid) { return theFieldInfo.Name; } } return "Not found"; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.