Example #1
0
        private bool OnChangeJupiterColor(object source, View.TouchEventArgs e)
        {
            PointStateType GetState = e.Touch.GetState(0);
            Vector2        item     = e.Touch.GetLocalPosition(0);

            if (scroll.ScrollEnabled && item.Y > 30)
            {
                if (GetState == PointStateType.Down)
                {
                    viewBgClicked[3]             = !viewBgClicked[3];
                    viewItems[3].BackgroundImage = VIEW_BG_CLICKED_PATH;
                    if (viewBgClicked[3])
                    {
                        // Set Jupiter Fill Color
                        rav.SetShapeFillColor("JupiterColor", new Color(245.0f / 255.0f, 117.0f / 255.0f, 220.0f / 255.0f, 1.0f));
                    }
                    else
                    {
                        // Set Jupiter Fill Color
                        rav.SetShapeFillColor("JupiterColor", new Color(232.0f / 255.0f, 130.0f / 255.0f, 101.0f / 255.0f, 1.0f));
                    }
                }
                if (GetState == PointStateType.Up)
                {
                    viewItems[3].BackgroundImage = VIEW_BG_PATH[3];
                }
            }
            return(false);
        }
Example #2
0
        private bool OnViewTouchEvent2(object source, TouchEventArgs e)
        {
            PointStateType type   = e.Touch.GetState(0);
            Vector2        vector = e.Touch.GetScreenPosition(0);

            switch (type)
            {
            case PointStateType.Down:
                downPosition = movePosition = new Position(vector);
                PlayScaleDownAnimation(mainView);
                PlayScaleDownAnimation(source as View);
                break;

            case PointStateType.Motion:
                var currentPosition = new Position(vector);
                MoveMainScreen(new Position(mainViewModel.MainPosition) + (currentPosition - movePosition));
                movePosition = currentPosition;
                break;

            case PointStateType.Up:
                if (isTouchArea(AbsPosition(new Position(vector) - downPosition)))
                {
                    LaunchApplication(TARGET_APPLICATION);
                }

                PlayScaleUpAnimation(mainView);
                PlayScaleUpAnimation(source as View);
                break;
            }
            return(false);
        }
Example #3
0
        protected override bool HandleControlStateOnTouch(Touch touch)
        {
            if ((IsEnabled == false) || (touch == null))
            {
                return(false);
            }

            PointStateType state = touch.GetState(0);

            switch (state)
            {
            case PointStateType.Up:
                if (IsSelected == true)
                {
                    selectedAgain = true;
                }
                break;

            default:
                break;
            }

            bool ret = base.HandleControlStateOnTouch(touch);

            if (selectedAgain == true)
            {
                IsSelected    = true;
                selectedAgain = false;
            }

            return(ret);
        }
Example #4
0
 private bool Popup_TouchEvent(object source, TouchEventArgs e)
 {
     if (previousState == PointStateType.Down && e.Touch.GetState(0) == PointStateType.Finished)
     {
         OutsideClicked?.Invoke(this, null);
     }
     previousState = e.Touch.GetState(0);
     return(true);
 }
