Exemplo n.º 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);
        }
Exemplo n.º 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);
        }