Esempio n. 1
0
        internal static Xamarin.Forms.Size Measure(ExtraView view)
        {
            var display = (Context as Activity)?.WindowManager.DefaultDisplay;

            Point size = new Point();

            display.GetSize(size);

            var dWidth  = Context.FromPixels(size.X);
            var dHeight = Context.FromPixels(size.Y);

            var fWidth  = view.ProportionalWidth >= 0 ? dWidth * view.ProportionalWidth : dWidth;
            var fHeight = view.ProportionalHeight >= 0 ? dHeight * view.ProportionalHeight : dHeight;

            if (view.ProportionalWidth < 0 || view.ProportionalHeight < 0)
            {
                var sizeRequest = view.Measure(fWidth, fHeight);

                var reqWidth  = view.ProportionalWidth >= 0 ? fWidth : sizeRequest.Request.Width;
                var reqHeight = view.ProportionalHeight >= 0 ? fHeight : sizeRequest.Request.Height;

                return(new XF.Size(reqWidth, reqHeight));
            }

            return(new XF.Size(fWidth, fHeight));
        }
Esempio n. 2
0
        internal static Size Measure(ExtraView view)
        {
            var window = UIApplication.SharedApplication.KeyWindow;

            var dWidth  = window.Bounds.Width;
            var dHeight = window.Bounds.Height;

            double fWidth = dWidth;

            if (view.ProportionalWidth >= 0)
            {
                fWidth = dWidth * view.ProportionalWidth;
            }
            else if (view.HorizontalLayoutAlignment == LayoutAlignment.Fill)
            {
                fWidth = dWidth;
            }
            else if (view.WidthRequest == -1)
            {
                fWidth = double.PositiveInfinity;
            }
            else if (view.WidthRequest >= 0)
            {
                fWidth = view.WidthRequest;
            }

            double fHeight = dHeight;

            if (view.ProportionalHeight >= 0)
            {
                fHeight = dHeight * view.ProportionalHeight;
            }
            else if (view.VerticalLayoutAlignment == LayoutAlignment.Fill)
            {
                fHeight = dHeight;
            }
            else if (view.HeightRequest == -1)
            {
                fHeight = double.PositiveInfinity;
            }
            else if (view.HeightRequest >= 0)
            {
                fHeight = view.HeightRequest;
            }

            if (view.ProportionalWidth < 0 || view.ProportionalHeight < 0)
            {
                var sizeRequest = view.Measure(fWidth, fHeight, MeasureFlags.IncludeMargins);

                var reqWidth  = view.ProportionalWidth >= 0 ? fWidth : sizeRequest.Request.Width;
                var reqHeight = view.ProportionalHeight >= 0 ? fHeight : sizeRequest.Request.Height;

                return(new Size(reqWidth, reqHeight));
            }

            // If both width and height are proportional, Measure is not called.
            return(new Size(fWidth, fHeight));
        }
Esempio n. 3
0
        internal static Xamarin.Forms.Size Measure(ExtraView view)
        {
            var dWidth  = Context.FromPixels(ContentSize.Width);
            var dHeight = Context.FromPixels(ContentSize.Height);

            double fWidth = dWidth;

            if (view.ProportionalWidth >= 0)
            {
                fWidth = dWidth * view.ProportionalWidth;
            }
            else if (view.HorizontalLayoutAlignment == XF.LayoutAlignment.Fill)
            {
                fWidth = dWidth;
            }
            else if (view.WidthRequest == -1)
            {
                fWidth = double.PositiveInfinity;
            }
            else if (view.WidthRequest >= 0)
            {
                fWidth = view.WidthRequest;
            }

            double fHeight = dHeight;

            if (view.ProportionalHeight >= 0)
            {
                fHeight = dHeight * view.ProportionalHeight;
            }
            else if (view.VerticalLayoutAlignment == XF.LayoutAlignment.Fill)
            {
                fHeight = dHeight;
            }
            else if (view.HeightRequest == -1)
            {
                fHeight = double.PositiveInfinity;
            }
            else if (view.HeightRequest >= 0)
            {
                fHeight = view.HeightRequest;
            }


            if (view.ProportionalWidth < 0 || view.ProportionalHeight < 0)
            {
                var sizeRequest = view.Measure(fWidth, fHeight, XF.MeasureFlags.IncludeMargins);

                var reqWidth  = view.ProportionalWidth >= 0 ? fWidth : sizeRequest.Request.Width;
                var reqHeight = view.ProportionalHeight >= 0 ? fHeight : sizeRequest.Request.Height;

                return(new XF.Size(reqWidth, reqHeight));
            }

            return(new XF.Size(fWidth, fHeight));
        }
Esempio n. 4
0
        internal static Size Measure(ExtraView view)
        {
            var window = UIApplication.SharedApplication.KeyWindow;

            var dWidth  = window.Bounds.Width;
            var dHeight = window.Bounds.Height;

            var fWidth  = view.ProportionalWidth >= 0 ? dWidth * view.ProportionalWidth : dWidth;
            var fHeight = view.ProportionalHeight >= 0 ? dHeight * view.ProportionalHeight : dHeight;

            if (view.ProportionalWidth < 0 || view.ProportionalHeight < 0)
            {
                var sizeRequest = view.Measure(fWidth, fHeight);

                var reqWidth  = view.ProportionalWidth >= 0 ? fWidth : sizeRequest.Request.Width;
                var reqHeight = view.ProportionalHeight >= 0 ? fHeight : sizeRequest.Request.Height;

                return(new Size(reqWidth, reqHeight));
            }

            // If both width and height are proportional, Measure is not called.
            return(new Size(fWidth, fHeight));
        }