Ejemplo n.º 1
0
        private SensorContext CreateAndAddSensorContext(InkInputProvider inkInputProvider, InputDevice inputDevice)
        {
            // Create the sensor channel groups using the input provider and device
            SensorChannelsContext defaultSensorChannelsContext = CreateChannelsGroup(inkInputProvider, inputDevice);

            SensorChannelsContext specialChannelsContext = new SensorChannelsContext(
                inkInputProvider,
                inputDevice,
                new List <SensorChannel> {
                mTimestampSensorChannel
            },                                                      //, mSpecialPressureSensorChannel },
                latency: 2,
                samplingRateHint: 2);

            // Create the sensor context using the sensor channels contexts
            SensorContext sensorContext = new SensorContext();

            sensorContext.AddSensorChannelsContext(defaultSensorChannelsContext);
            //sensorContext.AddSensorChannelsContext(specialChannelsContext);

            Identifier sensorContextId = sensorContext.Id;
            bool       res             = InkDocument.InputConfiguration.SensorContexts.Any((context) => context.Id == sensorContextId);

            if (!res)
            {
                InkDocument.InputConfiguration.SensorContexts.Add(sensorContext);
            }

            return(sensorContext);
        }
Ejemplo n.º 2
0
        private void InitInputConfig()
        {
            // Init input providers
            var mouseInputProvider = new InkInputProvider(InkInputType.Mouse);
            var touchInputProvider = new InkInputProvider(InkInputType.Touch);
            var penInputProvider   = new InkInputProvider(InkInputType.Pen);

            mouseInputProvider.Seal();
            touchInputProvider.Seal();
            penInputProvider.Seal();

            // Cache input providers
            mInkInputProvidersMap.Add(mouseInputProvider.Id, mouseInputProvider);
            mInkInputProvidersMap.Add(touchInputProvider.Id, touchInputProvider);
            mInkInputProvidersMap.Add(penInputProvider.Id, penInputProvider);

            // Init input device
            mCurrentInputDevice.Properties["dev.name"]         = mEAS.FriendlyName;
            mCurrentInputDevice.Properties["dev.model"]        = mEAS.SystemProductName;
            mCurrentInputDevice.Properties["dev.manufacturer"] = mEAS.SystemManufacturer;
            mCurrentInputDevice.Seal();

            // Cache input device
            mInputDevices.Add(mCurrentInputDevice.Id, mCurrentInputDevice);

            // Init environment
            mEnvironment.Properties["os.name"]         = mEAS.OperatingSystem;
            mEnvironment.Properties["os.version.code"] = System.Environment.OSVersion.Version.ToString();
            mEnvironment.Seal();

            // Cache the environment
            mEnvironments.Add(mEnvironment.Id, mEnvironment);

            // Init sensor channels contexts
            SensorChannelsContext mouseSensorChannelsContext = CreateChannelsGroup(mouseInputProvider, mCurrentInputDevice);
            SensorChannelsContext touchSensorChannelsContext = CreateChannelsGroup(touchInputProvider, mCurrentInputDevice);
            SensorChannelsContext penSensorChannelsContext   = CreateChannelsGroup(penInputProvider, mCurrentInputDevice);

            // Cache sensor channels contexts
            mSensorChannelsContexts.Add(mouseSensorChannelsContext.Id, mouseSensorChannelsContext);
            mSensorChannelsContexts.Add(touchSensorChannelsContext.Id, touchSensorChannelsContext);
            mSensorChannelsContexts.Add(penSensorChannelsContext.Id, penSensorChannelsContext);

            // Init sensor contexts
            SensorContext mouseSensorContext = new SensorContext();

            mouseSensorContext.AddSensorChannelsContext(mouseSensorChannelsContext);

            SensorContext touchSensorContext = new SensorContext();

            touchSensorContext.AddSensorChannelsContext(touchSensorChannelsContext);

            SensorContext penSensorContext = new SensorContext();

            penSensorContext.AddSensorChannelsContext(penSensorChannelsContext);

            // Cache sensor contexts
            mSensorContexts.Add(mouseSensorContext.Id, mouseSensorContext);
            mSensorContexts.Add(touchSensorContext.Id, touchSensorContext);
            mSensorContexts.Add(penSensorContext.Id, penSensorContext);

            // Init input contexts
            InputContext mouseInputContext = new InputContext(mEnvironment.Id, mouseSensorContext.Id);
            InputContext touchInputContext = new InputContext(mEnvironment.Id, touchSensorContext.Id);
            InputContext penInputContext   = new InputContext(mEnvironment.Id, penSensorContext.Id);

            // Cache input contexts
            mInputContexts.Add(mouseInputContext.Id, mouseInputContext);
            mInputContexts.Add(touchInputContext.Id, touchInputContext);
            mInputContexts.Add(penInputContext.Id, penInputContext);

            mDeviceTypeMap.Add(PointerDeviceType.Mouse, mouseInputContext.Id);
            mDeviceTypeMap.Add(PointerDeviceType.Touch, touchInputContext.Id);
            mDeviceTypeMap.Add(PointerDeviceType.Pen, penInputContext.Id);
        }