// ======================================== // constructor // ======================================== public MemoTableRuledLineHandle(Func <TableFigure> tableFigureProvider) { _tableFigureProvider = tableFigureProvider; _figure = new Lazy <MemoTableRuledLineHandleFigure>( () => new MemoTableRuledLineHandleFigure(tableFigureProvider) ); _changeRowHeightRequest = new ChangeRowHeightRequest(); _changeColumnWidthRequest = new ChangeColumnWidthRequest(); _dragStartPoint = Point.Empty; _lineIndex = 0; _isVertical = false; _selectScenario = new SelectScenario(this); }
public static void AdjustColumnSize(IEditor tableEditor, TableFigure tableFig, int colIndex) { if (tableEditor == null || tableFig == null) { return; } if (colIndex < 0 || colIndex >= tableFig.TableData.ColumnCount) { throw new ArgumentException("colIndex"); } var col = tableFig.TableData.Columns.ElementAt(colIndex); var width = col.Cells.Where(cell => !(cell.IsMerging && cell.ColumnSpan != 1) && !cell.IsMerged).Max(cell => cell.Value.StyledTextBounds.Width); var req = new ChangeColumnWidthRequest(colIndex, width + tableFig.Padding.Width); tableEditor.PerformRequest(req); }
//public static void AdjustAllColumnSizes(TableFigure tableFig) { // if (tableFig == null) { // return; // } // foreach (var col in tableFig.TableData.Columns) { // var width = col.Cells.Where(cell => !(cell.IsMerging && cell.ColumnSpan != 1) && !cell.IsMerged).Max(cell => cell.Value.StyledTextBounds.Width); // col.Width = width + tableFig.Padding.Width; // } //} public static void AdjustColumnSizesAtEvenInterval(IEditor tableEditor, TableFigure tableFig, int firstColumnIndex, int lastColumnIndex) { if (tableEditor == null || tableFig == null) { return; } if (firstColumnIndex < 0 || lastColumnIndex > tableFig.TableData.ColumnCount - 1 || firstColumnIndex >= lastColumnIndex) { return; } /// calc width var colIndex = 0; var width = 0; foreach (var col in tableFig.TableData.Columns) { if (colIndex >= firstColumnIndex && colIndex <= lastColumnIndex) { width += col.Width; } ++colIndex; } var colCount = lastColumnIndex - firstColumnIndex + 1; var colWidth = width / colCount; var lastColWidth = width - (colWidth * (colCount - 1)); colIndex = 0; foreach (var col in tableFig.TableData.Columns) { if (colIndex >= firstColumnIndex && colIndex <= lastColumnIndex) { var req = new ChangeColumnWidthRequest(colIndex, colIndex == lastColumnIndex ? lastColWidth : colWidth); tableEditor.PerformRequest(req); } ++colIndex; } }