示例#1
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (primaryTouchEvent.Type == TouchEventType.Down)
            {
                this.isFlick = false;
                if (this.animationState == LiveScrollPanel.AnimationState.Up)
                {
                    this.animationState = LiveScrollPanel.AnimationState.Migrate;
                    this.migrateDownPos = primaryTouchEvent.LocalPosition;
                    this.migratePos     = this.migrateDownPos;
                }
                else
                {
                    this.touchDownPos   = primaryTouchEvent.LocalPosition;
                    this.touchPos       = this.touchDownPos;
                    touchEvents.Forward = true;
                }
            }
            else if (primaryTouchEvent.Type == TouchEventType.Up)
            {
                this.isDrag = false;
            }
            if (!this.isDrag)
            {
                touchEvents.Forward = true;
            }
            if (primaryTouchEvent.Type == TouchEventType.Up)
            {
                this.animationState   = LiveScrollPanel.AnimationState.Up;
                this.flickElapsedTime = 0f;
            }
        }
示例#2
0
 protected internal virtual void OnTouchEvent(TouchEventCollection touchEvents)
 {
     this.SendTouchEventToGestureDetectors(touchEvents);
     if (this.TouchEventReceived != null)
     {
         this.TouchEventReceived.Invoke(this, new TouchEventArgs(touchEvents));
     }
 }
示例#3
0
        private void OnTouchEventImpl(TouchEventCollection touchEvents)
        {
            switch (touchEvents.PrimaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.animationState == ListPanel.AnimationState.Drag)
                {
                    this.animationState = ListPanel.AnimationState.None;
                    this.animation      = false;
                    switch (this.terminalState)
                    {
                    case ListPanel.TerminalState.Top:
                        this.terminalState = ListPanel.TerminalState.TopReset;
                        this.animation     = true;
                        break;

                    case ListPanel.TerminalState.Bottom:
                        this.terminalState = ListPanel.TerminalState.BottomReset;
                        this.animation     = true;
                        break;
                    }
                }
                if (this.ScrollBarVisibility == ScrollBarVisibility.ScrollingVisible && !this.animation)
                {
                    this.scrollBar.Visible = false;
                }
                return;

            case TouchEventType.Down:
                switch (this.terminalState)
                {
                case ListPanel.TerminalState.None:
                    this.animationState = ListPanel.AnimationState.None;
                    this.animation      = false;
                    return;

                case ListPanel.TerminalState.Top:
                case ListPanel.TerminalState.TopReset:
                    this.ResetTopTerminalItems();
                    return;

                case ListPanel.TerminalState.Bottom:
                case ListPanel.TerminalState.BottomReset:
                    this.ResetBottomTerminalItems();
                    return;

                default:
                    return;
                }

//				break;
            default:
                return;
            }
        }
示例#4
0
 protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
 {
     base.OnTouchEvent(touchEvents);
     if (touchEvents.PrimaryTouchEvent.Type == TouchEventType.Down)
     {
         this.dialog      = new TextInputDialog();
         this.dialog.Mode = this.TextInputMode;
         this.dialog.Text = this.Text;
         this.dialog.Open();
     }
 }
示例#5
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            if (this.ButtonState == CheckBox.CheckBoxState.Disabled)
            {
                return;
            }
            switch (touchEvents.PrimaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.buttonState == CheckBox.CheckBoxState.Pressed)
                {
                    if (this.style == CheckBoxStyle.RadioButton && this.Checked)
                    {
                        this.ButtonState    = CheckBox.CheckBoxState.Normal;
                        this.needUpdateFlag = true;
                        return;
                    }
                    this.ButtonState    = CheckBox.CheckBoxState.Normal;
                    this.Checked        = !this.Checked;
                    this.needUpdateFlag = true;
                    if (this.CheckedChanged != null)
                    {
                        this.CheckedChanged.Invoke(this, new TouchEventArgs(touchEvents));
                        return;
                    }
                }
                break;

            case TouchEventType.Down:
                this.ButtonState = CheckBox.CheckBoxState.Pressed;
                return;

            case TouchEventType.Move:
                break;

            case TouchEventType.Enter:
                this.ButtonState = CheckBox.CheckBoxState.Pressed;
                return;

            case TouchEventType.Leave:
                this.ButtonState = CheckBox.CheckBoxState.Normal;
                break;

            default:
                return;
            }
        }
