예제 #1
0
 protected virtual void OnPointMove(InputPointsEventArgs args)
 {
     if (PointMove != null)
     {
         PointMove(this, args);
     }
 }
예제 #2
0
        protected void PointEventTranslator_PointDown(object sender, InputPointsEventArgs e)
        {
            if (State == CaptureState.Ready || State == CaptureState.Capturing || State == CaptureState.CapturingInvalid)
            {
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;

                var timeout = AppConfig.InitialTimeout;
                if (timeout > 0)
                {
                    if (_initialTimeoutTimer == null)
                    {
                        _initialTimeoutTimer = new System.Threading.Timer(InitialTimeoutCallback, null, Timeout.Infinite, Timeout.Infinite);
                    }
                    _initialTimeoutTimer.Change(timeout, Timeout.Infinite);
                }

                if (_lastGestureTime != null && Environment.TickCount - _lastGestureTime.Value > GestureStackTimeout)
                {
                    _isGestureStackTimeout = true;
                }

                // Try to begin capture process, if capture started then don't notify other applications of a Point event, otherwise do
                if (!TryBeginCapture(e.InputPointList))
                {
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                }
                else
                {
                    e.Handled = Mode != CaptureMode.UserDisabled;
                }
            }
        }
예제 #3
0
 protected virtual void OnPointDown(InputPointsEventArgs args)
 {
     if (PointDown != null)
     {
         PointDown(this, args);
     }
 }
예제 #4
0
 protected virtual void OnPointMove(InputPointsEventArgs args)
 {
     if (SourceDevice != args.PointSource)
     {
         return;
     }
     PointMove?.Invoke(this, args);
 }
예제 #5
0
        protected void PointEventTranslator_PointUp(object sender, InputPointsEventArgs e)
        {
            if (SourceDevice != Device.None && SourceDevice != e.PointSource)
            {
                return;
            }

            if (State == CaptureState.Capturing || State == CaptureState.CapturingInvalid && SourceDevice == Device.Touch)
            {
                e.Handled = Mode != CaptureMode.UserDisabled;

                EndCapture();

                if (TemporarilyDisableCapture && Mode == CaptureMode.UserDisabled)
                {
                    TemporarilyDisableCapture = false;
                    ToggleUserDisablePointCapture();
                }
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }
            else if (State == CaptureState.CapturingInvalid && SourceDevice == Device.Mouse)
            {
                if (Mode != CaptureMode.UserDisabled)
                {
                    State = CaptureState.Disabled;

                    var observeExceptionsTask = new Action <Task>(t =>
                    {
                        State = CaptureState.Ready;
                        Console.WriteLine($"{t.Exception.InnerException.GetType().Name}: {t.Exception.InnerException.Message}");
                    });

                    var clickAsync = Task.Factory.StartNew(delegate
                    {
                        InputSimulator ssSimulator = new InputSimulator();
                        ssSimulator.Mouse.RightButtonClick();
                        State = CaptureState.Ready;
                    }).ContinueWith(observeExceptionsTask, TaskContinuationOptions.OnlyOnFaulted);

                    e.Handled = true;
                }
                else
                {
                    State = CaptureState.Ready;
                }
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }
            else if (State == CaptureState.TriggerFired)
            {
                State     = CaptureState.Ready;
                e.Handled = Mode != CaptureMode.UserDisabled;
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }

            SourceDevice = Device.None;

            UpdateBlockTouchInputThreshold();
        }
예제 #6
0
 protected void PointEventTranslator_PointMove(object sender, InputPointsEventArgs e)
 {
     // Only add point if we're capturing
     if (State == CaptureState.Capturing || State == CaptureState.CapturingInvalid)
     {
         AddPoint(e.InputPointList);
     }
     UpdateBlockTouchInputThreshold();
 }
예제 #7
0
 protected virtual void OnPointDown(InputPointsEventArgs args)
 {
     if (SourceDevice != Devices.None && SourceDevice != args.PointSource && args.PointSource != Devices.Pen)
     {
         return;
     }
     SourceDevice = args.PointSource;
     PointDown?.Invoke(this, args);
 }
