示例#1
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();
     }
 }
示例#2
0
        private LayoutViewResult LayoutView(PointF layoutOrigin, ref LayoutParams layoutParams)
        {
            var freeSpaceSize = new SizeF(Math.Max(0, _layoutSpaceBounds.Right - layoutOrigin.X),
                                          Math.Max(0, _layoutSpaceBounds.Bottom - layoutOrigin.Y));
            //Free space available a view in layout coordinates
            var freeSpace = new RectangleF(layoutOrigin, freeSpaceSize);
            //Free space available for a view in view coordinates
            var viewFreeSpace = _layoutToView.Transform(freeSpace);
            //Area which view wants to occupy in view coordinates
            var viewBox = _layoutBuilder.View(layoutParams.View, viewFreeSpace);

            _views.Add(viewBox);
            layoutParams.Layout(viewBox);
            //Area which view wants to occupy in layout coordinates
            var layoutFrame = _viewToLayout.Transform(viewBox.Frame());
            //Space required for view starting from layout origin in layout coordinates
            var viewFrame       = new RectangleF(layoutOrigin, new SizeF(layoutFrame.Right - layoutOrigin.X, layoutFrame.Bottom - layoutOrigin.Y));
            var newLayoutOrigin = new PointF(viewFrame.Right + LayoutStep, viewFrame.Top);

            return(new LayoutViewResult()
            {
                ViewLayoutBox = viewBox,
                NewLayoutOrigin = newLayoutOrigin,
                LayoutViewFrame = viewFrame
            });
        }
示例#3
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);
            }
        }