private static void Raise(IInputElement target, InputEventArgs e)
 {
     if (InputMappers.TryGetValue(e.GetType(), out var mappers))
     {
         mappers.ForEach(mapper => mapper?.Invoke(target, e));
     }
 }
Exemple #2
0
        void OnActivity(object sender, PreProcessInputEventArgs e)
        {
            InputEventArgs inputEventArgs = e.StagingItem.Input;

            if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs)
            {
                if (e.StagingItem.Input is MouseEventArgs)
                {
                    MouseEventArgs mouseEventArgs = (MouseEventArgs)e.StagingItem.Input;

                    // no button is pressed and the position is still the same as the application became inactive
                    if (isTest)
                    {
                        Trace.WriteLine($"Mouse Position={_inactiveMousePosition == mouseEventArgs.GetPosition(_inputElement)}");
                    }
                    if (mouseEventArgs.LeftButton == MouseButtonState.Released &&
                        mouseEventArgs.RightButton == MouseButtonState.Released &&
                        mouseEventArgs.MiddleButton == MouseButtonState.Released &&
                        mouseEventArgs.XButton1 == MouseButtonState.Released &&
                        mouseEventArgs.XButton2 == MouseButtonState.Released &&
                        _inactiveMousePosition == mouseEventArgs.GetPosition(_inputElement))
                    {
                        return;
                    }
                }
                if (isTest)
                {
                    Trace.WriteLine($"Idle reset={inputEventArgs.GetType()}");
                }
                _activityTimer.Stop();
                _activityTimer.Start();
            }
        }
Exemple #3
0
        /// <summary>
        /// Deals with Mouse or touch screen events for when User releases button
        /// </summary>
        /// <param name="e"></param>
        private void OnSmartButtonUp(InputEventArgs e)
        {
            if (EnableClickHold)
            {
                if (Timer != null)
                {
                    try
                    {
                        if (e.GetType() == typeof(TouchEventArgs))
                        {
                            e.Handled = true;
                        }
                        else
                        {
                            e.Handled = false;
                        }

                        //Enable the timer
                        bool isMouseReleaseBeforeHoldTimeout = Timer.IsEnabled;

                        ResetAndRemoveTimer();

                        // Consider it as a mouse click
                        if (isMouseReleaseBeforeHoldTimeout)
                        {
                            //Command.Execute(CommandParameter);
                        }

                        //if (e.GetType() == typeof(TouchEventArgs))
                        //{
                        //    //e.Handled = true;
                        //}
                        //else
                    }
                    catch { }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Deals with Mouse or touch screen events for when User pushes the button
        /// </summary>
        /// <param name="e"></param>
        private void OnSmartButtonDown(InputEventArgs e)
        {
            if (EnableClickHold)
            {
                if (e.GetType() == typeof(TouchEventArgs))
                {
                    e.Handled = true;
                }
                else
                {
                    e.Handled = false;
                }

                //Create a timer
                Timer = new DispatcherTimer(DispatcherPriority.Normal, this.Dispatcher)
                {
                    Interval = TimeSpan.FromMilliseconds(MillisecondsToWait)
                };

                Timer.Tick     += Timer_Tick;
                Timer.IsEnabled = true;
                Timer.Start();
            }
        }