Ejemplo n.º 1
0
        void RemoveTablet(uint index)
        {
            System.Diagnostics.Debug.Assert(index < Count && Count > 0);

            WispTabletDevice removeTablet = _tablets[index].As <WispTabletDevice>();

            TabletDevice[] tablets = new TabletDevice[_tablets.Length - 1];

            uint preCopyCount  = index;
            uint postCopyCount = (uint)_tablets.Length - index - 1;

            Array.Copy(_tablets, 0, tablets, 0, preCopyCount);
            Array.Copy(_tablets, index + 1, tablets, index, postCopyCount);

            _tablets      = tablets;
            TabletDevices = new List <TabletDevice>(_tablets);

            // DevDiv:1078091
            // Dispose the tablet unless there is input waiting
            removeTablet.DisposeOrDeferDisposal();

            // This is now a deferred disposal, move it to the deferred list
            if (removeTablet.IsDisposalPending)
            {
                _deferredTablets.Add(removeTablet.TabletDevice);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get a transformation from the tablet to the screen
        /// </summary>
        /// <param name="tablet">The tablet device to use</param>
        /// <returns>A matrix from the tablet to the screen</returns>
        private Matrix GetTabletToViewTransform(TabletDevice tablet)
        {
            Matrix matrix = (_inputSource.Value as HwndSource)?.CompositionTarget?.TransformToDevice ?? Matrix.Identity;

            matrix.Invert();
            matrix *= tablet.TabletDeviceImpl.TabletToScreen;

            return(matrix);
        }
Ejemplo n.º 3
0
        void AddTablet(uint index, TabletDevice tabletDevice)
        {
            Debug.Assert(index <= Count);
            Debug.Assert(tabletDevice.Type != (TabletDeviceType)(-1)); // make sure not the mouse tablet device!

            TabletDevice[] newTablets = new TabletDevice[Count + 1];

            uint preCopyCount  = index;
            uint postCopyCount = (uint)_tablets.Length - index;

            Array.Copy(_tablets, 0, newTablets, 0, preCopyCount);
            newTablets[index] = tabletDevice;
            Array.Copy(_tablets, index, newTablets, index + 1, postCopyCount);
            _tablets      = newTablets;
            TabletDevices = new List <TabletDevice>(_tablets);
        }
Ejemplo n.º 4
0
        internal GettingFocusEventArgs(KeyboardFocusChangedEventArgs args)
        {
            _args = args;

            InputDevice = InputManager.Current.MostRecentInputDevice switch
            {
                MouseDevice _ => FocusInputDeviceKind.Mouse,
                TouchDevice _ => FocusInputDeviceKind.Touch,
                StylusDevice _ => FocusInputDeviceKind.Pen,
                TabletDevice _ => FocusInputDeviceKind.Pen,
                KeyboardDevice _ => FocusInputDeviceKind.Keyboard,
                            _ => FocusInputDeviceKind.Mouse
            };

            OldFocusedElement = args.OldFocus as DependencyObject;
            NewFocusedElement = args.NewFocus as DependencyObject;
        }
Ejemplo n.º 5
0
        //</Snippet15>

        void GetTabletStylusPointProperties()
        {
            //<Snippet27>
            TabletDevice currentTablet = Tablet.CurrentTabletDevice;
            ReadOnlyCollection <StylusPointProperty> supportedProperties =
                currentTablet.SupportedStylusPointProperties;

            StringWriter properties = new StringWriter();

            foreach (StylusPointProperty property in supportedProperties)
            {
                properties.WriteLine(property.ToString());
            }

            MessageBox.Show(properties.ToString());
            //</Snippet27>
        }
Ejemplo n.º 6
0
        // When user clicks button,
        //  Display capabilities to panel
        private void Button1Click(object sender, RoutedEventArgs e)
        {
            // Clear the textbox if they clicked once before
            textbox1.Clear();

            // <Snippet1>
            // Get the current stylus device
            StylusDevice myStylusDevice = Stylus.CurrentStylusDevice;

            // </Snippet1>

            // Check whether we got the current stylus
            if (null == myStylusDevice)
            {
                textbox1.AppendText("No current stylus device\n");

                // Try to get it through the default tablet
                TabletDevice defaultTabletDevice = Tablet.TabletDevices[0];

                // Quit if we did not get the default tablet
                if (null == defaultTabletDevice)
                {
                    textbox1.AppendText("No default tablet device. Goodby!\n");
                    return;
                }

                // Now try to get the default stylus device through the default tablet device
                StylusDeviceCollection myStylusDeviceCollection = defaultTabletDevice.StylusDevices;

                int numStylusDevices = myStylusDeviceCollection.Count;

                // If none returned, we are toast, so quit
                if (numStylusDevices < 1)
                {
                    textbox1.AppendText("No stylus devices attached.\n");
                    return;
                }
                else
                {
                    // We have at least one stylus device, so just grab the first one
                    textbox1.AppendText("Got " + numStylusDevices + " stylus device through default tablet\n");
                    myStylusDevice = myStylusDeviceCollection[0];
                }
            }

            // See what properties the default stylus device has

            // <Snippet2>
            PresentationSource myPresentationSource = myStylusDevice.ActiveSource;

            if (null == myPresentationSource)
            {
                textbox1.AppendText("ActiveSource : null\n");
            }
            else
            {
                textbox1.AppendText("ActiveSource :" + myPresentationSource.ToString() + "\n");
            }
            // </Snippet2>

            // <Snippet15>
            TabletDevice myTabletDevice = myStylusDevice.TabletDevice;

            // </Snippet15>

            // <Snippet3>
            // Bind stylus to tablet's input element
            myStylusDevice.Capture(myStylusDevice.Target);
            // </Snippet3>

            // <Snippet4>
            // See to what Captured property is set
            // First see if it's null
            if (null == myStylusDevice.Captured)
            {
                textbox1.AppendText("Captured: null\n");
            }
            else
            {
                // Otherwise display the underlying type
                textbox1.AppendText("Captured: " + myStylusDevice.Captured.GetType().Name + "\n");
            }
            // </Snippet4>

            // <Snippet5>
            // Bind stylus to tablet's input element
            // through entire subtree
            myStylusDevice.Capture(myStylusDevice.Target, CaptureMode.SubTree);
            // </Snippet5>

            // <Snippet6>
            // See to what DirectlyOver property is set
            // First see if it's null
            if (null == myStylusDevice.DirectlyOver)
            {
                textbox1.AppendText("DirectlyOver: null\n");
            }
            else
            {
                // Otherwise display the underlying type
                textbox1.AppendText("DirectlyOver: " + myStylusDevice.DirectlyOver.GetType().Name + "\n");
            }
            // </Snippet6>

            //StylusPointDescription

            // <Snippet7>
            StylusPointCollection myStylusPoints =
                myStylusDevice.GetStylusPoints(myStylusDevice.Target);

            textbox1.AppendText("Got " + myStylusPoints.Count.ToString() + " packets\n");
            // </Snippet7>

            // <Snippet8>
            Point myPoint = myStylusDevice.GetPosition(myStylusDevice.Target);

            textbox1.AppendText("The relative position is: (" + myPoint.X.ToString() + "," + myPoint.Y.ToString() + ")\n");
            // </Snippet8>

            // <Snippet9>
            textbox1.AppendText("Id: " + myStylusDevice.Id.ToString() + "\n");
            // </Snippet9>

            // <Snippet11>
            textbox1.AppendText("InRange: " + myStylusDevice.InRange.ToString() + "\n");
            // </Snippet11>

            // <Snippet13>
            textbox1.AppendText("Name: " + myStylusDevice.Name + "\n");
            // </Snippet13>

            // <Snippet14>
            StylusButtonCollection myStylusButtonCollection = myStylusDevice.StylusButtons;

            if (null == myStylusButtonCollection)
            {
                textbox1.AppendText("StylusButtons: null\n");
            }
            else
            {
                textbox1.AppendText("# of StylusButtons == " + myStylusButtonCollection.Count.ToString() + "\n");
            }
            // </Snippet14>

            // Snippet 15 (TabletDevice property) is between snippet 2 and snippet 3

            // <Snippet16>
            // See to what Target property is set
            // First see if it's null
            if (null == myStylusDevice.Target)
            {
                textbox1.AppendText("Target: null\n");
            }
            else
            {
                // Otherwise display the underlying type
                textbox1.AppendText("Target: " + myStylusDevice.Target.GetType().Name + "\n");
            }
            // </Snippet16>

            // <Snippet17>
            textbox1.AppendText("\n" + "StylusDevice: " + myStylusDevice.ToString() + "\n");
            // </Snippet17>

            // StylusButton members

            // Dummy array to hold result of CopyTo method
            StylusButton[] myStylusButtonArray = new StylusButton[100];

            int index = 0;

            // <Snippet19>
            myStylusButtonCollection.CopyTo(myStylusButtonArray, index);
            // </Snippet19>

            // <Snippet20>
            // Get the names of the buttons
            for (int i = 0; i < myStylusButtonCollection.Count; i++)
            {
                textbox1.AppendText("Button[" + i + "]: " + myStylusButtonCollection[i].Name);
            }
            // </Snippet20>

            // <Snippet21>
            // Ensure collection access is synchronized
            //if (!myStylusButtonCollection.IsSynchronized)
            //{
            //    lock (myStylusButtonCollection.SyncRoot)
            //    {
            //        // work with collection
            //    }
            //}
            // </Snippet21>

            // <Snippet22>
            // Get the names of all of the of StylusButton objects
            // and store them in an ArrayList
            ArrayList myStylusButtonNamesArrayList = new ArrayList();

            foreach (StylusButton sb in myStylusButtonCollection)
            {
                myStylusButtonNamesArrayList.Add(sb.Name);
            }
            // </Snippet22>

            // <Snippet23>
            // Get the first StylusButton, if it exists
            if (myStylusButtonCollection.Count > 0)
            {
                StylusButton mySB = myStylusButtonCollection[0];
            }
            // </Snippet23>

            StylusButton myStylusButton = myStylusButtonCollection[0];

            // <Snippet25>
            // Get the name of the StylusButton
            textbox1.AppendText("StylusButton.Name: " + myStylusButton.Name + "\n");
            // </Snippet25>

            // <Snippet26>
            // Get the state of the StylusButton
            switch (myStylusButton.StylusButtonState)
            {
            case StylusButtonState.Down:
                textbox1.AppendText("StylusButton.State: Down\n");
                break;

            default:      // StylusButtonState.Up
                textbox1.AppendText("StylusButton.State: Up\n");
                break;
            }
            // </Snippet26>

            // <Snippet27>
            // Get the name of the StylusDevice to which the StylusButton is attached
            textbox1.AppendText("StylusButton.StylusDevice: " + myStylusButton.StylusDevice.Name + "\n");
            // </Snippet27>

            // <Snippet28>
            // Get string representation of the StylusButton
            textbox1.AppendText("\n" + myStylusButton.ToString() + "\n");
            // </Snippet28>
        }
Ejemplo n.º 7
0
        void UpdateTabletsImpl()
        {
            // REENTRANCY NOTE: Let a PenThread do this work to avoid reentrancy!
            //                  On return you get entire list of tablet and info needed to
            //                  create all the tablet devices (and stylus device info gets
            //                  cached too in penimc which avoids calls to wisptis.exe).

            // Use existing penthread if we have one otherwise grab an available one.
            PenThread penThread = _tablets.Length > 0 ? _tablets[0].As <WispTabletDevice>().PenThread :
                                  PenThreadPool.GetPenThreadForPenContext(null);

            // There was an error acquiring a PenThread, do no work here.
            if (penThread == null)
            {
                Debug.Assert(false, "Error acquiring PenThread in UpdateTabletsImpl()");
                return;
            }

            TabletDeviceInfo [] tabletdevices = penThread.WorkerGetTabletsInfo();

            // First find out the index of the mouse device (usually the first at index 0)
            uint indexMouseTablet = UInt32.MaxValue;

            for (uint i = 0; i < tabletdevices.Length; i++)
            {
                // See if this is a bogus entry first.
                if (tabletdevices[i].PimcTablet == null)
                {
                    continue;
                }

                // If it is the mouse tablet device we want to ignore it.
                if (tabletdevices[i].DeviceType == (TabletDeviceType)(-1))
                {
                    indexMouseTablet            = i;
                    tabletdevices[i].PimcTablet = null; // ignore this one!
                }
            }

            // Now figure out count of valid tablet devices left
            uint count = 0;

            for (uint k = 0; k < tabletdevices.Length; k++)
            {
                if (tabletdevices[k].PimcTablet != null)
                {
                    count++;
                }
            }

            TabletDevice[] tablets = new TabletDevice[count];

            uint tabletsIndex         = 0;
            uint unchangedTabletCount = 0;

            for (uint iTablet = 0; iTablet < tabletdevices.Length; iTablet++)
            {
                if (tabletdevices[iTablet].PimcTablet == null)
                {
                    continue; // Skip looking at this index (mouse and bogus tablets are ignored).
                }

                int id = tabletdevices[iTablet].Id;

                // First see if same index has not changed (typical case)
                if (tabletsIndex < _tablets.Length && _tablets[tabletsIndex] != null && _tablets[tabletsIndex].Id == id)
                {
                    tablets[tabletsIndex]  = _tablets[tabletsIndex];
                    _tablets[tabletsIndex] = null; // clear to ignore on cleanup pass.
                    unchangedTabletCount++;
                }
                else
                {
                    // Look up and see if we have this tabletdevice created already...
                    TabletDevice tablet = null;
                    for (uint i = 0; i < _tablets.Length; i++)
                    {
                        if (_tablets[i] != null && _tablets[i].Id == id)
                        {
                            tablet      = _tablets[i];
                            _tablets[i] = null; // clear it so we don't dispose it.
                            break;
                        }
                    }
                    // Not found so create it.
                    if (tablet == null)
                    {
                        try
                        {
                            tablet = new TabletDevice(new WispTabletDevice(tabletdevices[iTablet], penThread));
                        }
                        catch (InvalidOperationException ex)
                        {
                            // This is caused by the Stylus ID not being unique when trying
                            // to register it in the StylusLogic.__stylusDeviceMap.  If we
                            // come across a dup then just ignore registering this tablet device.
                            // There seems to be an issue in wisptis where different tablet IDs get
                            // duplicate Stylus Ids when installing the VHID test devices.
                            if (ex.Data.Contains("System.Windows.Input.StylusLogic"))
                            {
                                continue; // Just go to next without adding this one.
                            }
                            else
                            {
                                throw; // not an expected exception, rethrow it.
                            }
                        }
                    }
                    tablets[tabletsIndex] = tablet;
                }

                tabletsIndex++;
            }

            if (unchangedTabletCount == _tablets.Length &&
                unchangedTabletCount == tabletsIndex &&
                tabletsIndex == count)
            {
                // Keep the _tablet reference when nothing changes.
                // The reason is that if this method gets called from within
                // CreateContexts while looping on _tablets, it could result in
                // a null ref exception since the original _tablets array has
                // been purged to nulls.
                // NOTE: There is still the case of changing the ref (else case below)
                // when tablet devices actually change. But such a case is rare
                // (if not improbable) from within CreateContexts.
                Array.Copy(tablets, 0, _tablets, 0, count);
                _indexMouseTablet = indexMouseTablet;
            }
            else
            {
                // See if we need to re alloc the array due to invalid tabletdevice being seen.
                if (tabletsIndex != count)
                {
                    TabletDevice[] updatedTablets = new TabletDevice[tabletsIndex];
                    Array.Copy(tablets, 0, updatedTablets, 0, tabletsIndex);
                    tablets = updatedTablets;
                }

                DisposeTablets();            // Clean up any non null TabletDevice entries on old array.
                _tablets          = tablets; // set updated tabletdevice array
                TabletDevices     = new List <TabletDevice>(_tablets);
                _indexMouseTablet = indexMouseTablet;
            }

            // DevDiv:1078091
            // Any deferred tablet should be properly disposed of when applicable and
            // removed from the list of deferred tablets.
            DisposeDeferredTablets();
        }
Ejemplo n.º 8
0
        // To use Loaded event put Loaded="WindowLoaded" attribute in root element of .xaml file.
        // private void WindowLoaded(object sender, EventArgs e) {}

        // When user clicks button, display capabilities in panel
        private void Button1Click(object sender, RoutedEventArgs e)
        {
            // Clear the textbox if they clicked once before
            textbox1.Clear();

            // Find out if we have more than one tablet device
            int count = Tablet.TabletDevices.Count;

            if (count == 1)
            {
                textbox1.AppendText("There is one tablet device\n");
            }
            else
            {
                textbox1.AppendText("There are " + count + " tablet devices\n");
            }

            // <Snippet7>
            // Get the current tablet device, if it exists
            TabletDevice myCurrentTabletDevice = Tablet.CurrentTabletDevice;

            // </Snippet7>

            if (null != myCurrentTabletDevice)
            {
                textbox1.AppendText("INFO: Got the current tablet device\n");
            }
            else
            {
                textbox1.AppendText("INFO: Cannot get the current tablet device\n");
            }

            // <Snippet15>
            // Get the TabletDevice objects
            TabletDeviceCollection myTabletDeviceCollection = Tablet.TabletDevices;

            // <Snippet24>
            // Display the types of TabletDevices
            foreach (TabletDevice td in myTabletDeviceCollection)
            {
                Console.WriteLine(td.Type);
            }
            // </Snippet24>
            // </Snippet15>

            // Store them in an array of strings
            // <Snippet16>
            // Get the number of tablet devices
            int numTabletDevices = myTabletDeviceCollection.Count;

            // </Snippet16>

            // <Snippet19>
            string[] myTabletDeviceNamesArray = new string[numTabletDevices];

            for (int i = 0; i < numTabletDevices; i++)
            {
                myTabletDeviceNamesArray[i] = myTabletDeviceCollection[i].Name;
            }
            // </Snippet19>

            bool gotCurrentTabletDevice = false;

            // Display a list of tablet device names
            for (int i = 0; i < numTabletDevices; i++)
            {
                TabletDevice theTD = myTabletDeviceCollection[i];

                textbox1.AppendText("TabletDevice[" + i + "].Name == \"" + theTD.Name + "\"");

                // Is this one the current TabletDevice?
                if (theTD == myCurrentTabletDevice)
                {
                    textbox1.AppendText(" (current tablet device)\n\n");

                    gotCurrentTabletDevice = true;
                }
                else
                {
                    textbox1.AppendText("\n\n");
                }
            }

            if (!gotCurrentTabletDevice)
            {
                textbox1.AppendText("No match for current tablet device\n\n");
            }

            // <Snippet17>
            // Is the collection thread safe?
            if (!myTabletDeviceCollection.IsSynchronized)
            {
                // If not, use SyncRoot to lock access
                lock (myTabletDeviceCollection.SyncRoot)
                {
                    // work with collection
                }
            }
            // </Snippet17>

            TabletDevice[] myTabletDeviceArray = new TabletDevice[100];
            int            index = 0;

            // <Snippet18>
            // Copy the collection to array of tablet devices starting at position index
            myTabletDeviceCollection.CopyTo(myTabletDeviceArray, index);
            // </Snippet18>

            // <Snippet3>
            // Get the first tablet device
            TabletDevice myTabletDevice = Tablet.TabletDevices[0];

            // </Snippet3>

            // If tablet device exists, display its capabilities
            if (null != myTabletDevice)
            {
                textbox1.AppendText("TABLET\n\n");
                textbox1.AppendText("Properties\n\n");

                // Display the tablet device properties

                // <Snippet4>
                PresentationSource myPresentationSource = myTabletDevice.ActiveSource;

                if (null != myPresentationSource)
                {
                    textbox1.AppendText("ActiveSource.RootVisual: " + myPresentationSource.RootVisual.ToString() + "\n");
                }
                else
                {
                    textbox1.AppendText("ActiveSource: null\n");
                }
                // </Snippet4>

                // <Snippet5>
                System.Windows.Threading.Dispatcher myDispatcher = myTabletDevice.Dispatcher;

                if (null != myDispatcher)
                {
                    textbox1.AppendText("Dispatcher: " + myDispatcher.ToString() + "\n");
                }
                else
                {
                    textbox1.AppendText("Dispatcher: null\n");
                }
                // </Snippet5>

                // <Snippet8>
                textbox1.AppendText("Id: " + myTabletDevice.Id + "\n");
                // </Snippet8>

                // <Snippet9>
                textbox1.AppendText("Name: " + myTabletDevice.Name + "\n");
                // </Snippet9>

                // <Snippet10>
                textbox1.AppendText("ProductId: " + myTabletDevice.ProductId + "\n");
                // </Snippet10>

                // <Snippet11>
                // Get the StylusDevice objects.
                StylusDeviceCollection myStylusDeviceCollection = myTabletDevice.StylusDevices;

                // Get the names of all of the of StylusDevice objects.
                string[] myStylusDeviceNames = new string[myStylusDeviceCollection.Count];

                for (int i = 0; i < myStylusDeviceCollection.Count; i++)
                {
                    myStylusDeviceNames[i] = myStylusDeviceCollection[i].Name;
                }
                // </Snippet11>

                // Or store them in an array of strings

                // <Snippet20>
                // Get the number of stylus devices
                int numStylusDevices = myStylusDeviceCollection.Count;
                // </Snippet20>

                // <Snippet21>
                string[] myStylusDeviceNamesArray = new string[numStylusDevices];

                for (int i = 0; i < numStylusDevices; i++)
                {
                    myStylusDeviceNamesArray[i] = myStylusDeviceCollection[i].Name;
                }
                // </Snippet21>

                // <Snippet22>
                // Is the collection thread safe?
                //if (!myStylusDeviceCollection.IsSynchronized)
                //{
                //    // If not, use SyncRoot to lock access
                //    lock (myStylusDeviceCollection.SyncRoot)
                //    {
                //        // work with collection
                //    }
                //}
                // </Snippet22>

                StylusDevice[] myStylusDeviceArray = new StylusDevice[100];
                index = 0;

                // <Snippet23>
                // Copy the collection to array of stylus devices starting at position index
                myStylusDeviceCollection.CopyTo(myStylusDeviceArray, index);
                // </Snippet23>

                for (int i = 0; i < myStylusDeviceCollection.Count; i++)
                {
                    textbox1.AppendText("StylusDevice[" + i + "] name: " + myStylusDeviceCollection[i].Name + "\n");
                }

                // <Snippet12>
                //StylusPointDescription myStylusPointDescription = myTabletDevice.StylusPacketDescription;
                // </Snippet12>

                //if (null != myStylusPointDescription)
                //{
                //    textbox1.AppendText("StylusPointDescription\n");
                //    textbox1.AppendText("    Number of buttons: " + myStylusPointDescription.ButtonCount + "\n");

                //    // Buttons
                //    for (int k = 0; k < myTabletDevice.StylusPacketDescription.ButtonCount; k++)
                //    {
                //        textbox1.AppendText("        Button[" + k + "] GUID: " + myStylusPointDescription.GetButton(k).ToString() + "\n");
                //    }

                //    textbox1.AppendText("    Packet size: " + myStylusPointDescription.PacketSize + "\n");
                //    textbox1.AppendText("    Number of values: " + myStylusPointDescription.ValueCount + "\n");

                //    // Stylus metrics
                //    ReadOnlyCollection<StylusPointPropertyInfo> myStylusPointProperties =
                //                                    myStylusPointDescription.GetStylusPointProperties();

                //    // If metrics exist, display them
                //    if (null != myStylusPointProperties)
                //    {
                //        for (int j = 0; j < myStylusPointProperties.Length; j++)
                //        {
                //            textbox1.AppendText("    Metric[" + j + "]\n");
                //            textbox1.AppendText("        Name:       " + GetPacketValueName(myStylusPointProperties[j].Guid) + "\n");
                //            textbox1.AppendText("        Guid:       " + myStylusPointProperties[j].Id.ToString() + "\n");
                //            textbox1.AppendText("        Min:        " + myStylusPointProperties[j].Minimum.ToString() + "\n");
                //            textbox1.AppendText("        Max:        " + myStylusPointProperties[j].Maximum.ToString() + "\n");
                //            textbox1.AppendText("        Unit:       " + myStylusPointProperties[j].Unit.ToString() + "\n");
                //            textbox1.AppendText("        Resolution: " + myStylusPointProperties[j].Resolution.ToString() + "\n");
                //            textbox1.AppendText("\n");
                //        }
                //    }
                //}
                //else
                //{
                //    textbox1.AppendText("StylusPacketDescription: null\n");
                //}

                // <Snippet13>
                if (null != myTabletDevice.Target)
                {
                    textbox1.AppendText("Target: " + myTabletDevice.Target.GetType().Name + "\n");
                }
                else
                {
                    textbox1.AppendText("Target: null\n");
                }
                // </Snippet13>

                // <Snippet2>
                // Get the type of tablet device
                TabletDeviceType myTabletDeviceType = myTabletDevice.Type;

                // Display the type of tablet device
                textbox1.AppendText("Type: ");

                switch (myTabletDeviceType)
                {
                case TabletDeviceType.Stylus:
                    textbox1.AppendText("Stylus\n");
                    break;

                default:     // TabletDeviceType.Touch:
                    textbox1.AppendText("Touch Pad\n");
                    break;
                }
                // </Snippet2>

                // Show output from TabletDevice.ToString()
                // <Snippet14>
                textbox1.AppendText("\n\nTablet Device:" + myTabletDevice.ToString() + "\n\n");
                // </Snippet14>

                textbox1.AppendText("\n");

                // <Snippet1>
                // Get the capabilities of the current tablet device
                TabletHardwareCapabilities myHWCaps = myTabletDevice.TabletHardwareCapabilities;
                // </Snippet1>

                // <Snippet26>
                if ((Tablet.CurrentTabletDevice.TabletHardwareCapabilities
                     & TabletHardwareCapabilities.SupportsPressure) ==
                    TabletHardwareCapabilities.SupportsPressure)
                {
                    textbox1.AppendText("The tablet can detect the pressure of the teblet pen.");
                }
                // </Snippet26>

                textbox1.AppendText("\n");

                //// Get the current stylus, if it exists:
                //StylusDevice myStylusDevice = myTabletDevice.StylusDevices[0];

                //// If stylus exists, print its properties
                //if (null != myStylusDevice)
                //{
                //    textbox1.AppendText("STYLUS\n\n");

                //    textbox1.AppendText("ActiveSource: " + GetStringOrNull(myStylusDevice.ActiveSource) + "\n");
                //    textbox1.AppendText("Captured: " + GetStringOrNull(myStylusDevice.Captured) + "\n");
                //    textbox1.AppendText("DirectlyOver: " + GetStringOrNull(myStylusDevice.DirectlyOver) + "\n");
                //    textbox1.AppendText("Dispatcher: " + GetStringOrNull(myStylusDevice.Dispatcher) + "\n");
                //    textbox1.AppendText("ID: " + GetStringOrNull(myStylusDevice.Id) + "\n");
                //    textbox1.AppendText("InAir: " + GetStringOrNull(myStylusDevice.InAir) + "\n");
                //    textbox1.AppendText("InRange: " + GetStringOrNull(myStylusDevice.InRange) + "\n");
                //    textbox1.AppendText("Inverted: " + GetStringOrNull(myStylusDevice.Inverted) + "\n");
                //    textbox1.AppendText("Name: " + GetStringOrNull(myStylusDevice.Name) + "\n");
                //    textbox1.AppendText("PacketCount: " + GetStringOrNull(myStylusDevice.GetPackets(null).PacketCount) + "\n");
                //    textbox1.AppendText("Tablet Device: " + GetStringOrNull(myStylusDevice.TabletDevice.Name) + "\n");
                //    textbox1.AppendText("Tablet Position: " + GetStringOrNull(myStylusDevice.GetPosition(null)) + "\n");
                //    textbox1.AppendText("Target: " + GetStringOrNull(myStylusDevice.Target) + "\n");
                //}
            }
        }