Esempio n. 1
0
        internal CellItem GetViewportCell(int row, int column, bool containsSpan)
        {
            CellItem cell      = null;
            RowItem  presenter = _rowsLayer.GetRow(row);

            if (presenter != null)
            {
                cell = presenter.GetCell(column);
            }
            if (containsSpan && (cell == null))
            {
                foreach (RowItem presenter2 in _rowsLayer.Rows)
                {
                    if (presenter2 != null)
                    {
                        foreach (CellItem base3 in presenter2.Cells.Values)
                        {
                            if (((base3 != null) && (base3.CellLayout != null)) && ((base3.CellLayout.Row == row) && (base3.CellLayout.Column == column)))
                            {
                                return(base3);
                            }
                        }
                    }
                }
            }
            return(cell);
        }
Esempio n. 2
0
 public CellItem(RowItem p_rowItem)
 {
     OwnRow = p_rowItem;
     Column = -1;
     _tb    = new TextBlock {
         VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis
     };
     Children.Add(_tb);
 }
Esempio n. 3
0
        protected override Size MeasureOverride(Size availableSize)
        {
            if (_owner.Excel.CanCellOverflow)
            {
                int viewportLeftColumn = _owner.Excel.GetViewportLeftColumn(_owner.ColumnViewportIndex);
                _owner.CellOverflowLayoutBuildEngine.ViewportLeftColumn = viewportLeftColumn;
                int viewportRightColumn = _owner.Excel.GetViewportRightColumn(_owner.ColumnViewportIndex);
                _owner.CellOverflowLayoutBuildEngine.ViewportRightColumn = viewportRightColumn;
            }

            // 频繁增删Children子元素会出现卡顿现象!
            // Children = _rows + _recycledRows
            RowLayoutModel rowLayoutModel = _owner.GetRowLayoutModel();
            int            less           = rowLayoutModel.Count - Children.Count;

            if (less > 0)
            {
                for (int i = 0; i < less; i++)
                {
                    RowItem rowItem = new RowItem(_owner);
                    Children.Add(rowItem);
                    _recycledRows.Add(rowItem);
                }
            }

            // 先回收不可见行
            List <RowItem> rows = _rows.Values.ToList();

            foreach (var rowItem in rows)
            {
                RowLayout layout = rowLayoutModel.FindRow(rowItem.Row);
                if (layout == null || layout.Height <= 0.0)
                {
                    _recycledRows.Add(rowItem);
                    _rows.Remove(rowItem.Row);
                    rowItem.Row = -1;
                    rowItem.CleanUpBeforeDiscard();
                }
            }

            double y    = _owner.Location.Y;
            double left = 0.0;

            foreach (RowLayout layout in rowLayoutModel)
            {
                if (layout.Height <= 0.0)
                {
                    continue;
                }

                bool    updateAllCell = false;
                RowItem rowItem       = null;
                if (!_rows.TryGetValue(layout.Row, out rowItem))
                {
                    // 重新利用回收的行
                    rowItem = _recycledRows[0];
                    _recycledRows.RemoveAt(0);
                    rowItem.Row = layout.Row;
                    _rows.Add(layout.Row, rowItem);
                    updateAllCell = true;
                }
                rowItem.Location = new Point(_owner.Location.X, y);
                rowItem.UpdateChildren(updateAllCell);

                int z = rowItem.ContainsSpanCell ? _spanRowZIndexBase + rowItem.Row : _normalZIndexBase + rowItem.Row;
                z = z % 0x7ffe;
                Canvas.SetZIndex(rowItem, z);

                // 测量尺寸足够大,否则当单元格占多行时在uno上只绘一行!
                rowItem.Measure(availableSize);
                y   += layout.Height;
                left = Math.Max(left, rowItem.DesiredSize.Width);
            }

            // 测量回收的行
            if (_recycledRows.Count > 0)
            {
                foreach (var rowItem in _recycledRows)
                {
                    rowItem.Measure(_szEmpty);
                }
            }
            return(new Size(left + _owner.Location.X, y));
        }