예제 #1
0
        public static SizeF PreferredSize(ILayoutable view, SizeF bounds)
        {
            var layout = new LayoutBuilder(new RectangleF(PointF.Empty, bounds));

            view.OnLayout(layout);
            return(layout.PreferredSize);
        }
예제 #2
0
        public sealed override void LayoutSubviews()
        {
            var layoutBuilder = new LayoutBuilder((RectangleF)Bounds);

            OnLayout(layoutBuilder);
            foreach (var box in layoutBuilder.Views)
            {
                box.Layout();
            }
        }
예제 #3
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            var layout = new LayoutBuilder((RectangleF)Bounds);

            OnLayout(layout);
            foreach (var v in layout.Views)
            {
                v.Layout();
            }
        }
예제 #4
0
        protected sealed override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            //var rect = new RectangleF(PaddingLeft, PaddingTop, r - l - PaddingRight, b - t - PaddingBottom);
            var rect          = new RectangleF(0, 0, r - l, b - t);
            var layoutBuilder = new LayoutBuilder(rect);

            OnLayout(layoutBuilder);
            foreach (var box in layoutBuilder.Views)
            {
                box.Layout();
            }
        }
예제 #5
0
 protected override void OnLayout(LayoutBuilder layout)
 {
     layout.View(ImageView)
     .Top(0).Bottom(0).Left(0).Right(0);
     if (Indicator != null)
     {
         layout.View(Indicator)
         .CenterVertically()
         .CenterHorizontally()
         .AutoSize();
     }
 }
예제 #6
0
 public static void Distribute(this LayoutBuilder layout, RectangleF bounds, DistributionDirection direction,
                               params PlatformView[] views)
 {
     if (direction == DistributionDirection.Horizontal)
     {
         layout.DistributeHorizontally(bounds, views);
     }
     else
     {
         layout.DistributeVertically(bounds, views);
     }
 }
예제 #7
0
        public sealed override void LayoutSubviews()
        {
            var layoutBuilder = new LayoutBuilder((RectangleF)Bounds);

            layoutBuilder.Padding = new EdgeInsets(Padding.Left,
                                                   Padding.Top,
                                                   Padding.Right,
                                                   Padding.Bottom);
            OnLayout(layoutBuilder);
            foreach (var box in layoutBuilder.Views)
            {
                box.Layout();
            }
        }
예제 #8
0
        public LinearLayoutBuilder(LayoutBuilder layoutBuilder, LinearLayoutDirection layoutDirection, LinearLayoutDirection?flowDirection = null, RectangleF?bounds = null)
        {
            Assert.Argument(layoutBuilder, nameof(layoutBuilder)).NotNull();
            flowDirection  = flowDirection ?? DefaultFlowDirection(layoutDirection);
            _layoutBuilder = layoutBuilder;
            _maxSize       = 0;
            var layoutBounds = bounds ?? _layoutBuilder.OuterBounds;

            _layoutBounds      = new RectangleF(layoutBounds.Location, SizeF.Empty);
            _layoutToView      = LayoutTransform(layoutBounds, layoutDirection, flowDirection.Value);
            _viewToLayout      = _layoutToView.Inverted();
            _layoutSpaceBounds = _viewToLayout.Transform(layoutBounds);
            _layoutOrigin      = _layoutSpaceBounds.Location;
        }
예제 #9
0
        public virtual System.Drawing.SizeF SizeThatFits(System.Drawing.SizeF bounds)
        {
            var layoutBuilder = new LayoutBuilder(new RectangleF(PointF.Empty, bounds));

            OnLayout(layoutBuilder);
            int l = int.MaxValue, t = int.MaxValue, r = int.MinValue, b = int.MinValue;

            foreach (var v in layoutBuilder.Views)
            {
                l = (int)Math.Round(Math.Min(v.LayoutLeft, l));
                r = (int)Math.Round(Math.Max(v.LayoutRight, r));
                t = (int)Math.Round(Math.Min(v.LayoutTop, t));
                b = (int)Math.Round(Math.Max(v.LayoutBottom, b));
            }
            return(new System.Drawing.SizeF(Math.Abs(r - l), Math.Abs(b - t)));
        }
예제 #10
0
        public static void DistributeVertically(this LayoutBuilder layout, RectangleF bounds,
                                                params PlatformView[] views)
        {
            var viewBoxes  = views.Select(x => layout.View(x)).ToArray();
            var totalWidth = viewBoxes.Sum(x => x.Height);

            if (totalWidth > bounds.Height || views.Length < 2)
            {
                return;
            }
            var dx     = (bounds.Height - totalWidth) / (views.Length - 1);
            var xCoord = 0f;

            foreach (var v in viewBoxes)
            {
                v.Top(xCoord).Height(v.Height);
                xCoord += (dx + v.Height);
            }
        }
예제 #11
0
        public static SizeF SizeThatFits(ILayoutable view, SizeF bounds)
        {
            var layout = new LayoutBuilder(new RectangleF(PointF.Empty, bounds));

            view.OnLayout(layout);
            float l = int.MaxValue, t = int.MaxValue, r = int.MinValue, b = int.MinValue;

            foreach (var v in layout.Views)
            {
                var frame = v.LayoutBounds;
                l = Math.Min(frame.Left, l);
                r = Math.Max(frame.Right, r);
                t = Math.Min(frame.Top, t);
                b = Math.Max(frame.Bottom, b);
            }

            // Top and Left padings already assumed by 'r' and 'b' coordinates
            // since layout performed in padded rectangle.
            return(new SizeF((float)(r + layout.Padding.Right),
                             (float)(b + layout.Padding.Bottom)));
        }
예제 #12
0
 protected virtual void OnLayout(LayoutBuilder layout)
 {
 }
예제 #13
0
 void ILayoutable.OnLayout(LayoutBuilder layout)
 {
     OnLayout(layout);
 }
예제 #14
0
 public static void DistributeVertically(this LayoutBuilder layout, params PlatformView[] views)
 {
     layout.DistributeVertically(layout.PaddedOuterBounds, views);
 }