示例#6
0
 protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
 {
     base.OnTouchEvent(touchEvents);
     if (!this.IsScrollable())
     {
         touchEvents.Forward = true;
         return;
     }
     if (this.animationState == ListPanel.AnimationState.None)
     {
         this.OnTouchEventImpl(touchEvents);
         touchEvents.Forward = true;
         return;
     }
     this.OnTouchEventImpl(touchEvents);
 }
示例#7
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;
            bool       flag = false;

            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.animationState == LiveListPanel.AnimationState.Drag)
                {
                    this.animationState = LiveListPanel.AnimationState.None;
                    this.isScrolling    = false;
                    flag = true;
                }
                this.UpdateScrollBarVisible();
                break;

            case TouchEventType.Down:
            {
                if (this.animationState == LiveListPanel.AnimationState.Flick)
                {
                    this.animationState = LiveListPanel.AnimationState.None;
                }
                float y = primaryTouchEvent.LocalPosition.Y;
                using (List <LiveListPanel.ListItemData> .Enumerator enumerator = this.usingItemDataList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        LiveListPanel.ListItemData current = enumerator.Current;
                        ListPanelItem item = this.GetItem(current.item.Index + 1);
                        if (item != null && current.item.Y <= y && y < item.Y)
                        {
                            this.scrollBaseIndex = current.item.Index;
                        }
                        current.scrollStartRotationZ = current.slideEndRotationZ;
                    }
                }
                this.UpdateScrollEndRotationZ();
                break;
            }
            }
            if (this.animationState == LiveListPanel.AnimationState.None && !this.isScrolling && !flag)
            {
                touchEvents.Forward = true;
            }
        }
        protected internal override GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents)
        {
            GestureDetectorResponse result = base.State;
            TouchEvent primaryTouchEvent   = touchEvents.PrimaryTouchEvent;

            if (base.State != GestureDetectorResponse.None && this.downID != primaryTouchEvent.FingerID)
            {
                return(result);
            }
            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                result = GestureDetectorResponse.FailedAndStop;
                break;

            case TouchEventType.Down:
                this.downID   = primaryTouchEvent.FingerID;
                this.downPos  = primaryTouchEvent.WorldPosition;
                this.downTime = primaryTouchEvent.Time;
                result        = GestureDetectorResponse.UndetectedAndContinue;
                break;

            case TouchEventType.Move:
            {
                float num  = primaryTouchEvent.WorldPosition.Distance(this.downPos);
                float num2 = (float)(primaryTouchEvent.Time - this.downTime).TotalMilliseconds;
                if (num <= this.MaxDistance)
                {
                    if (num2 >= this.MinPressDuration)
                    {
                        if (this.LongPressDetected != null)
                        {
                            LongPressEventArgs longPressEventArgs = new LongPressEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition, num2);
                            this.LongPressDetected.Invoke(this, longPressEventArgs);
                        }
                        result = GestureDetectorResponse.DetectedAndContinue;
                    }
                }
                else
                {
                    result = GestureDetectorResponse.FailedAndStop;
                }
                break;
            }
            }
            return(result);
        }
示例#9
0
            protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
            {
                base.OnTouchEvent(touchEvents);
                TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

                switch (primaryTouchEvent.Type)
                {
                case TouchEventType.Up:
                    this.isPress = false;
                    if (this.animationState != InternalSpinBox.SpinList.AnimationState.Flick && this.IsItemFit)
                    {
                        if (this.ScrollAreaPixelOffset > this.ItemGapLine * 0.5f)
                        {
                            this.fitTargetIndex = this.ScrollAreaFirstLine + 1;
                        }
                        else
                        {
                            this.fitTargetIndex = this.ScrollAreaFirstLine;
                        }
                        this.fitTargetOffsetPixel = 0f;
                        this.animationState       = InternalSpinBox.SpinList.AnimationState.Fit;
                        this.fitInterpRate        = 0.2f;
                    }
                    break;

                case TouchEventType.Down:
                    this.animationState = InternalSpinBox.SpinList.AnimationState.None;
                    this.startTouchPos  = primaryTouchEvent.LocalPosition;
                    this.isPress        = true;
                    break;

                case TouchEventType.Move:
                    if (this.isPress)
                    {
                        Vector2 realVec = this.startTouchPos - primaryTouchEvent.LocalPosition;
                        if (Math.Abs(this.GetVirtualVec(realVec)) > this.minDelayDragDist)
                        {
                            this.animationState = InternalSpinBox.SpinList.AnimationState.Drag;
                        }
                    }
                    break;
                }
                if (this.animationState != InternalSpinBox.SpinList.AnimationState.Drag && this.animationState != InternalSpinBox.SpinList.AnimationState.Flick)
                {
                    touchEvents.Forward = true;
                }
            }
