コード例 #1
0
        /// <summary>
        /// Measures wrapped UWP XAML content using passed in size availableSize
        /// </summary>
        /// <param name="availableSize">Available Size</param>
        /// <returns>XAML DesiredSize</returns>
        protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize)
        {
            Windows.Foundation.Size desiredSize = new Windows.Foundation.Size(0, 0);

            Windows.UI.Xaml.UIElement element = Child;

            if (element != null)
            {
                try
                {
                    element.Measure(new Windows.Foundation.Size(availableSize.Width / _scalingFactor, availableSize.Height / _scalingFactor));
                }
                catch (Exception)
                {
                    Debugger.Break();
                }

                desiredSize.Width  = element.DesiredSize.Width * _scalingFactor;
                desiredSize.Height = element.DesiredSize.Height * _scalingFactor;
            }

            desiredSize.Width  = Math.Min(desiredSize.Width, availableSize.Width);
            desiredSize.Height = Math.Min(desiredSize.Height, availableSize.Height);

            return(desiredSize);
        }
コード例 #2
0
        protected override Size MeasureOverride(Size availableSize)
        {
            Size desiredSize = new Size(0, 0);

            Windows.UI.Xaml.UIElement rootXamlElement = Windows.UI.Xaml.Window.Current.Content;

            if (rootXamlElement != null)
            {
                rootXamlElement.Measure(new Windows.Foundation.Size(availableSize.Width, availableSize.Height));
                desiredSize.Width  = rootXamlElement.DesiredSize.Width;
                desiredSize.Height = rootXamlElement.DesiredSize.Height;
            }

            desiredSize.Width  = Math.Min(desiredSize.Width, availableSize.Width);
            desiredSize.Height = Math.Min(desiredSize.Height, desiredSize.Height);

            // uncomment to debug layout issues
            //Debug.WriteLine("JupiterHost Measure({0}x{1}), DesiredSize= {2}x{3}", availableSize.Width, availableSize.Height, desiredSize.Width, desiredSize.Height);

            return(desiredSize);
        }
コード例 #3
0
        public static void layout(Windows.UI.Xaml.UIElement widget, int widthConstraint, bool force = false)
        {
            if (!(widget != null))
            {
                return;
            }
            var done = false;

            if (widget is cave.ui.WidgetWithLayout)
            {
                done = ((cave.ui.WidgetWithLayout)widget).layoutWidget(widthConstraint, force);
            }
            if (!done)
            {
                var srw = 0;
                var srh = 0;
                Windows.Foundation.Size available;
                available.Height = float.PositiveInfinity;
                if (widthConstraint >= 0)
                {
                    available.Width = (float)widthConstraint;
                }
                else
                {
                    available.Width = float.PositiveInfinity;
                }
                widget.Measure(available);
                srw = (int)System.Math.Ceiling(widget.DesiredSize.Width);
                srh = (int)System.Math.Ceiling(widget.DesiredSize.Height);
                widget.InvalidateMeasure();
                if (widthConstraint >= 0 && srw < widthConstraint)
                {
                    srw = widthConstraint;
                }
                cave.ui.Widget.setLayoutSize(widget, srw, srh);
            }
        }
コード例 #4
0
        protected Size MeasureChildOverride(View view, Size slotSize)
        {
            view.Measure(slotSize);

            return(view.DesiredSize);
        }