internal void InsertAfter(int index, GridRow row) { GridCell gridItem = new GridCell( this, row); cells.Insert(index + 1, gridItem); }
internal void AddRowRange(IEnumerable<GridRow> rows, int count) { GridCell[] newGrids = new GridCell[count]; int i = 0; foreach (GridRow row in rows) { GridCell gridItem = new GridCell(this, row); newGrids[i] = gridItem; i++; } cells.AddRange(newGrids); }
public override void DrawChildContent(Canvas canvas, Rectangle updateArea) { //GridCell leftTopGridItem = GetGridItemByPosition(updateArea.Left, updateArea.Top); //if (leftTopGridItem == null) //{ // return; //} //GridCell rightBottomGridItem = GetGridItemByPosition(updateArea.Right, updateArea.Bottom); //if (rightBottomGridItem == null) //{ // return; //} //TODO: temp fixed, review here again, GridCell leftTopGridItem = this.GetCell(0, 0); if (leftTopGridItem == null) { return; } GridCell rightBottomGridItem = this.GetCell(this.RowCount - 1, this.ColumnCount - 1); if (rightBottomGridItem == null) { return; } this.BeginDrawingChildContent(); GridColumn startColumn = leftTopGridItem.column; GridColumn currentColumn = startColumn; GridRow startRow = leftTopGridItem.row; GridColumn stopColumn = rightBottomGridItem.column.NextColumn; GridRow stopRow = rightBottomGridItem.row.NextRow; int startRowId = startRow.RowIndex; int stopRowId = 0; if (stopRow == null) { stopRowId = gridRows.Count; } else { stopRowId = stopRow.RowIndex; } int n = 0; var prevColor = canvas.StrokeColor; canvas.StrokeColor = Color.Gray; //canvas.DrawLine(0, 0, 100, 100); //canvas.DrawLine(0, 100, 100, 0); //if (startRowId > 0) //{ // Console.WriteLine(startRowId); //} //canvas.DrawRectangle(Color.Red, updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height); do { GridCell startGridItemInColumn = currentColumn.GetCell(startRowId); GridCell stopGridItemInColumn = currentColumn.GetCell(stopRowId - 1); //draw vertical line canvas.DrawLine( startGridItemInColumn.Right, startGridItemInColumn.Y, stopGridItemInColumn.Right, stopGridItemInColumn.Bottom); if (n == 0) { //draw horizontal line int horizontalLineWidth = rightBottomGridItem.Right - startGridItemInColumn.X; for (int i = startRowId; i < stopRowId; i++) { GridCell gridItem = currentColumn.GetCell(i); int x = gridItem.X; int gBottom = gridItem.Bottom; canvas.DrawLine( x, gBottom, x + horizontalLineWidth, gBottom); } n = 1; } currentColumn = currentColumn.NextColumn; } while (currentColumn != stopColumn); canvas.StrokeColor = prevColor; currentColumn = startColumn; //---------------------------------------------------------------------------- do { for (int i = startRowId; i < stopRowId; i++) { GridCell gridItem = currentColumn.GetCell(i); if (gridItem != null && gridItem.HasContent) { int x = gridItem.X; int y = gridItem.Y; canvas.OffsetCanvasOrigin(x, y); updateArea.Offset(-x, -y); var renderContent = gridItem.ContentElement as RenderElement; if (renderContent != null) { if (canvas.PushClipAreaRect(gridItem.Width, gridItem.Height, ref updateArea)) { renderContent.DrawToThisCanvas(canvas, updateArea); } canvas.PopClipAreaRect(); } canvas.OffsetCanvasOrigin(-x, -y); updateArea.Offset(x, y); } #if DEBUG else { canvas.DrawText(new char[] { '.' }, gridItem.X, gridItem.Y); } #endif } currentColumn = currentColumn.NextColumn; } while (currentColumn != stopColumn); this.FinishDrawingChildContent(); }
internal GridCell CreateGridItemForRow(GridRow row) { GridCell gridItem = new GridCell( this, row); cells.Add(gridItem); return gridItem; }
static void ReCalculateContentSize(GridCell cell) { var renderE = cell.ContentElement as RenderElement; if (renderE != null && !renderE.HasCalculatedSize) { renderE.TopDownReCalculateContentSize(); } }