示例#10
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            if (!this.Enabled)
            {
                return;
            }
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.state == Slider.SliderState.Pressed)
                {
                    this.state = Slider.SliderState.Normal;
                    this.UpdateView();
                    if (this.ValueChangeEventEnabled && this.ValueChanged != null)
                    {
                        this.ValueChanged.Invoke(this, new SliderValueChangeEventArgs(this.Value));
                    }
                }
                break;

            case TouchEventType.Down:
                this.handleClickPos.X = this.handleImage.X - primaryTouchEvent.LocalPosition.X;
                this.handleClickPos.Y = this.handleImage.Y - primaryTouchEvent.LocalPosition.Y;
                this.state            = Slider.SliderState.Pressed;
                this.UpdateView();
                return;

            case TouchEventType.Move:
                if (this.state == Slider.SliderState.Pressed)
                {
                    this.UpdateHandlePos(primaryTouchEvent.LocalPosition);
                    if (this.ValueChangeEventEnabled && this.ValueChanging != null)
                    {
                        this.ValueChanging.Invoke(this, new SliderValueChangeEventArgs(this.Value));
                        return;
                    }
                }
                break;

            default:
                return;
            }
        }
示例#11
0
 protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
 {
     base.OnTouchEvent(touchEvents);
     if (touchEvents.PrimaryTouchEvent.Type == TouchEventType.Up && !this.animation)
     {
         if (this.ScrollBarVisibility == ScrollBarVisibility.ScrollingVisible)
         {
             this.scrollBarH.Visible = false;
             this.scrollBarV.Visible = false;
         }
         this.animationState = ScrollPanel.AnimationState.None;
     }
     if (this.animationState != ScrollPanel.AnimationState.Drag && this.animationState != ScrollPanel.AnimationState.Flick)
     {
         touchEvents.Forward = true;
     }
 }
示例#12
0
            protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
            {
                base.OnTouchEvent(touchEvents);
                switch (touchEvents.PrimaryTouchEvent.Type)
                {
                case TouchEventType.Up:
                    if (this.isDown)
                    {
                        this.FireSelect();
                        this.isDown = false;
                    }
                    return;

                case TouchEventType.Down:
                    this.isDown = true;
                    return;

                default:
                    return;
                }
            }
示例#13
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (primaryTouchEvent.Type == TouchEventType.Down)
            {
                this.animation         = false;
                this.startPos          = this.panelContainer.X;
                this.touchDownLocalPos = primaryTouchEvent.LocalPosition.X;
                this.state             = PagePanel.AnimationState.None;
            }
            if (primaryTouchEvent.Type == TouchEventType.Up && this.state != PagePanel.AnimationState.Flick)
            {
                this.ScrollTo(this.pageIndex, true);
            }
            if (this.state != PagePanel.AnimationState.Drag && this.state != PagePanel.AnimationState.Flick)
            {
                touchEvents.Forward = true;
            }
        }
示例#14
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            if (this.State == Button.ButtonState.Disabled)
            {
                return;
            }
            switch (touchEvents.PrimaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.State == Button.ButtonState.Pressed && this.ButtonAction != null)
                {
                    this.ButtonAction.Invoke(this, new TouchEventArgs(touchEvents));
                }
                if (this.Enabled)
                {
                    this.State = Button.ButtonState.Normal;
                    return;
                }
                break;

            case TouchEventType.Down:
                this.State = Button.ButtonState.Pressed;
                return;

            case TouchEventType.Move:
                break;

            case TouchEventType.Enter:
                this.State = Button.ButtonState.Pressed;
                return;

            case TouchEventType.Leave:
                this.State = Button.ButtonState.Normal;
                break;

            default:
                return;
            }
        }
