private void MeasureChildren(Size availableSize) { _pages = new List <FlexyPanelPage>(); double tempWidth = 0; double tempHeight = 0; int currentPageIndex = 0; int currentRowIndex = 0; int maxRowCount = 2; List <FlexyPanelPageRow> allRows = new List <FlexyPanelPageRow>(); FlexyPanelPageRow tempRow = new FlexyPanelPageRow(); tempRow.Children = new List <FrameworkElement>(); FlexyPanelPage tempPage = new FlexyPanelPage(); tempPage.Rows = new List <FlexyPanelPageRow>(); foreach (FrameworkElement child in InternalChildren) { double estimatedWidth = tempWidth + child.Width + ItemMargin.Left + ItemMargin.Right; tempHeight = child.Height + ItemMargin.Top + ItemMargin.Bottom; if (estimatedWidth < availableSize.Width) { tempWidth = estimatedWidth; tempRow.Children.Add(child); tempRow.Height = Math.Max(child.Height + ItemMargin.Top + ItemMargin.Bottom, tempRow.Height); tempRow.Width = tempWidth; } else { allRows.Add(tempRow); tempRow = new FlexyPanelPageRow(); tempRow.Children = new List <FrameworkElement>(); tempRow.Children.Add(child); tempRow.Height = Math.Max(child.Height + ItemMargin.Top + ItemMargin.Bottom, tempRow.Height); tempWidth = child.Width + ItemMargin.Right + ItemMargin.Left; } } allRows.Add(tempRow); foreach (var row in allRows) { if (currentRowIndex < maxRowCount) { tempPage.Rows.Add(row); currentRowIndex++; } else { tempPage.Index = currentPageIndex++; currentRowIndex = 0; _pages.Add(tempPage); tempPage = new FlexyPanelPage(); tempPage.Rows = new List <FlexyPanelPageRow>(); tempPage.Rows.Add(row); currentRowIndex++; } } tempPage.Index = currentPageIndex++; _pages.Add(tempPage); }
private void MeasureChildren(Size availableSize) { _pages = new List<FlexyPanelPage>(); double tempWidth = 0; double tempHeight = 0; int currentPageIndex = 0; int currentRowIndex = 0; int maxRowCount = 2; List<FlexyPanelPageRow> allRows = new List<FlexyPanelPageRow>(); FlexyPanelPageRow tempRow = new FlexyPanelPageRow(); tempRow.Children = new List<FrameworkElement>(); FlexyPanelPage tempPage = new FlexyPanelPage(); tempPage.Rows = new List<FlexyPanelPageRow>(); foreach (FrameworkElement child in InternalChildren) { double estimatedWidth = tempWidth + child.Width + ItemMargin.Left + ItemMargin.Right; tempHeight = child.Height + ItemMargin.Top + ItemMargin.Bottom; if (estimatedWidth < availableSize.Width) { tempWidth = estimatedWidth; tempRow.Children.Add(child); tempRow.Height = Math.Max(child.Height + ItemMargin.Top + ItemMargin.Bottom, tempRow.Height); tempRow.Width = tempWidth; } else { allRows.Add(tempRow); tempRow = new FlexyPanelPageRow(); tempRow.Children = new List<FrameworkElement>(); tempRow.Children.Add(child); tempRow.Height = Math.Max(child.Height + ItemMargin.Top + ItemMargin.Bottom, tempRow.Height); tempWidth = child.Width + ItemMargin.Right + ItemMargin.Left; } } allRows.Add(tempRow); foreach (var row in allRows) { if (currentRowIndex < maxRowCount) { tempPage.Rows.Add(row); currentRowIndex++; } else { tempPage.Index = currentPageIndex++; currentRowIndex = 0; _pages.Add(tempPage); tempPage = new FlexyPanelPage(); tempPage.Rows = new List<FlexyPanelPageRow>(); tempPage.Rows.Add(row); currentRowIndex++; } } tempPage.Index = currentPageIndex++; _pages.Add(tempPage); }