Example #5
0
        /// <summary>
        /// Retrieves the state of the point specified.<br />
        /// If a point is greater than GetPointCount(), then this method will return PointState.Finished.<br />
        /// </summary>
        /// <param name="point">The point required.</param>
        /// <returns>The state of the point specified.</returns>
        /// <since_tizen> 3 </since_tizen>
        public PointStateType GetState(uint point)
        {
            PointStateType ret = (PointStateType)Interop.Touch.GetState(swigCPtr, point);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #6
0
        private void OnTouchEvent(object source, Window.TouchEventArgs e)
        {
            PointStateType state = e.Touch.GetState(0);

            if (state == PointStateType.Down)
            {
                SetContentInfo("count:" + mCount);
                mCount++;
            }
        }
Example #7
0
        public void TouchGetState()
        {
            tlog.Debug(tag, $"TouchGetState START");
            Touch          a1 = new Touch();
            PointStateType b1 = a1.GetState(1);

            a1.Dispose();

            tlog.Debug(tag, $"TouchGetState END (OK)");
            Assert.Pass("TouchGetDeviceId");
        }
Example #8
0
        protected override bool HandleControlStateOnTouch(Touch touch)
        {
            if (!IsEnabled || null == touch)
            {
                return(false);
            }

            PointStateType state = touch.GetState(0);

            switch (state)
            {
            case PointStateType.Down:
                isPressed = true;
                Extension?.SetTouchInfo(touch);
                UpdateState();
                return(true);

            case PointStateType.Interrupted:
                isPressed = false;
                UpdateState();
                return(true);

            case PointStateType.Up:
            {
                if (!isPressed)
                {
                    return(false);
                }

                isPressed = false;

                if (IsSelectable)
                {
                    Extension?.SetTouchInfo(touch);
                    IsSelected = !IsSelected;
                }
                else
                {
                    Extension?.SetTouchInfo(touch);
                    UpdateState();
                }

                ClickedEventArgs eventArgs = new ClickedEventArgs();
                OnClickedInternal(eventArgs, touch);

                return(true);
            }

            default:
                break;
            }
            return(base.HandleControlStateOnTouch(touch));
        }
Example #9
0
        private bool OnTouchEventForThumb(object source, TouchEventArgs e)
        {
            PointStateType state = e.Touch.GetState(0);

            if (state == PointStateType.Down)
            {
                UpdateState(isFocused, true);
            }
            else if (state == PointStateType.Up)
            {
                UpdateState(isFocused, false);
            }
            return(true);
        }
Example #10
0
 private bool OnViewTouched(object sender, View.TouchEventArgs e)
 {
     if (e.Touch.GetState(0) == PointStateType.Down)
     {
         PointStateType state = e.Touch.GetState(0);
         if (state == PointStateType.Down)
         {
             Bundle bundle        = new Bundle();
             String encodedBundle = bundle.Encode();
             SetContentInfo(encodedBundle);
             mCount++;
         }
     }
     return(true);
 }
Example #11
0
        private bool ItemTouchEvent(object source, TouchEventArgs e)
        {
            TabItem item = source as TabItem;

            if (item == null)
            {
                return(false);
            }
            PointStateType state = e.Touch.GetState(0);

            if (state == PointStateType.Up)
            {
                UpdateSelectedItem(item);
            }

            return(true);
        }
Example #12
0
        private bool DoTilePress(View actor, PointStateType pointState)
        {
            bool consumed = false;

            if (PointStateType.Down == pointState)
            {
                mPressedActor = actor;
                consumed      = true;
            }

            // A button press is only valid if the Down & Up events
            // both occurred within the button.
            if ((PointStateType.Up == pointState) &&
                (mPressedActor == actor))
            {
                // ignore Example button presses when scrolling or button animating.
                if ((!mScrolling) && (!mPressedAnimation))
                {
                    string name = actor.Name;
                    foreach (Example example in mExampleList)
                    {
                        if (example.Name == name)
                        {
                            consumed = true;
                            break;
                        }
                    }
                }

                if (consumed)
                {
                    mPressedAnimation           = new Animation((int)(BUTTON_PRESS_ANIMATION_TIME * 1000.0));
                    mPressedAnimation.EndAction = Animation.EndActions.Discard;

                    // scale the content actor within the Tile, as to not affect the placement within the Table.
                    View content = actor.GetChildAt(0);
                    mPressedAnimation.AnimateTo(content, "Scale", new Vector3(0.7f, 0.7f, 1.0f), 0, (int)((BUTTON_PRESS_ANIMATION_TIME * 0.5f) * 1000.0), new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut));
                    mPressedAnimation.AnimateTo(content, "Scale", Vector3.One, (int)((BUTTON_PRESS_ANIMATION_TIME * 0.5f) * 1000.0), (int)((BUTTON_PRESS_ANIMATION_TIME * 0.5f) * 1000.0), new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut));
                    mPressedAnimation.AnimateTo(content, "Orientation", new Rotation(new Radian(new Degree(180)), new Vector3(0, 1, 0)));
                    mPressedAnimation.Play();
                    mPressedAnimation.Finished += OnPressedAnimationFinished;
                }
            }
            return(consumed);
        }
Example #13
0
        private bool OnTouchEventForBgTrack(object source, TouchEventArgs e)
        {
            PointStateType state = e.Touch.GetState(0);

            if (state == PointStateType.Down)
            {
                Vector2 pos = e.Touch.GetLocalPosition(0);
                CalculateCurrentValueByTouch(pos);
                UpdateValue();
                if (null != slidingFinishedHandler)
                {
                    SlidingFinishedArgs args = new SlidingFinishedArgs();
                    args.CurrentValue = curValue;
                    slidingFinishedHandler(this, args);
                }
            }
            return(false);
        }