示例#15
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (primaryTouchEvent.Type == TouchEventType.Down)
            {
                this.animation = false;
            }
            else if (primaryTouchEvent.Type == TouchEventType.Up)
            {
                if (this.animationState == LiveFlipPanel.AnimationState.Drag)
                {
                    this.totalTime    = 0f;
                    this.endAngle     = (float)Math.Round((double)(this.angle / 3.14159274f)) * 3.14159274f;
                    this.flipEndAngle = this.angle;
                    if (this.isUseSprite)
                    {
                        this.setupSprite();
                    }
                    this.isStopAnimate = true;
                    this.animation     = true;
                }
                else if (this.animationState == LiveFlipPanel.AnimationState.Flip)
                {
                    this.animation = true;
                    this.Stop(true);
                }
                else if (this.animationState == LiveFlipPanel.AnimationState.FlickFlip)
                {
                    this.animationState = LiveFlipPanel.AnimationState.Flip;
                }
            }
            if (this.animationState != LiveFlipPanel.AnimationState.None)
            {
                touchEvents.Forward = true;
            }
        }
示例#16
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (this.state != PopupList.ButtonState.Disabled)
            {
                switch (primaryTouchEvent.Type)
                {
                case TouchEventType.Up:
                    if (this.state == PopupList.ButtonState.Pressed)
                    {
                        this.ShowDialog();
                        return;
                    }
                    this.updateState(PopupList.ButtonState.Normal);
                    return;

                case TouchEventType.Down:
                    this.updateState(PopupList.ButtonState.Pressed);
                    return;

                case TouchEventType.Move:
                    break;

                case TouchEventType.Enter:
                    this.updateState(PopupList.ButtonState.Pressed);
                    return;

                case TouchEventType.Leave:
                    this.updateState(PopupList.ButtonState.Normal);
                    break;

                default:
                    return;
                }
            }
        }
示例#17
0
 private void SendTouchEventToGestureDetectors(TouchEventCollection touchEvents)
 {
     using (List <GestureDetector> .Enumerator enumerator = this.GestureDetectors.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             GestureDetector current = enumerator.Current;
             bool            flag    = false;
             foreach (TouchEvent touchEvent in touchEvents)
             {
                 flag |= (touchEvent.Type == TouchEventType.Down);
             }
             if (flag || current.State != GestureDetectorResponse.None)
             {
                 current.State = current.OnTouchEvent(touchEvents);
                 if (current.State == GestureDetectorResponse.None)
                 {
                     current.State = GestureDetectorResponse.FailedAndStop;
                 }
             }
         }
     }
 }
示例#18
0
        protected internal override GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents)
        {
            GestureDetectorResponse result = base.State;
            TouchEvent primaryTouchEvent   = touchEvents.PrimaryTouchEvent;

            if (base.State != GestureDetectorResponse.None && this.downID != primaryTouchEvent.FingerID)
            {
                return(result);
            }
            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.DragEndDetected != null)
                {
                    DragEventArgs dragEventArgs = new DragEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition, primaryTouchEvent.WorldPosition - this.previousWorldPosition);
                    this.DragEndDetected.Invoke(this, dragEventArgs);
                }
                this.previousWorldPosition = primaryTouchEvent.WorldPosition;
                result = GestureDetectorResponse.FailedAndStop;
                break;

            case TouchEventType.Down:
                this.downID = primaryTouchEvent.FingerID;
                this.previousWorldPosition = primaryTouchEvent.WorldPosition;
                result = GestureDetectorResponse.UndetectedAndContinue;
                break;

            case TouchEventType.Move:
                if (base.State == GestureDetectorResponse.UndetectedAndContinue)
                {
                    Vector2 worldPosition = primaryTouchEvent.WorldPosition;
                    float   num           = this.previousWorldPosition.Distance(worldPosition);
                    if (num >= this.MaxDistance)
                    {
                        DragEventArgs dragEventArgs2 = new DragEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition, primaryTouchEvent.WorldPosition - this.previousWorldPosition);
                        this.previousWorldPosition = primaryTouchEvent.WorldPosition;
                        if (this.DragStartDetected != null)
                        {
                            this.DragStartDetected.Invoke(this, dragEventArgs2);
                        }
                        if (this.DragDetected != null)
                        {
                            this.DragDetected.Invoke(this, dragEventArgs2);
                        }
                        result = GestureDetectorResponse.DetectedAndContinue;
                    }
                }
                else
                {
                    if (this.DragDetected != null)
                    {
                        DragEventArgs dragEventArgs3 = new DragEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition, primaryTouchEvent.WorldPosition - this.previousWorldPosition);
                        this.DragDetected.Invoke(this, dragEventArgs3);
                    }
                    this.previousWorldPosition = primaryTouchEvent.WorldPosition;
                    result = GestureDetectorResponse.DetectedAndContinue;
                }
                break;
            }
            return(result);
        }
