public override SizeF GetElementSize(GridViewColumn item) { float width = (float)item.Width; if (item is GridViewRowHeaderColumn) { width = (float)this.rowView.RowHeaderColumnWidth; } else if (item is GridViewIndentColumn) { width = (float)this.rowView.GroupIndent; } if ((double)width < 0.0) { width = this.DefaultElementSize.Width; } if (item is GridViewGroupColumn) { ColumnGroupRowLayout rowLayout = this.rowView.ViewElement.RowLayout as ColumnGroupRowLayout; if (rowLayout != null) { ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData(item); if (columnData != null) { width = columnData.Bounds.Width; } } } return(new SizeF(width, 0.0f)); }
protected virtual Size GetRowSize(GridViewRowInfo row, ColumnGroupRowLayout rowLayout) { if (this.rowSize == Size.Empty) { int width1 = 0; int height = rowLayout.GetRowHeight(row) + this.GridView.TableElement.RowSpacing; foreach (GridViewColumn renderColumn in (IEnumerable <GridViewColumn>)rowLayout.RenderColumns) { if (!(renderColumn is GridViewRowHeaderColumn) && !(renderColumn is GridViewIndentColumn)) { ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData(renderColumn); if (columnData != null) { int width2 = (int)columnData.Bounds.Width; if ((double)width1 < (double)columnData.Bounds.X + (double)width2) { width1 = (int)columnData.Bounds.X + width2; } } } } this.rowSize = new Size(width1, height); } return(this.rowSize); }
private void BestFitGroupColumn( GridViewGroupColumn column, bool bestFitChildColumns, BestFitColumnMode?mode) { GridTableHeaderRowElement headerRowElement = this.GetHeaderRowElement(); IVirtualizedElementProvider <GridViewColumn> elementProvider = this.tableElement.ColumnScroller.ElementProvider; ColumnGroupRowLayout rowLayout = this.tableElement.ViewElement.RowLayout as ColumnGroupRowLayout; if (rowLayout == null || headerRowElement == null) { return; } GridColumnGroupCellElement element = elementProvider.GetElement((GridViewColumn)column, (object)headerRowElement) as GridColumnGroupCellElement; if (element == null || !element.CanBestFit(column.AutoSizeMode)) { return; } float num = this.MeasureCell((GridRowElement)headerRowElement, (GridViewColumn)column, element); this.Detach(elementProvider, (GridCellElement)element); ColumnGroupsCellArrangeInfo columnData = rowLayout.GetColumnData((GridViewColumn)column); if ((double)columnData.Bounds.Width < (double)num) { rowLayout.StartColumnResize((GridViewColumn)column); rowLayout.ResizeColumn((int)((double)num - (double)columnData.Bounds.Width)); rowLayout.InvalidateLayout(); this.TableElement.ViewElement.InvalidateMeasure(true); this.TableElement.ViewElement.UpdateLayout(); rowLayout.EndColumnResize(); } if (!bestFitChildColumns) { return; } foreach (GridViewColumn dataColumn in this.GetDataColumns(column.Group)) { this.BestFitColumnCore(dataColumn, mode.HasValue ? mode.Value : column.AutoSizeMode); } }
protected virtual void BestFitColumnsCore(BestFitColumnMode?mode) { BestFitColumnMode?nullable = mode; if ((nullable.GetValueOrDefault() != BestFitColumnMode.None ? 0 : (nullable.HasValue ? 1 : 0)) != 0) { return; } List <GridViewDataColumn> columns = new List <GridViewDataColumn>((IEnumerable <GridViewDataColumn>) this.tableElement.ViewTemplate.Columns); ColumnGroupRowLayout groupLayout = this.TableElement.ViewElement.RowLayout as ColumnGroupRowLayout; if (groupLayout != null) { columns.Sort((Comparison <GridViewDataColumn>)((A, B) => { ColumnGroupsCellArrangeInfo columnData1 = groupLayout.GetColumnData((GridViewColumn)A); ColumnGroupsCellArrangeInfo columnData2 = groupLayout.GetColumnData((GridViewColumn)B); if (columnData1 == columnData2) { return(0); } if (columnData1 == null) { return(-1); } if (columnData2 == null) { return(1); } int num1 = columnData1.Group.Rows.IndexOf(columnData1.Row); int num2 = columnData2.Group.Rows.IndexOf(columnData2.Row); if (columnData1.Group != columnData2.Group) { return(columnData1.Bounds.X.CompareTo(columnData2.Bounds.X)); } if (num1 != num2) { return(num1.CompareTo(num2)); } return(columnData1.Bounds.X.CompareTo(columnData2.Bounds.X)); })); } float[] numArray = new float[this.tableElement.ViewTemplate.ColumnCount]; int index1 = -1; if (mode.HasValue && mode.Value == BestFitColumnMode.AllCells) { numArray = this.CalculateColumnWidths(columns); } else { foreach (GridViewColumn column in columns) { if (!(column is GridViewGroupColumn)) { ++index1; BestFitColumnMode mode1 = mode.HasValue ? mode.Value : column.AutoSizeMode; if (column.IsVisible && mode1 != BestFitColumnMode.None) { float columnWidth = this.CalculateColumnWidth(column, mode1); float val1 = numArray[index1]; numArray[index1] = Math.Max(val1, columnWidth); } } } } for (int index2 = 0; index2 < numArray.Length; ++index2) { GridViewColumn column = (GridViewColumn)columns[index2]; if (column != null && column.IsVisible && column.AutoSizeMode != BestFitColumnMode.None && ((!column.IsGrouped || column.OwnerTemplate.ShowGroupedColumns) && column.CanStretch)) { this.SetColumnWidth(column, numArray[index2]); } } if (this.tableElement.ViewTemplate.AutoSizeColumnsMode == GridViewAutoSizeColumnsMode.Fill) { return; } this.BestFitGroupColumns(mode); }