internal PointerStylusDevice(PointerTabletDevice tabletDevice, UnsafeNativeMethods.POINTER_DEVICE_CURSOR_INFO cursorInfo) { _cursorInfo = cursorInfo; _tabletDevice = tabletDevice; _pointerLogic = StylusLogic.GetCurrentStylusLogicAs <PointerLogic>(); // Touch devices have a special set of handling code if (tabletDevice.Type == TabletDeviceType.Touch) { TouchDevice = new PointerTouchDevice(this); } _interactionEngine = new PointerInteractionEngine(this); _interactionEngine.InteractionDetected += HandleInteraction; List <StylusButton> buttons = new List <StylusButton>(); // Create a button collection for this StylusDevice based off the button properties stored in the tablet // This needs to be done as each button instance has a StylusDevice owner that it uses to access the raw // data in the StylusDevice. foreach (var prop in _tabletDevice.DeviceInfo.StylusPointProperties) { if (prop.IsButton) { StylusButton button = new StylusButton(StylusPointPropertyIds.GetStringRepresentation(prop.Id), prop.Id); button.SetOwner(this); buttons.Add(button); } } _stylusButtons = new StylusButtonCollection(buttons); }
private void BuildStylusDevices() { UInt32 cursorCount = 0; List <PointerStylusDevice> pointerStylusDevices = new List <PointerStylusDevice>(); if (UnsafeNativeMethods.GetPointerDeviceCursors(_deviceInfo.Device, ref cursorCount, null)) { UnsafeNativeMethods.POINTER_DEVICE_CURSOR_INFO[] cursors = new UnsafeNativeMethods.POINTER_DEVICE_CURSOR_INFO[cursorCount]; if (UnsafeNativeMethods.GetPointerDeviceCursors(_deviceInfo.Device, ref cursorCount, cursors)) { foreach (var cursor in cursors) { PointerStylusDevice stylus = new PointerStylusDevice(this, cursor); _stylusDeviceMap.Add(stylus.CursorId, stylus); pointerStylusDevices.Add(stylus); } } } _stylusDevices = new StylusDeviceCollection(pointerStylusDevices.ToArray()); }