示例#19
0
 protected internal abstract GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents);
示例#20
0
 public TouchEventArgs(TouchEventCollection touchEvents)
 {
     this.TouchEvents = touchEvents;
 }
示例#21
0
        protected internal override GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents)
        {
            GestureDetectorResponse result = base.State;
            TouchEventCollection    touchEventCollection = new TouchEventCollection();

            foreach (TouchEvent touchEvent in touchEvents)
            {
                if (touchEvent.Type != TouchEventType.Enter && touchEvent.Type != TouchEventType.Leave && touchEvent.Type != TouchEventType.None)
                {
                    touchEventCollection.Add(touchEvent);
                }
            }
            if (touchEventCollection.Count >= 2)
            {
                bool      flag   = false;
                Vector2[] array  = new Vector2[2];
                Vector2[] array2 = new Vector2[2];
                for (int i = 0; i < 2; i++)
                {
                    TouchEvent touchEvent2 = touchEventCollection[i];
                    array[i]  = touchEvent2.LocalPosition;
                    array2[i] = touchEvent2.WorldPosition;
                    if (touchEvent2.Type == TouchEventType.Up)
                    {
                        flag = true;
                    }
                }
                float num = array[0].Distance(array[1]);
                if (this.firstDistance < 0f)
                {
                    this.firstDistance    = num;
                    this.firstTouchVector = array[1] - array[0];
                }
                if (base.State == GestureDetectorResponse.UndetectedAndContinue || base.State == GestureDetectorResponse.None)
                {
                    if (FMath.Abs(num - this.firstDistance) > this.MinPinchDistance)
                    {
                        Vector2 localCenter = (array[0] + array[1]) / 2f;
                        Vector2 worldCenter = (array2[0] + array2[1]) / 2f;
                        if (this.PinchStartDetected != null)
                        {
                            this.PinchStartDetected.Invoke(this, new PinchEventArgs(base.TargetWidget, num, 1f, 0f, worldCenter, localCenter));
                        }
                        result = GestureDetectorResponse.DetectedAndContinue;
                    }
                    else
                    {
                        result = GestureDetectorResponse.UndetectedAndContinue;
                    }
                }
                else if (base.State == GestureDetectorResponse.DetectedAndContinue)
                {
                    Vector2 vector       = array[1] - array[0];
                    float   scale        = num / this.firstDistance;
                    float   angle        = this.firstTouchVector.Angle(vector);
                    Vector2 localCenter2 = (array[0] + array[1]) / 2f;
                    Vector2 worldCenter2 = (array2[0] + array2[1]) / 2f;
                    if (flag)
                    {
                        if (this.PinchEndDetected != null)
                        {
                            this.PinchEndDetected.Invoke(this, new PinchEventArgs(base.TargetWidget, num, scale, angle, worldCenter2, localCenter2));
                        }
                        result                = GestureDetectorResponse.DetectedAndStop;
                        this.firstDistance    = -1f;
                        this.firstTouchVector = Vector2.Zero;
                    }
                    else
                    {
                        if (this.PinchDetected != null)
                        {
                            this.PinchDetected.Invoke(this, new PinchEventArgs(base.TargetWidget, num, scale, angle, worldCenter2, localCenter2));
                        }
                        result = GestureDetectorResponse.DetectedAndContinue;
                    }
                }
            }
            else if (base.State == GestureDetectorResponse.DetectedAndContinue)
            {
                result = GestureDetectorResponse.FailedAndStop;
            }
            else
            {
                result = GestureDetectorResponse.UndetectedAndContinue;
            }
            return(result);
        }
