RealTimeStylus.RealTimeStylus Constructor
RealTimeStylus.RealTimeStylus Constructor |
Creates a RealTimeStylus object and attaches it to the specified control.
Definition
Visual Basic .NET Public Sub RealTimeStylus( _
ByVal attachedControl As Control _
)C# public RealTimeStylus(
Control attachedControl
);Managed C++ public: RealTimeStylus(
Control *attachedControl
);
Parameters
attachedControl System.Windows.Forms.Control. The control to which to attach the RealTimeStylus object. If this parameter is set to null
(Nothing
in Microsoft® Visual Basic® .NET), the RealTimeStylus object is not attached it to a window or control.
Exceptions
ArgumentException : One of the parameters is not valid.
InvalidOperationException : Initialization failed.
Remarks
For new RealTimeStylus objects, ink collection is initially disabled and the input region is set to the bounds of the window to which the RealTimeStylus object is attached. For more information, see the Enabled and WindowInputRectangle properties.
When the RealTimeStylus object is created with the default constructor or with a constructor with the handle parameter set to 0 or the attachedControl parameter set to
null
, then the RealTimeStylus object does not collect ink from a window or control. Instead, the only way to receive ink input is by cascading this RealTimeStylus object under one that is receiving ink input from a window or control. For more information on cascading the RealTimeStylus, see The Cascaded RealTimeStylus Model.When the attachedControl parameter is specified and not set to
null
, the RealTimeStylus object is attached to and receives ink input from the specified control.By default, the RealTimeStylus object uses all attached tablets and the mouse to collect ink.
Examples
This Microsoft® Visual C#® .NET example is a snippet from a form's Load event handler, which creates a GestureRecognizer, DynamicRenderer, and two RealTimeStylus objects, attaches the objects in a cascaded RealTimeStylus model, and enables dynamic rendering, gesture recognition, and tablet pen data collection through the RealTimeStylus. The GestureRecognizer object is set to recognize single-stroke gestures and to only recognize the Right, ChevronRight, and ArrowRight application gestures. The primary RealTimeStylus object's WindowInputRectangle property is explicitly set to use the entire control to which the RealTimeStylus object is attached. The form itself implements the IStylusAsyncPlugin interface and is attached to the RealTimeStylus object.
[C#]using Microsoft.Ink; using Microsoft.StylusInput; using Microsoft.StylusInput.PluginData; // ... // The panel where the tablet pen data is collected. private System.Windows.Forms.Panel thePanel; // Declare the RealTimeStylus objects, the GestureRecognizer plugin, // and the DynamicRenderer plug-in. private Microsoft.StylusInput.RealTimeStylus thePrimaryRealTimeStylus = null; private Microsoft.StylusInput.RealTimeStylus theSecondaryRealTimeStylus = null; private Microsoft.StylusInput.GestureRecognizer theGestureRecognizer = null; private Microsoft.StylusInput.DynamicRenderer theDynamicRenderer = null; // The form's Load event handler. private void theForm_Load(object sender, System.EventArgs e) { // ... // Create a DynamicRenderer attached to the drawing area , // and enable dynamic rendering. this.theDynamicRenderer = new DynamicRenderer(this.thePanel); this.theDynamicRenderer.Enabled = true; // Create a GestureRecognizer, and set it to recognize single-stroke gestures. this.theGestureRecognizer = new GestureRecognizer(); this.theGestureRecognizer.MaxStrokeCount = 1; // Allow gesture recognition for specific gestures. this.theGestureRecognizer.EnableGestures( new ApplicationGesture[] { ApplicationGesture.Right, ApplicationGesture.ChevronRight, ApplicationGesture.ArrowRight } ); // Enable gesture recognition. this.theGestureRecognizer.Enabled = true; // Create the primary and secondary RealTimeStylus objects. this.thePrimaryRealTimeStylus = new RealTimeStylus(this.thePanel); this.theSecondaryRealTimeStylus = new RealTimeStylus(); // Add the secondary RealTimeStylus to the primary's asynchronous plug-in collection. this.thePrimaryRealTimeStylus.AsyncPluginCollection.Add( this.theSecondaryRealTimeStylus); // Add the dynamic renderer to the primary's synchronous plug-in collection. this.thePrimaryRealTimeStylus.SyncPluginCollection.Add(this.theDynamicRenderer); // Add the gesture recognizer to the secondary's synchronous plug-in collection. this.theSecondaryRealTimeStylus.SyncPluginCollection.Add(this.theGestureRecognizer); // Add the form to the secondary's asynchronous plug-in colleciton. this.theSecondaryRealTimeStylus.AsyncPluginCollection.Add(this); // Set the input rectangle to the entire panel for the RealTimeStylus. this.thePrimaryRealTimeStylus.WindowInputRectangle = new Rectangle(0,0,0,0); // Enable the RealTimeStylus, which allows notifications to flow to the plug-ins. this.thePrimaryRealTimeStylus.Enabled = true; // ... }
See Also