コード例 #1
0
        // Inputs from topGrid are transferred to bottomGrid in this method
        void ProcessTopGridInput(PointerRoutedEventArgs args)
        {
            var point = args.GetCurrentPoint(topGrid);

            SetPressureText(point, topPressureRun);

            // Calculate the actual position of bottomGrid on the monitor, so that pen inputs can injected onto bottomGrid
            var bottomGridPointerPosition = GetBottomGridPointerPosition(point.Position);

            // Initialize the InjectedInputPenInfo using the pressure from topGrid's pointer input
            var injectedPenInfo = new InjectedInputPenInfo()
            {
                PenParameters = InjectedInputPenParameters.Pressure,
                Pressure      = point.Properties.Pressure,
                PointerInfo   = new InjectedInputPointerInfo()
                {
                    PointerId      = point.PointerId,
                    PointerOptions = (point.IsInContact) ? InjectedInputPointerOptions.InContact : InjectedInputPointerOptions.None,
                    PixelLocation  = new InjectedInputPoint()
                    {
                        PositionX = (int)bottomGridPointerPosition.X, PositionY = (int)bottomGridPointerPosition.Y
                    }
                }
            };

            inputInjector.InjectPenInput(injectedPenInfo);
        }
コード例 #2
0
        public void InjectInputForPen(int x, int y, double pressure, bool contact)
        {
            prevContact = contact;
            InjectedInputPenInfo info = new InjectedInputPenInfo();

            info.PenParameters = InjectedInputPenParameters.Pressure;
            InjectedInputPointerOptions options;

            if (contact)
            {
                if (prevContact)
                {
                    options = InjectedInputPointerOptions.Update | InjectedInputPointerOptions.InContact | InjectedInputPointerOptions.InRange;
                }
                else
                {
                    options = InjectedInputPointerOptions.PointerDown | InjectedInputPointerOptions.InContact | InjectedInputPointerOptions.InRange;
                    System.Diagnostics.Debug.WriteLine("pointer down");
                }
            }
            else
            {
                if (prevContact)
                {
                    options = InjectedInputPointerOptions.PointerUp | InjectedInputPointerOptions.InRange;
                }
                else
                {
                    options = InjectedInputPointerOptions.Update | InjectedInputPointerOptions.InRange;
                }
            }
            info.PointerInfo = new InjectedInputPointerInfo {
                PointerId                = pointerID,
                PointerOptions           = options,
                TimeOffsetInMilliseconds = 0,
                PixelLocation            = new InjectedInputPoint {
                    PositionX = x,
                    PositionY = y
                }
            };
            info.Pressure = pressure;
            inputInjector.InjectPenInput(info);
        }
コード例 #3
0
        InjectedInputPenInfo GetInjectedInputPenInfo(PointerData pointerData)
        {
            var injectedInputPenInfo = new InjectedInputPenInfo();

            injectedInputPenInfo.PenParameters = 0;
            InjectedInputPoint injectedInputPoint;

            injectedInputPoint.PositionX = pointerData.location.X;
            injectedInputPoint.PositionY = pointerData.location.Y;
            InjectedInputPointerInfo inputPointerInfo;

            inputPointerInfo.PointerOptions           = (InjectedInputPointerOptions)(int)pointerData.flags;
            inputPointerInfo.PointerId                = (uint)(int)pointerData.pointerId;
            inputPointerInfo.PixelLocation            = injectedInputPoint;
            inputPointerInfo.PerformanceCount         = 0L;
            inputPointerInfo.TimeOffsetInMilliseconds = 0;
            injectedInputPenInfo.PointerInfo          = inputPointerInfo;
            return(injectedInputPenInfo);
        }
コード例 #4
0
        private async void manualInputButton_Click(object sender, RoutedEventArgs e)
        {
            // Get a point at the center of bottomGrid, this is the position the pen input will be injected at
            var position = GetBottomGridPointerPosition(new Point(bottomGrid.ActualWidth / 2, bottomGrid.ActualHeight / 2));

            var injectedPenInfo = new InjectedInputPenInfo()
            {
                PenParameters = InjectedInputPenParameters.Pressure,
                Pressure      = pressureSlider.Value,
                PointerInfo   = new InjectedInputPointerInfo()
                {
                    PointerId      = 35254,
                    PointerOptions = InjectedInputPointerOptions.InContact,
                    PixelLocation  = new InjectedInputPoint()
                    {
                        PositionX = (int)position.X, PositionY = (int)position.Y
                    }
                }
            };

            inputInjector.InjectPenInput(injectedPenInfo);

            // Release the pen input after a second
            await Task.Delay(1000);

            injectedPenInfo = new InjectedInputPenInfo()
            {
                PenParameters = InjectedInputPenParameters.Pressure,
                Pressure      = pressureSlider.Value,
                PointerInfo   = new InjectedInputPointerInfo()
                {
                    PointerId     = 35254,
                    PixelLocation = new InjectedInputPoint()
                    {
                        PositionX = (int)position.X, PositionY = (int)position.Y
                    }
                }
            };

            inputInjector.InjectPenInput(injectedPenInfo);
        }