Пример #1
0
        private IEnumerator Hold()
        {
            yield return(new WaitForSeconds(Delay));

            if (isHold)
            {
                LongPress?.Invoke();
            }
        }
Пример #2
0
        private IEnumerator ContinuousHold()
        {
            yield return(new WaitForSeconds(Delay));

            while (isHold)
            {
                yield return(null);

                LongPress?.Invoke();
            }
        }
Пример #3
0
        private async void OnPreviewPress(object sender, RoutedEventArgs e)
        {
            if (!IsEnabled)
            {
                return;
            }

            if (firstMouseDownHash == -1)
            {
                firstMouseDownHash = GetHashCode();
                IsPressedInternal  = true;

                if (e is MouseButtonEventArgs)
                {
                    PreviewMouseLeftButtonDown?.Invoke(sender, e as MouseButtonEventArgs);
                }
                else if (e is TouchEventArgs)
                {
                    PreviewTouchDown?.Invoke(sender, e as TouchEventArgs);
                }

                PressHold?.Invoke(this, new PressHoldEventArgs(PressHoldEventArgs.EventType.Press));
                if (LongPressEnabled)
                {
                    var longPressMSec      = LongPressDelay.TotalMilliseconds;
                    var longPressStep      = 10;
                    var longPressStepDelay = longPressMSec / longPressStep;

                    while (longPressMSec > 0)
                    {
                        if (firstMouseDownHash == -1)
                        {
                            break;
                        }
                        await Task.Delay(TimeSpan.FromMilliseconds(longPressStepDelay));

                        longPressMSec -= longPressStepDelay;
                    }

                    if (firstMouseDownHash == GetHashCode())
                    {
                        ReleaseAllTouchCaptures();
                        ReleaseMouseCapture();

                        firstMouseDownHash = -1;
                        LongPress?.Invoke(this, e);
                        IsPressedInternal = false;
                        e.Handled         = true;
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Raises the <see cref="LongPress"/> event.
 /// </summary>
 /// <param name="touchID">The unique identifier of the touch input.</param>
 /// <param name="fingerID">The unique identifier of the finger which caused the touch.</param>
 /// <param name="x">The normalized x-coordinate of the touch.</param>
 /// <param name="y">The normalized y-coordinate of the touch.</param>
 /// <param name="pressure">The normalized pressure of the touch.</param>
 protected virtual void OnLongPress(Int64 touchID, Int64 fingerID, Single x, Single y, Single pressure)
 {
     LongPress?.Invoke(this, touchID, fingerID, x, y, pressure);
 }
Пример #5
0
 public void HandleLongPress(object sender, EventArgs e)
 {
     LongPress?.Invoke(this, new EventArgs());
 }
Пример #6
0
 public void OnLongPress(JuniperPointerEventData evt)
 {
     onLongPress?.Invoke(evt);
     LongPress?.Invoke(this, evt);
 }
Пример #7
0
 protected virtual void OnLongPress()
 {
     LongPress?.Invoke(this, EventArgs.Empty);
 }
Пример #8
0
 public virtual void OnLongPress()
 {
     onLongPress?.Invoke();
     LongPress?.Invoke(this, EventArgs.Empty);
 }
Пример #9
0
 public void OnLongPress(object v)
 {
     LongPress?.Invoke(this, new SelectedItemChangedEventArgs(v));
     LongPressCommand?.Execute(v);
 }