Esempio n. 1
0
        void UpdateMenuWithNewSize()
        {
            var menu = _basePage.SlideMenu;

            if (menu != null)
            {
                if (menu.IsFullScreen)
                {
                    if (menu.MenuOrientations == MenuOrientation.BottomToTop ||
                        menu.MenuOrientations == MenuOrientation.TopToBottom)
                    {
                        menu.WidthRequest = ScreenSizeHelper.ScreenWidth;
                    }
                    if (menu.MenuOrientations == MenuOrientation.LeftToRight ||
                        menu.MenuOrientations == MenuOrientation.RightToLeft)
                    {
                        menu.HeightRequest = ScreenSizeHelper.ScreenHeight;
                    }
                }
                if (_dragGesture != null)
                {
                    _dragGesture.UpdateLayoutSize(menu);
                    _dragGesture.LayoutHideStatus();
                }
            }
        }
Esempio n. 2
0
        void OnSizeChanged(int w, int h, int oldw, int oldh)
        {
            if (_basePage == null)
            {
                return;
            }

            var metrics = _pageRenderer.Resources.DisplayMetrics;

            ScreenSizeHelper.ScreenWidth  = w / metrics.Density;
            ScreenSizeHelper.ScreenHeight = h / metrics.Density;

            var menu = _basePage.SlideMenu;

            if (menu != null)
            {
                if (_dragGesture != null)
                {
                    _dragGesture.UpdateLayoutSize(menu);

                    var rect = _dragGesture.GetHidePosition();
                    menu.Layout(new Xamarin.Forms.Rectangle(
                                    rect.left / metrics.Density,
                                    rect.top / metrics.Density,
                                    (rect.right - rect.left) / metrics.Density,
                                    (rect.bottom - rect.top) / metrics.Density));
                    if (_popMenuOverlayRenderer != null)
                    {
                        _popMenuOverlayRenderer.UpdateLayout();
                    }
                    _dragGesture.LayoutHideStatus();
                    return;
                }
            }

            if (!string.IsNullOrEmpty(_currentPopup))
            {
                LayoutPopup();
            }

            if (_backgroundOverlay != null)
            {
                _backgroundOverlay.Layout(
                    0,
                    0,
                    (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                    (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));
            }
        }
        void OnSizeChanged(int w, int h, int oldw, int oldh)
        {
            if (_basePage == null)
            {
                return;
            }

            var metrics = _pageRenderer.Resources.DisplayMetrics;

            ScreenSizeHelper.ScreenWidth  = w / metrics.Density;
            ScreenSizeHelper.ScreenHeight = h / metrics.Density;

            var menu = _basePage.SlideMenu;

            if (menu != null)
            {
                if (_dragGesture != null)
                {
                    _dragGesture.UpdateLayoutSize(menu);

                    // Actully, this cannot Layout the Hide Position
                    // but it can update the menu Layout, I didn't find a better to do so
                    var rect = _dragGesture.GetHidePosition();
                    menu.Layout(new Xamarin.Forms.Rectangle(
                                    rect.left / metrics.Density,
                                    rect.top / metrics.Density,
                                    (rect.right - rect.left) / metrics.Density,
                                    (rect.bottom - rect.top) / metrics.Density));
                }
            }

            if (!string.IsNullOrEmpty(_currentPopup))
            {
                LayoutPopup();
            }

            if (_backgroundOverlay != null)
            {
                _backgroundOverlay.Layout(
                    0,
                    0,
                    (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                    (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));
            }
        }
        public void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
        {
            var menu = _basePage.SlideMenu;

            // this is used for rotation
            double bigValue   = UIScreen.MainScreen.Bounds.Height > UIScreen.MainScreen.Bounds.Width ? UIScreen.MainScreen.Bounds.Height : UIScreen.MainScreen.Bounds.Width;
            double smallValue = UIScreen.MainScreen.Bounds.Height < UIScreen.MainScreen.Bounds.Width ? UIScreen.MainScreen.Bounds.Height : UIScreen.MainScreen.Bounds.Width;

            if (toSize.Width < toSize.Height)
            {
                ScreenSizeHelper.ScreenHeight = bigValue;
                // this is used for mutiltasking
                ScreenSizeHelper.ScreenWidth = toSize.Width < smallValue ? toSize.Width : smallValue;
            }
            else
            {
                ScreenSizeHelper.ScreenHeight = smallValue;
                ScreenSizeHelper.ScreenWidth  = toSize.Width < bigValue ? toSize.Width : bigValue;
            }

            if (!string.IsNullOrEmpty(_currentPopup))
            {
                GetPopupPositionAndLayout();

                // Layout background
                _backgroundOverlay.Frame = new CGRect(0, 0, ScreenSizeHelper.ScreenWidth, ScreenSizeHelper.ScreenHeight);
            }


            if (_dragGesture == null)
            {
                return;
            }

            _dragGesture.UpdateLayoutSize(menu);
            var rect = _dragGesture.GetHidePosition();

            menu.Layout(new Xamarin.Forms.Rectangle(
                            rect.left,
                            rect.top,
                            (rect.right - rect.left),
                            (rect.bottom - rect.top)));
            _dragGesture.LayoutHideStatus();
        }
        void UpdateMenuLayout()
        {
            var menu = _basePage.SlideMenu;

            if (menu == null || _dragGesture == null)
            {
                return;
            }

            //update layout
            _dragGesture.UpdateLayoutSize(menu);
            var rect = _dragGesture.GetHidePosition();

            menu.Layout(new Xamarin.Forms.Rectangle(
                            rect.left,
                            rect.top,
                            (rect.right - rect.left),
                            (rect.bottom - rect.top)));
            _dragGesture.LayoutHideStatus();
        }