public override Size ArrangeOverride(IPanelAdapter adapter, Size finalSize)
        {
            double usedHeight = 0;
            var    colWidth   = finalSize.Width / Columns;

            foreach (var row in measurements)
            {
                for (int i = 0; i < row.Items.Count; i++)
                {
                    adapter.Arrange(row.Items[i], i * colWidth, usedHeight, colWidth, row.RowHeight);
                }
                usedHeight += row.RowHeight;
            }
            return(new Size(finalSize.Width, usedHeight));
        }
예제 #2
0
        public override Size MeasureOverride(IPanelAdapter adapter, Size availaibleSize)
        {
            if (adapter.ChildrenCount < 1)
            {
                return(new Size(1, 1));
            }

            // measure the first Child
            adapter.Measure(0, availaibleSize);
            var firstSize = adapter.GetDesiredSize(0);

            for (int i = 1; i < adapter.ChildrenCount; i++)
            {
                adapter.Measure(i, firstSize);
            }
            return(firstSize);
        }
        public override Size MeasureOverride(IPanelAdapter adapter, Size availaibleSize)
        {
            measurements.Clear();
            var cellSize = new Size();

            for (int i = 0; i < adapter.ChildrenCount; i++)
            {
                if (i % Columns == 0)
                {
                    cellSize = new Size(availaibleSize.Width / Columns,
                                        availaibleSize.Height - measurements.Sum(j => j.RowHeight));
                    measurements.Add(new MeasurementRowHeight());
                }
                adapter.Measure(i, cellSize);
                measurements.Last().AddItem(i, adapter.GetDesiredSize(i).Height);
            }

            return(new Size(availaibleSize.Width, measurements.Sum(i => i.RowHeight)));
        }
예제 #4
0
        public override Size ArrangeOverride(IPanelAdapter adapter, Size finalSize)
        {
            if (adapter.ChildrenCount < 1)
            {
                return(finalSize);
            }
            var desiredSize = adapter.GetDesiredSize(0);

            var finalRect = new Rect(
                new Point((finalSize.Width - desiredSize.Width) / 2, (finalSize.Height - desiredSize.Height) / 2), desiredSize);

            var adjustedRect = ApplyOffset ? new Rect(OffsetPoint(finalRect, Offset.Left, Offset.Top),
                                                      OffsetPoint(finalRect, Offset.Right, Offset.Bottom)) : finalRect;

            for (int i = 0; i < adapter.ChildrenCount; i++)
            {
                adapter.Arrange(i, i == 0 ? finalRect : adjustedRect);
            }
            return(finalSize);
        }
예제 #5
0
 public abstract Size ArrangeOverride(IPanelAdapter adapter, Size finalSize);
예제 #6
0
 public abstract Size MeasureOverride(IPanelAdapter adapter, Size availaibleSize);
예제 #7
0
 public static void Arrange(this IPanelAdapter adapter, int child, double left, double top, double width,
                            double height) =>
 adapter.Arrange(child, new Rect(left, top, width, height));
예제 #8
0
 public static void Measure(this IPanelAdapter adapter, int child, double width, double height) =>
 adapter.Measure(child, new Size(width, height));