예제 #1
0
파일: RowItem.cs 프로젝트: Daoting/dt
        CellRange ClipCellRange(CellRange source)
        {
            RowLayoutModel    rowLayoutModel    = OwnPanel.GetRowLayoutModel();
            ColumnLayoutModel columnLayoutModel = GetColumnLayoutModel();
            ICellsSupport     dataContext       = OwnPanel.GetDataContext();
            int row    = Math.Max(rowLayoutModel[0].Row, source.Row);
            int num2   = Math.Min(rowLayoutModel[rowLayoutModel.Count - 1].Row, (source.Row + source.RowCount) - 1);
            int column = Math.Max(columnLayoutModel[0].Column, source.Column);
            int num4   = Math.Min(columnLayoutModel[columnLayoutModel.Count - 1].Column, (source.Column + source.ColumnCount) - 1);

            for (int i = row; i <= num2; i++)
            {
                if (dataContext.Rows[i].ActualHeight > 0.0)
                {
                    row = i;
                    break;
                }
            }
            for (int j = column; j <= num4; j++)
            {
                if (dataContext.Columns[j].ActualWidth > 0.0)
                {
                    column = j;
                    break;
                }
            }
            return(new CellRange(row, column, (num2 - row) + 1, (num4 - column) + 1));
        }
예제 #2
0
        CellOverflowLayout BuildTrailingCellOverflowLayoutModel(int rowIndex, ColumnLayoutModel columnLayoutModel, CellOverflowLayoutModel existed, object textFormattingMode, bool useLayoutRounding)
        {
            ColumnLayout layout = Enumerable.LastOrDefault <ColumnLayout>(columnLayoutModel, delegate(ColumnLayout clm)
            {
                return(clm.Width > 0.0);
            });

            if (layout == null)
            {
                if (columnLayoutModel.Count == 0)
                {
                    return(null);
                }
                layout = columnLayoutModel[0];
            }
            if (!existed.Contains(layout.Column))
            {
                CellOverflowLayout layout2     = new CellOverflowLayout(layout.Column, 0.0);
                ICellsSupport      dataContext = Viewport.GetDataContext();
                SheetSpanModelBase spanModel   = Viewport.GetSpanModel();
                for (int i = 1; i < _maxCellOverflowDistance; i++)
                {
                    int column = layout.Column + i;
                    if (column >= dataContext.Columns.Count)
                    {
                        return(null);
                    }
                    if (dataContext.Columns[column].ActualWidth > 0.0)
                    {
                        if ((spanModel != null) && (spanModel.Find(rowIndex, column) != null))
                        {
                            return(null);
                        }
                        Cell cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, column);
                        if (!string.IsNullOrEmpty(cachedCell.Text))
                        {
                            if (cachedCell.ActualWordWrap)
                            {
                                return(null);
                            }
                            if (cachedCell.ActualShrinkToFit)
                            {
                                return(null);
                            }
                            switch (cachedCell.ToHorizontalAlignment())
                            {
                            case HorizontalAlignment.Left:
                            case HorizontalAlignment.Stretch:
                                return(null);

                            case HorizontalAlignment.Center:
                            {
                                int deadColumnIndex = columnLayoutModel[0].Column - 1;
                                layout2 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, existed, true, deadColumnIndex, textFormattingMode, useLayoutRounding);
                                if ((layout2 == null) || (layout2.StartingColumn > ViewportRightColumn))
                                {
                                    return(null);
                                }
                                layout2.BackgroundWidth += (dataContext.Columns[column].ActualWidth * Viewport.Excel.ZoomFactor) / 2.0;
                                return(layout2);
                            }

                            case HorizontalAlignment.Right:
                            {
                                int num5 = columnLayoutModel[0].Column - 1;
                                layout2 = BuildCellOverflowLayoutModelForRight(cachedCell, rowIndex, existed, false, num5, textFormattingMode, useLayoutRounding);
                                if ((layout2 == null) || (layout2.StartingColumn > ViewportRightColumn))
                                {
                                    return(null);
                                }
                                return(layout2);
                            }
                            }
                            break;
                        }
                    }
                }
            }
            return(null);
        }
예제 #3
0
 public CellCachePool(ICellsSupport p_cellsSupport)
 {
     _cellsSupport = p_cellsSupport;
 }
예제 #4
0
        CellOverflowLayout BuildCellOverflowLayoutModelForRight(Cell bindingCell, int rowIndex, CellOverflowLayoutModel result, bool buildForCenter, int deadColumnIndex, object textFormattingMode, bool useLayoutRounding)
        {
            ICellsSupport dataContext = Viewport.GetDataContext();
            int           index       = bindingCell.Column.Index;

            if (index > deadColumnIndex)
            {
                Column          column          = dataContext.Columns[index];
                CellLayoutModel cellLayoutModel = Viewport.GetCellLayoutModel();
                Column          column2         = dataContext.Columns[index - 1];
                int             num2            = column2.Index;
                if ((cellLayoutModel != null) && (cellLayoutModel.FindCell(rowIndex, num2) != null))
                {
                    return(null);
                }
                Cell cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, num2);
                if ((cachedCell != null) && !string.IsNullOrEmpty(cachedCell.Text))
                {
                    return(null);
                }
                float  zoomFactor = Viewport.Excel.ZoomFactor;
                Size   textSize   = MeasureHelper.MeasureTextInCell(bindingCell, new Size(double.PositiveInfinity, double.PositiveInfinity), (double)zoomFactor, null, textFormattingMode, useLayoutRounding);
                double width      = MeasureHelper.ConvertTextSizeToExcelCellSize(textSize, (double)zoomFactor).Width;
                double num5       = column.ActualWidth * zoomFactor;
                if (buildForCenter)
                {
                    width /= 2.0;
                    num5  /= 2.0;
                }
                double num6 = num5;
                if (num6 < width)
                {
                    CellOverflowLayout layout2 = new CellOverflowLayout(column.Index, num6)
                    {
                        StartingColumn = column.Index
                    };
                    for (int i = index - 1; (i >= 0) && (i >= deadColumnIndex); i--)
                    {
                        column2 = dataContext.Columns[i];
                        num2    = column2.Index;
                        if ((cellLayoutModel != null) && (cellLayoutModel.FindCell(rowIndex, num2) != null))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        if (((cachedCell != null) && (result != null)) && result.Contains(column2.Index))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        cachedCell = Viewport.CellCache.GetCachedCell(rowIndex, num2);
                        if ((cachedCell != null) && !string.IsNullOrEmpty(cachedCell.Text))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = dataContext.Columns[i + 1].Index;
                            break;
                        }
                        num6 += column2.ActualWidth * zoomFactor;
                        if (((num6 >= width) || (i == 0)) || (i <= deadColumnIndex))
                        {
                            layout2.BackgroundWidth = num6;
                            layout2.StartingColumn  = column2.Index;
                            break;
                        }
                    }
                    if (layout2.StartingColumn != column.Index)
                    {
                        layout2.ContentWidth        = MeasureHelper.ConvertTextSizeToExcelCellSize(textSize, (double)zoomFactor).Width;
                        layout2.LeftBackgroundWidth = num6;
                        return(layout2);
                    }
                }
            }
            return(null);
        }