示例#22
0
        protected internal override GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents)
        {
            GestureDetectorResponse result = base.State;
            TouchEvent primaryTouchEvent   = touchEvents.PrimaryTouchEvent;

            if (base.State != GestureDetectorResponse.None && this.downID != primaryTouchEvent.FingerID)
            {
                return(result);
            }
            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
            {
                Vector2 vector = primaryTouchEvent.WorldPosition - this.previousWorldPosition[1];
                float   num    = (float)(primaryTouchEvent.Time - this.previousTime[1]).TotalMilliseconds;
                Vector2 zero   = Vector2.Zero;
                if (this.Direction != FlickDirection.Virtical)
                {
                    zero.X = vector.X / num * 1000f;
                    if (zero.X < -this.MaxSpeed)
                    {
                        zero.X = -this.MaxSpeed;
                    }
                    else if (zero.X > this.MaxSpeed)
                    {
                        zero.X = this.MaxSpeed;
                    }
                    else if (Math.Abs(zero.X) < this.MinSpeed)
                    {
                        zero.X = 0f;
                    }
                }
                if (this.Direction != FlickDirection.Horizontal)
                {
                    zero.Y = vector.Y / num * 1000f;
                    if (zero.Y < -this.MaxSpeed)
                    {
                        zero.Y = -this.MaxSpeed;
                    }
                    else if (this.MaxSpeed < zero.Y)
                    {
                        zero.Y = this.MaxSpeed;
                    }
                    else if (Math.Abs(zero.Y) < this.MinSpeed)
                    {
                        zero.Y = 0f;
                    }
                }
                if (zero.X != 0f || zero.Y != 0f)
                {
                    if (this.FlickDetected != null)
                    {
                        FlickEventArgs flickEventArgs = new FlickEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition, zero);
                        this.FlickDetected.Invoke(this, flickEventArgs);
                    }
                    result = GestureDetectorResponse.DetectedAndStop;
                }
                else
                {
                    result = GestureDetectorResponse.FailedAndStop;
                }
                break;
            }

            case TouchEventType.Down:
                this.downID = primaryTouchEvent.FingerID;
                for (int i = 0; i < 2; i++)
                {
                    this.previousWorldPosition[i] = primaryTouchEvent.WorldPosition;
                    this.previousTime[i]          = primaryTouchEvent.Time;
                }
                result = GestureDetectorResponse.UndetectedAndContinue;
                break;

            case TouchEventType.Move:
                if ((primaryTouchEvent.Time - this.previousTime[0]).TotalMilliseconds > (double)this.pollingMilliseconds)
                {
                    this.previousWorldPosition[1] = this.previousWorldPosition[0];
                    this.previousTime[1]          = this.previousTime[0];
                    this.previousWorldPosition[0] = primaryTouchEvent.WorldPosition;
                    this.previousTime[0]          = primaryTouchEvent.Time;
                    result = GestureDetectorResponse.UndetectedAndContinue;
                }
                break;
            }
            return(result);
        }
示例#23
0
 protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
 {
     base.OnTouchEvent(touchEvents);
     touchEvents.Forward = true;
 }
