Ejemplo n.º 1
0
        void SetAnimationStyle(QuickActionAnimationStyle animationStyle, int screenWidth, int requestedX, bool onTop)
        {
            var arrowPos = requestedX - _arrowUp.MeasuredWidth / 2;

            switch (animationStyle)
            {
            case QuickActionAnimationStyle.GrowLeft:
                _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Left : Resource.Style.Animations_PopDownMenu_Left;
                break;

            case QuickActionAnimationStyle.GrowRight:
                _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Right : Resource.Style.Animations_PopDownMenu_Right;
                break;

            case QuickActionAnimationStyle.GrowFromCenter:
                _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Center : Resource.Style.Animations_PopDownMenu_Center;
                break;

            case QuickActionAnimationStyle.Reflect:
                _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Reflect : Resource.Style.Animations_PopDownMenu_Reflect;
                break;

            case QuickActionAnimationStyle.Auto:
                if (arrowPos <= screenWidth / 4)
                {
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Left : Resource.Style.Animations_PopDownMenu_Left;
                }
                else if (arrowPos > screenWidth / 4 && arrowPos < 3 * (screenWidth / 4))
                {
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Center : Resource.Style.Animations_PopDownMenu_Center;
                }
                else
                {
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Right : Resource.Style.Animations_PopDownMenu_Right;
                }
                break;
            }
        }
Ejemplo n.º 2
0
        void SetAnimationStyle(QuickActionAnimationStyle animationStyle, int screenWidth, int requestedX, bool onTop)
        {
            var arrowPos = requestedX - _arrowUp.MeasuredWidth / 2;

            switch (animationStyle)
            {
                case QuickActionAnimationStyle.GrowLeft:
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Left : Resource.Style.Animations_PopDownMenu_Left;
                    break;

                case QuickActionAnimationStyle.GrowRight:
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Right : Resource.Style.Animations_PopDownMenu_Right;
                    break;

                case QuickActionAnimationStyle.GrowFromCenter:
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Center : Resource.Style.Animations_PopDownMenu_Center;
                    break;

                case QuickActionAnimationStyle.Reflect:
                    _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Reflect : Resource.Style.Animations_PopDownMenu_Reflect;
                    break;

                case QuickActionAnimationStyle.Auto:
                    if (arrowPos <= screenWidth / 4)
                    {
                        _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Left : Resource.Style.Animations_PopDownMenu_Left;
                    }
                    else if (arrowPos > screenWidth / 4 && arrowPos < 3 * (screenWidth / 4))
                    {
                        _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Center : Resource.Style.Animations_PopDownMenu_Center;
                    }
                    else
                    {
                        _window.AnimationStyle = onTop ? Resource.Style.Animations_PopUpMenu_Right : Resource.Style.Animations_PopDownMenu_Right;
                    }
                    break;
            }
        }
Ejemplo n.º 3
0
        public void Show(View anchor, QuickActionAnimationStyle animationStyle = QuickActionAnimationStyle.Auto)
        {
            PreShow();
            var windowLocation = new Point();
            int arrowPos;

            _didAction = false;

            var anchorRect = GetAnchorRectangle(anchor);

            _rootView.Measure(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            var rootHeight = _rootView.MeasuredHeight;

            if (_rootWidth == 0)
            {
                _rootWidth = _rootView.MeasuredWidth;
            }

            var screenWidth  = _windowManager.DefaultDisplay.Width;
            var screenHeight = _windowManager.DefaultDisplay.Height;

            // Get x coord of top left popup
            if ((anchorRect.Left + _rootWidth) > screenWidth)
            {
                windowLocation.X = anchorRect.Left - (_rootWidth - anchor.Width);
                windowLocation.X = (windowLocation.X < 0) ? 0 : windowLocation.X;
                arrowPos         = anchorRect.CenterX() - windowLocation.X;
            }
            else
            {
                if (anchor.Width > _rootWidth)
                {
                    windowLocation.X = anchorRect.CenterX() - (_rootWidth / 2);
                }
                else
                {
                    windowLocation.X = anchorRect.Left;
                }
                arrowPos = anchorRect.CenterX() - windowLocation.X;
            }

            var dyTop    = anchorRect.Top;
            var dyBottom = screenHeight - anchorRect.Bottom;

            var onTop = (dyTop > dyBottom);

            if (onTop)
            {
                if (rootHeight > dyTop)
                {
                    windowLocation.Y = 15;
                }
                else
                {
                    windowLocation.Y = anchorRect.Top - rootHeight;
                }
            }
            else
            {
                windowLocation.Y = anchorRect.Bottom;
            }

            ShowArrow(onTop ? Resource.Id.arrow_down : Resource.Id.arrow_up, arrowPos);
            SetAnimationStyle(animationStyle, screenWidth, anchorRect.CenterX(), onTop);

            _window.ShowAtLocation(anchor, GravityFlags.NoGravity, windowLocation.X, windowLocation.Y);
        }
Ejemplo n.º 4
0
        public void Show(View anchor, QuickActionAnimationStyle animationStyle = QuickActionAnimationStyle.Auto)
        {
            PreShow();
            var windowLocation = new Point();
            int arrowPos;
            _didAction = false;

            var anchorRect = GetAnchorRectangle(anchor);
            _rootView.Measure(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            var rootHeight = _rootView.MeasuredHeight;
            if (_rootWidth == 0)
            {
                _rootWidth = _rootView.MeasuredWidth;
            }

            var screenWidth = _windowManager.DefaultDisplay.Width;
            var screenHeight = _windowManager.DefaultDisplay.Height;

            // Get x coord of top left popup
            if ((anchorRect.Left + _rootWidth) > screenWidth)
            {
                windowLocation.X = anchorRect.Left - (_rootWidth - anchor.Width);
                windowLocation.X = (windowLocation.X < 0) ? 0 : windowLocation.X;
                arrowPos = anchorRect.CenterX() - windowLocation.X;
            }
            else
            {
                if (anchor.Width > _rootWidth)
                {
                    windowLocation.X = anchorRect.CenterX() - (_rootWidth / 2);
                }
                else
                {
                    windowLocation.X = anchorRect.Left;
                }
                arrowPos = anchorRect.CenterX() - windowLocation.X;
            }

            var dyTop = anchorRect.Top;
            var dyBottom = screenHeight - anchorRect.Bottom;

            var onTop = (dyTop > dyBottom);

            if (onTop)
            {
                if (rootHeight > dyTop)
                {
                    windowLocation.Y = 15;
                }
                else
                {
                    windowLocation.Y = anchorRect.Top - rootHeight;
                }
            }
            else
            {
                windowLocation.Y = anchorRect.Bottom;
            }

            ShowArrow(onTop ? Resource.Id.arrow_down : Resource.Id.arrow_up, arrowPos);
            SetAnimationStyle(animationStyle, screenWidth, anchorRect.CenterX(), onTop);

            _window.ShowAtLocation(anchor, GravityFlags.NoGravity, windowLocation.X, windowLocation.Y);
        }