Beispiel #1
0
        public void Arrange(ref LayoutView <T> view, float x, float y, float width, float height, float viewWidth, float viewHeight)
        {
            if (view.HorizontalAlignment == HorizontalAlignment.Right)
            {
                x += width - viewWidth;
            }
            else if (view.HorizontalAlignment == HorizontalAlignment.Center)
            {
                x += (width - viewWidth) / 2;
            }

            if (view.HorizontalAlignment != HorizontalAlignment.Stretch)
            {
                width = viewWidth;
            }

            if (view.VerticalAlignment == VerticalAlignment.Bottom)
            {
                y += height - viewHeight;
            }
            else if (view.VerticalAlignment == VerticalAlignment.Center)
            {
                y += (height - viewHeight) / 2;
            }

            if (view.VerticalAlignment != VerticalAlignment.Stretch)
            {
                height = viewHeight;
            }

            if (view.Panel != null)
            {
                view.Panel.Arrange(x, y, width, height);
            }
            else if (view.View != null)
            {
                _adapter.Arrange(view.View, x, y, width, height);
            }
        }
Beispiel #2
0
        public Size Measure(ref LayoutView <T> view, float width, float height)
        {
            Size size = Size.Zero;

            if (view.Panel != null)
            {
                size = view.Panel.Measure(width, height);
            }
            else if (view.View != null)
            {
                size = _adapter.Measure(view.View, width, height);
            }

            if (view.Frame.MaxWidth > 0 && size.Width > view.Frame.MaxWidth)
            {
                size.Width = view.Frame.MaxWidth;
            }
            if (size.Width < view.Frame.MinWidth)
            {
                size.Width = view.Frame.MinWidth;
            }

            if (view.Frame.MaxHeight > 0 && size.Height > view.Frame.MaxHeight)
            {
                size.Height = view.Frame.MaxHeight;
            }
            if (size.Height < view.Frame.MinHeight)
            {
                size.Height = view.Frame.MinHeight;
            }

            size.Width  += view.Frame.Margin.Left + view.Frame.Margin.Right;
            size.Height += view.Frame.Margin.Top + view.Frame.Margin.Bottom;

            return(size);
        }
Beispiel #3
0
        public void Arrange(ref LayoutView <T> view, float x, float y, float width, float height)
        {
            var size = Measure(ref view, width, height);

            Arrange(ref view, x, y, width, height, size.Width, size.Height);
        }