コード例 #1
0
        // ========================================
        // 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);
        }
コード例 #2
0
        public static void AdjustRowSize(IEditor tableEditor, TableFigure tableFig, int rowIndex)
        {
            if (tableEditor == null || tableFig == null)
            {
                return;
            }

            if (rowIndex < 0 || rowIndex >= tableFig.TableData.RowCount)
            {
                throw new ArgumentException("rowIndex");
            }

            var row    = tableFig.TableData.Rows.ElementAt(rowIndex);
            var height = row.Cells.Where(cell => !(cell.IsMerging && cell.RowSpan != 1) && !cell.IsMerged).Max(cell => cell.Value.StyledTextBounds.Height);
            var req    = new ChangeRowHeightRequest(rowIndex, height + tableFig.Padding.Height);

            tableEditor.PerformRequest(req);
        }
コード例 #3
0
        //public static void AdjustAllRowSizes(TableFigure tableFig) {
        //    if (tableFig == null) {
        //        return;
        //    }

        //    foreach (var row in tableFig.TableData.Rows) {
        //        var height = row.Cells.Where(cell => !(cell.IsMerging && cell.RowSpan != 1) && !cell.IsMerged).Max(cell => cell.Value.StyledTextBounds.Height);
        //        row.Height = height + tableFig.Padding.Height;
        //    }
        //}

        public static void AdjustRowSizesAtEvenInterval(IEditor tableEditor, TableFigure tableFig, int firstRowIndex, int lastRowIndex)
        {
            if (tableEditor == null || tableFig == null)
            {
                return;
            }

            if (firstRowIndex < 0 || lastRowIndex > tableFig.TableData.RowCount - 1 || firstRowIndex >= lastRowIndex)
            {
                return;
            }

            /// calc height
            var rowIndex = 0;
            var height   = 0;

            foreach (var row in tableFig.TableData.Rows)
            {
                if (rowIndex >= firstRowIndex && rowIndex <= lastRowIndex)
                {
                    height += row.Height;
                }
                ++rowIndex;
            }

            var rowCount      = lastRowIndex - firstRowIndex + 1;
            var rowHeight     = height / rowCount;
            var lastRowHeight = height - (rowHeight * (rowCount - 1));

            rowIndex = 0;
            foreach (var row in tableFig.TableData.Rows)
            {
                if (rowIndex >= firstRowIndex && rowIndex <= lastRowIndex)
                {
                    var req = new ChangeRowHeightRequest(rowIndex, rowIndex == lastRowIndex ? lastRowHeight : rowHeight);
                    tableEditor.PerformRequest(req);
                }
                ++rowIndex;
            }
        }