예제 #8
0
 private void LowLevelMouseHook_MouseDown(LowLevelMouseMessage mouseMessage, ref bool handled)
 {
     if ((MouseActions)mouseMessage.Button == AppConfig.DrawingButton && _pressedMouseButton.Count == 0)
     {
         var args = new InputPointsEventArgs(new List <InputPoint>(new[] { new InputPoint(1, mouseMessage.Point) }), Device.Mouse);
         OnPointDown(args);
         handled = args.Handled;
     }
     _pressedMouseButton.Add((MouseActions)mouseMessage.Button);
 }
예제 #9
0
        protected virtual void OnPointUp(InputPointsEventArgs args)
        {
            if (SourceDevice != Devices.None && SourceDevice != args.PointSource)
            {
                return;
            }

            PointUp?.Invoke(this, args);

            SourceDevice = Devices.None;
        }
예제 #10
0
        protected void PointEventTranslator_PointMove(object sender, InputPointsEventArgs e)
        {
            if (SourceDevice != e.PointSource)
            {
                return;
            }
            // Only add point if we're capturing
            if (State == CaptureState.Capturing || State == CaptureState.CapturingInvalid)
            {
                if (_timeoutTimer.Enabled)
                {
                    _timeoutTimer.Stop();
                }

                AddPoint(e.InputPointList);
            }
        }
예제 #11
0
        protected void PointEventTranslator_PointDown(object sender, InputPointsEventArgs e)
        {
            if (SourceDevice != Device.None && SourceDevice != e.PointSource)
            {
                return;
            }
            SourceDevice = e.PointSource;

            if (State == CaptureState.Ready || State == CaptureState.Capturing || State == CaptureState.CapturingInvalid)
            {
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;

                // Try to begin capture process, if capture started then don't notify other applications of a Point event, otherwise do
                if (!TryBeginCapture(e.InputPointList))
                {
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                }
                else
                {
                    e.Handled = Mode != CaptureMode.UserDisabled;
                }
            }
        }
예제 #12
0
        protected void PointEventTranslator_PointUp(object sender, InputPointsEventArgs e)
        {
            if (State == CaptureState.Capturing || State == CaptureState.CapturingInvalid && (SourceDevice & Devices.TouchDevice) != 0)
            {
                e.Handled = Mode != CaptureMode.UserDisabled;

                EndCapture();

                if (TemporarilyDisableCapture && Mode == CaptureMode.UserDisabled)
                {
                    TemporarilyDisableCapture = false;
                    ToggleUserDisablePointCapture();
                }
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }
            else if (State == CaptureState.CapturingInvalid && SourceDevice == Devices.Mouse)
            {
                if (Mode != CaptureMode.UserDisabled)
                {
                    State = CaptureState.Disabled;

                    var observeExceptionsTask = new Action <Task>(t =>
                    {
                        State = CaptureState.Ready;
                        Console.WriteLine($"{t.Exception.InnerException.GetType().Name}: {t.Exception.InnerException.Message}");
                    });

                    var clickAsync = Task.Factory.StartNew(delegate
                    {
                        InputSimulator simulator = new InputSimulator();
                        switch (AppConfig.DrawingButton)
                        {
                        case MouseActions.Left:
                            simulator.Mouse.LeftButtonClick();
                            break;

                        case MouseActions.Middle:
                            simulator.Mouse.MiddleButtonClick();
                            break;

                        case MouseActions.Right:
                            simulator.Mouse.RightButtonClick();
                            break;

                        case MouseActions.XButton1:
                            simulator.Mouse.XButtonClick(1);
                            break;

                        case MouseActions.XButton2:
                            simulator.Mouse.XButtonClick(2);
                            break;
                        }
                        State = CaptureState.Ready;
                    }).ContinueWith(observeExceptionsTask, TaskContinuationOptions.OnlyOnFaulted);

                    e.Handled = true;
                }
                else
                {
                    State = CaptureState.Ready;
                }
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }
            else if (State == CaptureState.TriggerFired)
            {
                State     = CaptureState.Ready;
                e.Handled = Mode != CaptureMode.UserDisabled;
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
            }

            UpdateBlockTouchInputThreshold();
            if (_initialTimeoutTimer != null)
            {
                _initialTimeoutTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }
        }
예제 #13
0
        private void LowLevelMouseHook_MouseMove(LowLevelMouseMessage mouseMessage, ref bool handled)
        {
            var args = new InputPointsEventArgs(new List <InputPoint>(new[] { new InputPoint(1, mouseMessage.Point) }), Device.Mouse);

            OnPointMove(args);
        }