示例#24
0
        protected internal override void OnTouchEvent(TouchEventCollection touchEvents)
        {
            base.OnTouchEvent(touchEvents);
            TouchEvent primaryTouchEvent = touchEvents.PrimaryTouchEvent;

            if (primaryTouchEvent.Type == TouchEventType.Down)
            {
                this.animation = false;
                Matrix4 transform3D = this.spherePrim.Transform3D;
                transform3D.M43             = this.radius * 0.2f;
                this.spherePrim.Transform3D = transform3D;
                return;
            }
            if (primaryTouchEvent.Type == TouchEventType.Enter)
            {
                Matrix4 transform3D2 = this.spherePrim.Transform3D;
                transform3D2.M43            = this.radius * 0.2f;
                this.spherePrim.Transform3D = transform3D2;
                return;
            }
            if (primaryTouchEvent.Type == TouchEventType.Leave)
            {
                Matrix4 transform3D3 = this.spherePrim.Transform3D;
                transform3D3.M43            = 0f;
                this.spherePrim.Transform3D = transform3D3;
                return;
            }
            if (primaryTouchEvent.Type == TouchEventType.Up)
            {
                Matrix4 transform3D4 = this.spherePrim.Transform3D;
                transform3D4.M43            = 0f;
                this.spherePrim.Transform3D = transform3D4;
                if (this.animationState == LiveSphere.AnimationState.None && !this.animation)
                {
                    if (this.ButtonAction != null)
                    {
                        this.ButtonAction.Invoke(this, new TouchEventArgs(touchEvents));
                        return;
                    }
                }
                else
                {
                    if (this.animationState == LiveSphere.AnimationState.Drag)
                    {
                        this.totalTime     = 0f;
                        this.endAngle      = (float)Math.Round((double)(this.yAxis / 3.14159274f)) * 3.14159274f;
                        this.flipEndAngle  = this.yAxis;
                        this.isStopAnimate = true;
                        this.animation     = true;
                        return;
                    }
                    if (this.animationState == LiveSphere.AnimationState.Flip)
                    {
                        this.animation = true;
                        this.Stop(true);
                        return;
                    }
                    if (this.animationState == LiveSphere.AnimationState.FlickFlip)
                    {
                        this.animationState = LiveSphere.AnimationState.Flip;
                    }
                }
            }
        }
        protected internal override GestureDetectorResponse OnTouchEvent(TouchEventCollection touchEvents)
        {
            GestureDetectorResponse result = base.State;
            TouchEvent primaryTouchEvent   = touchEvents.PrimaryTouchEvent;

            if (base.State != GestureDetectorResponse.None && this.firstDownID != primaryTouchEvent.FingerID)
            {
                return(result);
            }
            Vector2 worldPosition = primaryTouchEvent.WorldPosition;
            float   num           = this.firstDownPos.Distance(worldPosition);
            float   num2          = (float)(primaryTouchEvent.Time - this.previousTime).TotalMilliseconds;

            switch (primaryTouchEvent.Type)
            {
            case TouchEventType.Up:
                if (this.downCount == 2)
                {
                    if (num <= this.MaxDistance && num2 <= this.MaxPressDuration)
                    {
                        if (this.DoubleTapDetected != null)
                        {
                            DoubleTapEventArgs doubleTapEventArgs = new DoubleTapEventArgs(base.TargetWidget, primaryTouchEvent.WorldPosition, primaryTouchEvent.LocalPosition);
                            this.DoubleTapDetected.Invoke(this, doubleTapEventArgs);
                        }
                        result = GestureDetectorResponse.DetectedAndStop;
                    }
                    else
                    {
                        result = GestureDetectorResponse.FailedAndStop;
                    }
                }
                else if (num <= this.MaxDistance && num2 <= this.MaxPressDuration)
                {
                    this.previousTime = primaryTouchEvent.Time;
                    result            = GestureDetectorResponse.UndetectedAndContinue;
                }
                else
                {
                    result = GestureDetectorResponse.FailedAndStop;
                }
                break;

            case TouchEventType.Down:
                if (this.downCount > 0)
                {
                    if (num <= this.MaxDistance && num2 <= this.MaxNextPressDuration)
                    {
                        this.downCount++;
                        this.previousTime = primaryTouchEvent.Time;
                    }
                    else
                    {
                        this.OnResetState();
                    }
                }
                if (this.downCount == 0)
                {
                    this.downCount++;
                    this.firstDownID  = primaryTouchEvent.FingerID;
                    this.firstDownPos = primaryTouchEvent.WorldPosition;
                    this.previousTime = primaryTouchEvent.Time;
                }
                result = GestureDetectorResponse.UndetectedAndContinue;
                break;
            }
            return(result);
        }