The RealTimeStylus object does not inherently collect ink. To use the RealTimeStylus to collect ink, create an ink-collector plug-in.
The following is a minimal scenario for using the RealTimeStylus object on a form that collects ink.
- Create a form that implements the IStylusAsyncPlugin interface.
- Create a RealTimeStylus object, and attach it to a control on the form.
- Set interest in the StylusDown, Packets, and StylusUp notifications in the form's DataInterest property.
- In the form's StylusDown, Packets, and StylusUp methods, add code to handle the stylus down, packets, and stylus up notifications that are sent from the form's RealTimeStylus object. This code should store the pen data, and create and store the strokes.
For a sample of such an application, see the RealTimeStylus Ink Collection Sample sample.
When a DisplaySettingsChanged event occurs, call the ModifyDrawingAttributes method of the collected strokes in a DisplaySettingsChanged event handler to recalculate the Width and Height properties. This is necessary to account for possible dots per inch (dpi) changes that result from the DisplaySettingsChanged event.
Ink Collection and Recognizers
Neither ink analysis nor handwriting recognition is a function of the RealTimeStylus object. As the ink-collector plug-in collects ink-or as you want to recognize the ink-you can copy the ink to a RecognizerContext or Divider object. For more information about recognition and ink analysis, see About Handwriting Recognition or The Divider Object.
To render ink as it is being collected, attach a DynamicRenderer object to the RealTimeStylus object. To render ink after it has been collected, use a Renderer object to draw the strokes to the appropriate Graphics object. For more information about the DynamicRenderer object, see Dynamic-Renderer Plug-ins. For a sample of both static and dynamic rendering, see RealTimeStylus Ink Collection Sample.