private T GetCellDecorator(IItemInfoNode parentRow, ItemInfo columnItemInfo, int rowLine, int columnLine) { Dictionary <int, T> columnCellsPair; if (!this.generatedRowCells.TryGetValue(rowLine, out columnCellsPair)) { columnCellsPair = new Dictionary <int, T>(); this.generatedRowCells[rowLine] = columnCellsPair; } var cellValue = this.table.GetCellValue(parentRow.ItemInfo, columnItemInfo); bool isFrozen = false; if (columnItemInfo.Item is DataGridColumn) { isFrozen = (columnItemInfo.Item as DataGridColumn).IsFrozen; } var context = new CellGenerationContext(parentRow.ItemInfo.Item, columnItemInfo.Item, cellValue, isFrozen); object containerType = this.containerGenerator.ContainerTypeForItem(context); if (containerType == null) { return(null); } T cellDecorator; if (!columnCellsPair.TryGetValue(columnLine, out cellDecorator)) { cellDecorator = this.containerGenerator.GenerateContainer(context); columnCellsPair.Add(columnLine, cellDecorator); cellDecorator.layoutSlot = RadRect.Invalid; cellDecorator.DesiredSize = RadSize.Invalid; cellDecorator.parent = parentRow as Element; } if (!object.Equals(cellDecorator.Value, cellValue) || cellDecorator.Column != columnItemInfo.Item || cellDecorator.Column.ShouldRefreshCell(cellDecorator)) { cellDecorator.Value = cellValue; cellDecorator.Column = columnItemInfo.Item as DataGridColumn; cellDecorator.Column.ItemInfo = columnItemInfo; this.containerGenerator.PrepareContainerForItem(cellDecorator); } return(cellDecorator); }
private void UpdateReadOnlyRowOpacity(IItemInfoNode rowDecorator) { var row = rowDecorator as GridRowModel; if (!this.isInEditMode || row == null) { return; } if (this.EditRowPool.ReadOnlyItemInfo.Equals(row.ItemInfo)) { this.HideRow(row); } else { this.ShowRow(row); } }
internal bool GenerateCellsForRow(IItemInfoNode rowDecorator, int rowSlot) { var rowItem = rowDecorator.ItemInfo.Item; var isPlaceHolder = rowItem is PlaceholderInfo; if (rowItem is IGroup || isPlaceHolder) { return(false); } double desiredWidth = 0; bool shouldUpdateColumns = false; double availableWidth = this.ColumnPool.AvailableLength; int generatedCellCount = 0; var columns = this.ColumnPool.GetDisplayedElements().ToArray(); bool generated = this.generatedRowCells.ContainsKey(rowSlot); foreach (var columnPairs in columns) { int columnLine = columnPairs.Key; var columnDecorator = columnPairs.Value.LastOrDefault(); Debug.Assert(columnDecorator != null, "Decorator shoundn't be null"); int columnSlot = columnLine; generatedCellCount++; T cellModel = null; if (generated) { var cellsPerLine = this.generatedRowCells[rowSlot]; cellsPerLine.TryGetValue(columnLine, out cellModel); } if (cellModel == null) { cellModel = this.GetCellDecorator(rowDecorator, columnDecorator.ItemInfo, rowSlot, columnLine); } if (cellModel != null) { cellModel.parent = rowDecorator as Element; } var desiredSize = this.MeasureCellDecorator(cellModel); double cellWidth = desiredSize.Width; double cellHeight = desiredSize.Height; this.UpdateSlotHeight(rowSlot, cellHeight); bool slotWidthUpdated = this.UpdateSlotWidth(columnSlot, cellWidth); shouldUpdateColumns = shouldUpdateColumns || slotWidthUpdated; desiredWidth += this.GetSlotWidth(columnSlot); if (generatedCellCount == 1) { desiredWidth -= this.ColumnPool.HiddenPixels; } if (GridModel.DoubleArithmetics.IsGreaterThan(desiredWidth, availableWidth)) { break; } } // TODO:Handle this better in frozen columns scenario shouldUpdateColumns = generatedCellCount != this.ColumnPool.ViewportItemCount && this.table.FrozenColumnCount == 0 || shouldUpdateColumns; return(shouldUpdateColumns); }
internal bool GenerateCellsForColumn(IItemInfoNode columnDecorator, int columnSlot) { double desiredHeight = 0; double availableHeight = this.RowPool.AvailableLength; double availableWidth = this.ColumnPool.AvailableLength; bool shouldUpdateRows = false; int generatedCellCount = 0; var rows = this.RowPool.GetDisplayedElements().ToArray(); foreach (var rowPairs in rows) { int rowSlot = rowPairs.Key; var rowDecorator = rowPairs.Value.LastOrDefault(); Debug.Assert(rowDecorator != null, "Decorator shoundn't be null"); generatedCellCount++; bool isGroup = rowDecorator.ItemInfo.Item is IGroup; bool isPlaceHolder = rowDecorator.ItemInfo.Item is PlaceholderInfo; if (isGroup || isPlaceHolder) { desiredHeight += rowDecorator.DesiredSize.Height; continue; } T cellModel = null; if (this.generatedRowCells.ContainsKey(rowSlot)) { var cellsPerLine = this.generatedRowCells[rowSlot]; if (isGroup) { Debug.Assert(cellsPerLine.Count < 2, "Groups should have 1 cell only"); if (cellsPerLine.Count == 1) { cellModel = cellsPerLine.First().Value; } } else { cellsPerLine.TryGetValue(columnSlot, out cellModel); } } if (cellModel == null) { cellModel = this.GetCellDecorator(rowDecorator, columnDecorator.ItemInfo, rowSlot, columnSlot); } if (cellModel != null) { cellModel.parent = rowDecorator; } var desiredSize = this.MeasureCellDecorator(cellModel); double cellWidth = desiredSize.Width; double cellHeigth = desiredSize.Height; this.UpdateSlotWidth(columnSlot, cellWidth); bool slotHeightUpdated = this.UpdateSlotHeight(rowSlot, cellHeigth); shouldUpdateRows = shouldUpdateRows || slotHeightUpdated; desiredHeight += this.GetSlotHeight(rowSlot); if (generatedCellCount == 1) { desiredHeight -= this.RowPool.HiddenPixels; } if (GridModel.DoubleArithmetics.IsGreaterThan(desiredHeight, availableHeight)) { break; } } shouldUpdateRows = generatedCellCount != this.RowPool.ViewportItemCount || shouldUpdateRows; return(shouldUpdateRows); }
double ITable.GenerateCellsForColumn(int columnSlot, double largestColumnElementWidth, IItemInfoNode columnDecorator) { this.CellsController.UpdateSlotWidth(columnSlot, largestColumnElementWidth); Debug.Assert(columnDecorator != null, "Decorator shoundn't be null"); bool shouldUpdateRows = this.CellsController.GenerateCellsForColumn(columnDecorator, columnSlot); if (shouldUpdateRows) { this.InvalidateRowsMeasure(); } return(this.CellsController.GetSlotWidth(columnSlot)); }
private double GenerateCellsForEditRow(int rowSlot, double largestRowElementWidth, IItemInfoNode rowDecorator) { this.CellEditorsController.UpdateSlotHeight(rowSlot, largestRowElementWidth); Debug.Assert(rowDecorator != null, "Decorator shoundn't be null"); bool shouldUpdateColumns = this.CellEditorsController.GenerateCellsForRow(rowDecorator, rowSlot); if (shouldUpdateColumns) { this.GridView.InvalidateHeadersPanelMeasure(); this.GridView.InvalidateCellsPanelMeasure(); } var desiredHeight = this.CellEditorsController.GetSlotHeight(rowSlot); this.EditRowPool.RenderInfo.Update(rowSlot, desiredHeight); return(desiredHeight); }
double ITable.GenerateCellsForRow(int rowSlot, double largestRowElementHeight, IItemInfoNode rowDecorator) { if (this.isInEditMode && rowDecorator == this.EditRow || rowDecorator == this.FrozenEditRow) { return(this.GenerateCellsForEditRow(rowSlot, largestRowElementHeight, rowDecorator)); } else { var height = this.GenerateCellsForReadOnlyRow(rowSlot, largestRowElementHeight, rowDecorator); this.UpdateReadOnlyRowOpacity(rowDecorator); return(height); } }
private double GenerateCellsForReadOnlyRow(int rowSlot, double largestRowElementWidth, IItemInfoNode rowDecorator) { this.CellsController.UpdateSlotHeight(rowSlot, 0, this.HasExpandedRowDetails(rowSlot)); Debug.Assert(rowDecorator != null, "Decorator shoundn't be null"); bool shouldUpdateColumns = this.CellsController.GenerateCellsForRow(rowDecorator, rowSlot); if (shouldUpdateColumns) { this.GridView.InvalidateHeadersPanelMeasure(); this.GridView.InvalidateCellsPanelMeasure(); } var desiredHeight = this.CellsController.GetSlotHeight(rowSlot); var maxHeight = Math.Max(desiredHeight, largestRowElementWidth); this.rowLayout.RenderInfo.Update(rowSlot, maxHeight); return(desiredHeight); }