/// <summary> /// Populates the contents (ScrollView) with all the /// Examples that have been Added using the AddExample(...) /// call /// </summary> private void Populate() { Vector2 stagesize = Window.Instance.Size; mTotalPages = (numOfSamples + EXAMPLES_PER_ROW * ROWS_PER_PAGE - 1) / (EXAMPLES_PER_ROW * ROWS_PER_PAGE); mpages = new TableView[mTotalPages]; tile = new View[numOfSamples]; tileBackGround = new View[numOfSamples]; int iter = 0; // Calculate the number of images going across (columns) within a page, // according to the screen resolution and dpi. ushort margin = 2; float tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW; for (int t = 0; t < mTotalPages; t++) { // Create Table TableView page = new TableView(ROWS_PER_PAGE, EXAMPLES_PER_ROW); page.PositionUsesPivotPoint = true; page.PivotPoint = PivotPoint.Center; page.ParentOrigin = ParentOrigin.Center; page.HeightResizePolicy = ResizePolicyType.FillToParent; page.WidthResizePolicy = ResizePolicyType.FillToParent; page.Position2D = new Position2D((int)stagesize.Width * t, 0); scrollView.Add(page); for (uint row = 0; row < ROWS_PER_PAGE; row++) { for (uint column = 0; column < EXAMPLES_PER_ROW; column++) { // Calculate the tiles relative pmScrollingosition // on the page (between 0 - 1 in each dimension). Vector2 position = new Vector2(column / (EXAMPLES_PER_ROW - 1.0f), row / (EXAMPLES_PER_ROW - 1.0f)); tile[iter] = CreateTile(samples[iter], samples[iter], new Vector3(tileParentMultiplier, tileParentMultiplier, 1.0f), position); tile[iter].Padding = new Extents(margin, margin, margin, margin); tileBackGround[iter] = tile[iter].GetChildAt(0); page.AddChild(tile[iter], new TableView.CellPosition(row, column)); iter++; if (iter == numOfSamples) { break; } } if (iter == numOfSamples) { break; } } mpages[t] = page; if (iter == numOfSamples) { break; } } }