Example #14
0
        public override bool OnTouch(Touch touch)
        {
            if (IsEnabled == false)
            {
                return(false);
            }
            PointStateType state = touch.GetState(0);
            bool           ret   = base.OnTouch(touch);

            switch (state)
            {
            case PointStateType.Up:
                OnSelect();
                break;

            default:
                break;
            }
            return(ret);
        }
Example #15
0
        public override bool OnTouch(Touch touch)
        {
            // Handle Normal and Pressed states
            PointStateType state = touch.GetState(0);

            switch (state)
            {
            case PointStateType.Down:
                ControlState = ControlStates.Pressed;
                return(true);

            case PointStateType.Interrupted:
            case PointStateType.Up:
                if (ControlState == ControlStates.Pressed)
                {
                    ControlState = ControlStates.Normal;
                }
                return(true);

            default:
                break;
            }
            return(false);
        }
Example #16
0
        private void OnRiveWindowTouchEvent(object source, Window.TouchEventArgs e)
        {
            Vector2        sp        = e.Touch.GetScreenPosition(0);
            PointStateType state     = e.Touch.GetState(0);
            Position       screenPos = new Position(sp.X, sp.Y);

            if (!scroll.ScrollEnabled)
            {
                if (state == PointStateType.Down)
                {
                    startPos  = screenPos;
                    scrollPos = scroll.Position;
                }
                Position diff = screenPos - startPos;
                scroll.PositionX = 0.0f;
                float minmaxY = scrollPos.Y + diff.Y;

                if (minmaxY > 520)
                {
                    scroll.PositionY = 520;
                }
                else if (minmaxY <= 120)
                {
                    scroll.PositionY = 120;
                }
                else
                {
                    scroll.PositionY = minmaxY;
                }

                float time = (scroll.PositionY - 120) / 400;

                // Set RiveAnimation Elapsed Time using View Position
                rav.SetAnimationElapsedTime("Pull", time);

                if (time < 1.0)
                {
                    isMoving = true;
                    // Disable RiveAnimations
                    rav.EnableAnimation("Trigger", false);
                    rav.EnableAnimation("Loading", false);
                }
                else if (time >= 1.0 && isMoving)
                {
                    isMoving = false;
                    // Enable RiveAnimations
                    rav.EnableAnimation("Trigger", true);
                    rav.EnableAnimation("Loading", true);
                    scroll.ScrollEnabled = true;
                    scroll.Size          = new Size(720, 760);
                }
            }
            else
            {
                if (preScrollPositionY == 0)
                {
                    float diff = scroll.ScrollPosition.Y - preScrollPositionY;
                    if (diff > 5)
                    {
                        scroll.ScrollTo(0, false);
                        scroll.ScrollEnabled = false;
                        scroll.Size          = new Size(720, 1160);
                        for (int i = 0; i < 5; i++)
                        {
                            viewItems[i].BackgroundImage = VIEW_BG_PATH[i];
                        }
                    }
                }
                preScrollPositionY = scroll.ScrollPosition.Y;
            }
            ravCenterY    = (120.0f + scroll.Position.Y) / 2;
            rav.PositionX = 0.0f;
            rav.PositionY = ravCenterY - 248.0f;
        }
        protected override bool HandleControlStateOnTouch(Touch touch)
        {
            if (!IsEnabled || null == touch)
            {
                return(false);
            }

            PointStateType state = touch.GetState(0);

            switch (state)
            {
            case PointStateType.Down:
                IsPressed = true;
                UpdateState();
                return(true);

            case PointStateType.Interrupted:
                IsPressed = false;
                UpdateState();
                return(true);

            case PointStateType.Up:
            {
                bool clicked = IsPressed && IsEnabled;
                IsPressed = false;

                if (!clicked)
                {
                    return(true);
                }

                if (IsSelectable)
                {
                    if (ParentItemsView as CollectionView)
                    {
                        CollectionView colView = ParentItemsView as CollectionView;
                        switch (colView.SelectionMode)
                        {
                        case ItemSelectionMode.Single:
                            colView.SelectedItem = IsSelected ? null : BindingContext;
                            break;

                        case ItemSelectionMode.SingleAlways:
                            if (colView.SelectedItem != BindingContext)
                            {
                                colView.SelectedItem = BindingContext;
                            }
                            break;

                        case ItemSelectionMode.Multiple:
                            var selectedItems = colView.SelectedItems;
                            if (selectedItems.Contains(BindingContext))
                            {
                                selectedItems.Remove(BindingContext);
                            }
                            else
                            {
                                selectedItems.Add(BindingContext);
                            }
                            break;

                        case ItemSelectionMode.None:
                            break;
                        }
                    }
                }
                else
                {
                    // Extension : Extension?.SetTouchInfo(touch);
                    UpdateState();
                }

                if (clicked)
                {
                    ClickedEventArgs eventArgs = new ClickedEventArgs();
                    OnClickedInternal(eventArgs);
                }

                return(true);
            }

            default:
                break;
            }
            return(base.HandleControlStateOnTouch(touch));
        }
        private bool OnTouch(object source, View.TouchEventArgs e)
        {
            Vector2 position = e.Touch.GetScreenPosition(0);

            PointStateType state = e.Touch.GetState(0);

            if (PointStateType.Down == state)
            {
                if (animationState == TOUCH_ANIMATION_STATE.ON_FINISH_ANIMATION)
                {
                    // re-birth current animation
                    // in case of touch during finish animation,
                    // quit easingAnimation and AnimationOffTimer because animation ownership is returned to the touch event again.
                    // AND, DO NOT RESET ALL PROPERTIES OF FRAMECALLBACK.
                    // because, for example, if touched icon index is changed, the movement is wrong and the animation can be not continous.
                    // This re-birthed animation is just for smooth moving during complex user interaction.
                    // during complex and fast interaction, this is not so noticeable.
                    // and reset of such properties will be done in the below Motion state
                    finishAnimation.Stop();
                    animationOffTimer.Stop();

                    // Set Animation State to ON_ANIMATION again
                    animationState = TOUCH_ANIMATION_STATE.ON_ANIMATION;
                    // Set previousTouchPosition
                    previousTouchedPosition = position.X;
                }
                else
                {
                    // in case of stable state
                    // just set new framecallback for this touched position.
                    SetFrameUpdateCallback(position.X);
                }
            }
            else if (PointStateType.Motion == state)
            {
                // if framecallback can be reset, quit current frame callback and re-launch new frame callback.
                // because, if current frame callback is re-birthed one, the animation is not totally re-created one.
                // So, some properties like touched icon index can be wrong for the continuous animation.
                // But, some case like that finger is stopped and restart to move, this could make weired feeling.
                // We reset frameUpdateCallback as soon as possible we can. And the conditions are ...
                // 1. icons in screen is stopped.
                // 2. velocity of frame callback is 0.0 (this frame callback will not move again instantly)
                // 3. frame callback is not dirty (there is no reserved action)
                if (frameUpdateCallback.IsResetTouchedViewPossible() && frameUpdateCallback.GetVelocity() == 0.0f && !frameUpdateCallback.IsDirty())
                {
                    SetFrameUpdateCallback(position.X);
                }

                // Set new controlView(container) position
                // in here, we need to consider the container is not go outside of limits.
                float containerPosition = controlView.Position.X + (position.X - previousTouchedPosition);
                containerPosition = Math.Min(containerPosition, rightDirectionLimit);
                containerPosition = Math.Max(containerPosition, leftDirectionLimit);
                float adjustedPosition = containerPosition - controlView.Position.X + previousTouchedPosition;
                previousTouchedPosition = adjustedPosition;
                controlView.Position.X  = containerPosition;
            }
            else if ((PointStateType.Up == state || PointStateType.Leave == state || PointStateType.Interrupted == state) &&
                     animationState == TOUCH_ANIMATION_STATE.ON_ANIMATION)
            {
                animationState = TOUCH_ANIMATION_STATE.ON_FINISH_ANIMATION;

                // To launch finish animation, we get latest velocty from frame callback
                float lastVelocity = frameUpdateCallback.GetVelocity();

                /* TUNING */
                // This is just for turning of finish animation.
                // change the values if you want.
                lastVelocity = Math.Max(lastVelocity, -3.5f);
                lastVelocity = Math.Min(lastVelocity, 3.5f);
                if (Math.Abs(lastVelocity) < 0.0001f)
                {
                    // If velocity is zero. just start animationOfftimer.
                    animationOffTimer.Start();
                }
                else
                {
                    // If velocity is not zero, make decelerating animation.
                    Decelerating(lastVelocity);
                }
            }
            // set currently visible icons for optimization
            SetVisibleLimit();
            // make frame callback dirty.
            frameUpdateCallback.Dirty();
            return(true);
        }