Beispiel #1
0
        public IScreenState GetScreenState()
        {
            var pixelDensisty = _activity?.Resources?.DisplayMetrics?.Density ?? 1;

            var rotation   = _screenHelper.GetRotation();
            var hinge      = _screenHelper.GetHingeBounds();
            var windowRect = GetWindowRect();

            if (IsDualMode)
            {
                return(new ScreenState
                {
                    Screen1Visible = true,
                    Screen1Bounds = new Rect(0, 0, PixelsToDip(hinge.Left), PixelsToDip(windowRect.Bottom)),
                    Screen2Visible = true,
                    Screen2Bounds = new Rect(PixelsToDip(hinge.Right), 0, PixelsToDip(windowRect.Right - hinge.Right), PixelsToDip(windowRect.Bottom))
                });
            }
            else
            {
                return(new ScreenState
                {
                    Screen1Visible = true,
                    Screen1Bounds = new Rect(0, 0, PixelsToDip(windowRect.Right), PixelsToDip(windowRect.Bottom)),
                    Screen2Visible = false,
                    Screen2Bounds = Rect.Empty
                });
            }
        }
Beispiel #2
0
        void Update()
        {
            var isSpanned = screenHelper.IsDualMode;

            var hb  = screenHelper.GetHingeBounds();
            var hbd = screenHelper.GetHingeBoundsDip();

            var hingeText = $"Hinge:    x:{hb.Left}, y:{hb.Top}, w:{hb.Width()}, h:{hb.Height()}";

            hingeText += $"\r\nHinge DP: x:{hbd.Left}, y:{hbd.Top}, w:{hbd.Width()}, h:{hbd.Height()}";

            FindViewById <TextView>(Resource.Id.textViewDuo).Text   = $"Duo: {isDuo}";
            FindViewById <TextView>(Resource.Id.textViewSpan).Text  = $"Spanned: {isSpanned}";
            FindViewById <TextView>(Resource.Id.textViewHinge).Text = hingeText;
        }