コード例 #1
0
        void ShowBackgroundForPopup(Android.Graphics.Color color)
        {
            if (_popupBasePage == null)
            {
                return;
            }
            if (_popupRenderer == null)
            {
                return;
            }
            _backgroundOverlay = new global::Android.Widget.LinearLayout(Android.App.Application.Context);
            _pageRenderer.ViewGroup.AddView(_backgroundOverlay);
            _backgroundOverlay.SetBackgroundColor(color);

            _backgroundOverlay.Touch -= HidePopup;
            _backgroundOverlay.Touch += HidePopup;

            var metrics = _pageRenderer.Resources.DisplayMetrics;

            _backgroundOverlay.Layout(
                0,
                0,
                (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));
        }
コード例 #2
0
        void ShowBackgroundOverlay (double alpha)
        {
            if (_basePage == null)
                return;
            var menu = _basePage.SlideMenu;
            if (menu == null)
                return;

            double value = (double)(alpha * _basePage.SlideMenu.BackgroundViewColor.A);
            if (_backgroundOverlay != null) {
                var color = _basePage.SlideMenu.BackgroundViewColor.ToAndroid ();
                color.A = (Byte)(255 * value);
                _backgroundOverlay.SetBackgroundColor (color);
                return;
            }
            _backgroundOverlay = new global::Android.Widget.LinearLayout (Android.App.Application.Context);
            _pageRenderer.ViewGroup.AddView (_backgroundOverlay);
            _backgroundOverlay.SetBackgroundColor (_basePage.SlideMenu.BackgroundViewColor.ToAndroid ());

            _backgroundOverlay.Touch -= HideMenu;
            _backgroundOverlay.Touch += HideMenu;
            var metrics = _pageRenderer.Resources.DisplayMetrics;
            _backgroundOverlay.Layout (
                0,
                0,
                (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));

        }
コード例 #3
0
        void ShowBackgroundForPopup(Android.Graphics.Color color)
        {
            if (_popupBasePage == null)
            {
                return;
            }
            if (_popupRenderer == null)
            {
                return;
            }
            _backgroundOverlay = new global::Android.Widget.LinearLayout(Forms.Context);
            _pageRenderer.ViewGroup.AddView(_backgroundOverlay);
            _backgroundOverlay.SetBackgroundColor(color);

            _backgroundOverlay.Touch += (object sender, Android.Views.View.TouchEventArgs e) => {
                _popupBasePage.HidePopupAction();
            };
            var metrics = _pageRenderer.Resources.DisplayMetrics;

            _backgroundOverlay.Layout(
                0,
                0,
                (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));
        }
コード例 #4
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));
            }
        }
コード例 #5
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);

                    // 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));
            }
        }
コード例 #6
0
        void ShowBackgroundOverlay(double alpha)
        {
            if (_basePage == null)
                return;
            var menu = _basePage.SlideMenu;
            if (menu == null)
                return;

            double value = (double)(alpha * _basePage.SlideMenu.BackgroundViewColor.A);
            if (_backgroundOverlay != null) {
                var color = _basePage.SlideMenu.BackgroundViewColor.ToAndroid ();
                color.A = (Byte)(255 * value);
                _backgroundOverlay.SetBackgroundColor (color);
                return;
            }
            _backgroundOverlay = new global::Android.Widget.LinearLayout (Forms.Context);
            _pageRenderer.ViewGroup.AddView (_backgroundOverlay);
            _backgroundOverlay.SetBackgroundColor (_basePage.SlideMenu.BackgroundViewColor.ToAndroid ());

            _backgroundOverlay.Touch += (object sender, Android.Views.View.TouchEventArgs e) => {
                _basePage.HideMenuAction ();
            };
            var metrics = _pageRenderer.Resources.DisplayMetrics;
            _backgroundOverlay.Layout (
                0,
                0,
                (int)(ScreenSizeHelper.ScreenWidth * metrics.Density),
                (int)(ScreenSizeHelper.ScreenHeight * metrics.Density));
        }