GetCell() public method

public GetCell ( int rowIndex ) : GridCell
rowIndex int
return GridCell
Ejemplo n.º 1
0
        static void SetLeftAndPerformArrange(GridColumn col, int left)
        {
            int prevWidth = col.Width;

            if (!col.HasCustomSize)
            {
                col.Width = col.CalculatedWidth;
            }
            col.Left = left;
            int j  = col.CellCount;
            int dW = col.Width;

            for (int i = 0; i < j; ++i)
            {
                var content = col.GetCell(i).ContentElement as RenderElement;
                if (content != null)
                {
                    //RenderElement.DirectSetVisualElementWidth(content, dW);
                    //if (content.IsVisualContainerBase)
                    //{

                    //    ArtVisualContainerBase vscont = (ArtVisualContainerBase)content;
                    //    vscont.InvalidateContentArrangementFromContainerSizeChanged();
                    //    vscont.TopDownReArrangeContentIfNeed(vinv);
                    //}
                }
            }
        }
Ejemplo n.º 2
0
        static void ReCalculateColumnSize(GridColumn col)
        {
            int j = col.CellCount;

            if (j > 0)
            {
                col.DesiredHeight = 0;
                bool firstFoundContentCell = false;
                int  local_desired_width   = 0;
                for (int i = 0; i < j; i++)
                {
                    GridCell cell = col.GetCell(i);
                    ReCalculateContentSize(cell);

                    int cellDesiredWidth  = col.Width;
                    int cellDesiredHeight = cell.Height;

                    var content = cell.ContentElement as RenderElement;
                    if (content != null)
                    {
                        if (content.Width > cellDesiredWidth)
                        {
                            cellDesiredWidth = content.Width;
                        }
                        if (content.Height > cellDesiredHeight)
                        {
                            cellDesiredHeight = content.Height;
                        }
                    }

                    col.DesiredHeight += cellDesiredHeight;

                    if (!firstFoundContentCell)
                    {
                        firstFoundContentCell = cell.HasContent;
                    }
                    if (cellDesiredWidth > local_desired_width)
                    {
                        if (firstFoundContentCell)
                        {
                            if (cell.HasContent)
                            {
                                local_desired_width = cellDesiredWidth;
                            }
                        }
                        else
                        {
                            local_desired_width = cellDesiredWidth;
                        }
                    }
                }
                col.CalculatedWidth = local_desired_width;
            }
            else
            {
                col.CalculatedWidth = col.Width;
            }
        }
Ejemplo n.º 3
0
        public void UpdateParentLink(GridViewRenderBox gridViewRenderE)
        {
            int rowCount = _gridRows.Count;
            int colCount = _gridCols.Count;

            for (int c = 0; c < colCount; ++c)
            {
                GridColumn col = _gridCols.GetColumn(c);
                for (int r = 0; r < rowCount; ++r)
                {
                    GridCell      gridCell       = col.GetCell(r);
                    RenderElement contentRenderE = col.GetCell(r).ContentElement;

#if DEBUG
                    if (contentRenderE.MyParentLink != null)
                    {
                        throw new NotSupportedException();
                    }
#endif
                    RenderElement.SetParentLink(contentRenderE, gridViewRenderE);
                }
            }
        }
Ejemplo n.º 4
0
        public GridCell GetNeighborGrid(CellNeighbor nb)
        {
            switch (nb)
            {
            case CellNeighbor.Left:
            {
                GridColumn prevColumn = column.PrevColumn;
                if (prevColumn != null)
                {
                    return(prevColumn.GetCell(row.RowIndex));
                }
                else
                {
                    return(null);
                }
            }

            case CellNeighbor.Right:
            {
                GridColumn nextColumn = column.NextColumn;
                if (nextColumn != null)
                {
                    return(nextColumn.GetCell(row.RowIndex));
                }
                else
                {
                    return(null);
                }
            }

            case CellNeighbor.Up:
            {
                if (row.RowIndex > 0)
                {
                    return(column.GetCell(row.RowIndex - 1));
                }
                else
                {
                    return(null);
                }
            }

            case CellNeighbor.Down:
            {
                if (row.RowIndex < row.OwnerGridRowCount - 1)
                {
                    return(column.GetCell(row.RowIndex + 1));
                }
                else
                {
                    return(null);
                }
            }

            default:
            {
#if DEBUG
                throw new NotSupportedException();
#else
                return(null);
#endif
            }
            }
        }
Ejemplo n.º 5
0
        //
        public GridCell GetCellByPosition(int x, int y)
        {
            if (y < 0)
            {
                y = 0;
            }
            if (x < 0)
            {
                x = 0;
            }

            switch (_cellSizeStyle)
            {
            case CellSizeStyle.UniformWidth:
            {
                var     cell0     = this.GetCell(0, 0);
                var     cellWidth = cell0.Width;
                GridRow row       = _gridRows.GetRowAtPos(y);
                if (row != null)
                {
                    int columnNumber = x / cellWidth;
                    if (columnNumber >= _gridCols.Count)
                    {
                        columnNumber = _gridCols.Count - 1;
                    }

                    GridColumn column = _gridCols[columnNumber];
                    if (column == null)
                    {
                        column = _gridCols.Last;
                    }
                    if (column != null)
                    {
                        return(column.GetCell(row.RowIndex));
                    }
                }
            }
            break;

            case CellSizeStyle.UniformHeight:
            {
                var cell0      = this.GetCell(0, 0);
                var cellHeight = cell0.Height;
                int rowNumber  = y / cellHeight;
                if (rowNumber >= _gridRows.Count)
                {
                    rowNumber = _gridRows.Count - 1;
                }
                GridRow row = _gridRows[rowNumber];
                if (row != null)
                {
                    GridColumn column = _gridCols.GetColumnAtPosition(x);
                    if (column == null)
                    {
                        column = _gridCols.Last;
                    }
                    if (column != null)
                    {
                        return(column.GetCell(row.RowIndex));
                    }
                }
            }
            break;

            case CellSizeStyle.UniformCell:
            {
                //find cell height
                var cell0      = this.GetCell(0, 0);
                var cellWidth  = cell0.Width;
                var cellHeight = cell0.Height;
                int rowNumber  = y / cellHeight;
                if (rowNumber >= _gridRows.Count)
                {
                    rowNumber = _gridRows.Count - 1;
                }

                GridRow row = _gridRows[rowNumber];
                if (row != null)
                {
                    int columnNumber = x / cellWidth;
                    if (columnNumber >= _gridCols.Count)
                    {
                        columnNumber = _gridCols.Count - 1;
                    }
                    GridColumn column = _gridCols[columnNumber];
                    if (column == null)
                    {
                        column = _gridCols.Last;
                    }
                    if (column != null)
                    {
                        return(column.GetCell(row.RowIndex));
                    }
                }
            }
            break;

            default:
            {
                GridRow row = _gridRows.GetRowAtPos(y);
                if (row == null)
                {
                    row = _gridRows.Last;
                }
                if (row != null)
                {
                    GridColumn column = _gridCols.GetColumnAtPosition(x);
                    if (column == null)
                    {
                        column = _gridCols.Last;
                    }
                    if (column != null)
                    {
                        return(column.GetCell(row.RowIndex));
                    }
                }
            }
            break;
            }
            return(null);
        }
Ejemplo n.º 6
0
        public override void DrawChildContent(Canvas canvas, Rectangle updateArea)
        {
            //GridCell leftTopGridItem = GetGridItemByPosition(updateArea.Left, updateArea.Top);
            //if (leftTopGridItem == null)
            //{
            //    return;

            //}
            //GridCell rightBottomGridItem = GetGridItemByPosition(updateArea.Right, updateArea.Bottom);
            //if (rightBottomGridItem == null)
            //{
            //    return;
            //}


            //TODO: temp fixed, review here again,
            GridCell leftTopGridItem = this.GetCell(0, 0);

            if (leftTopGridItem == null)
            {
                return;
            }
            GridCell rightBottomGridItem = this.GetCell(this.RowCount - 1, this.ColumnCount - 1);

            if (rightBottomGridItem == null)
            {
                return;
            }
            this.BeginDrawingChildContent();

            GridColumn startColumn   = leftTopGridItem.column;
            GridColumn currentColumn = startColumn;
            GridRow    startRow      = leftTopGridItem.row;
            GridColumn stopColumn    = rightBottomGridItem.column.NextColumn;
            GridRow    stopRow       = rightBottomGridItem.row.NextRow;

            int startRowId = startRow.RowIndex;
            int stopRowId  = 0;

            if (stopRow == null)
            {
                stopRowId = gridRows.Count;
            }
            else
            {
                stopRowId = stopRow.RowIndex;
            }
            int n         = 0;
            var prevColor = canvas.StrokeColor;

            canvas.StrokeColor = Color.Gray;

            //canvas.DrawLine(0, 0, 100, 100);
            //canvas.DrawLine(0, 100, 100, 0);

            //if (startRowId > 0)
            //{
            //    Console.WriteLine(startRowId);
            //}

            //canvas.DrawRectangle(Color.Red, updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height);

            do
            {
                GridCell startGridItemInColumn = currentColumn.GetCell(startRowId);
                GridCell stopGridItemInColumn  = currentColumn.GetCell(stopRowId - 1);

                //draw vertical line
                canvas.DrawLine(
                    startGridItemInColumn.Right,
                    startGridItemInColumn.Y,
                    stopGridItemInColumn.Right,
                    stopGridItemInColumn.Bottom);

                if (n == 0)
                {
                    //draw horizontal line
                    int horizontalLineWidth = rightBottomGridItem.Right - startGridItemInColumn.X;
                    for (int i = startRowId; i < stopRowId; i++)
                    {
                        GridCell gridItem = currentColumn.GetCell(i);
                        int      x        = gridItem.X;
                        int      gBottom  = gridItem.Bottom;
                        canvas.DrawLine(
                            x, gBottom,
                            x + horizontalLineWidth, gBottom);
                    }
                    n = 1;
                }
                currentColumn = currentColumn.NextColumn;
            } while (currentColumn != stopColumn);

            canvas.StrokeColor = prevColor;
            currentColumn      = startColumn;
            //----------------------------------------------------------------------------
            do
            {
                for (int i = startRowId; i < stopRowId; i++)
                {
                    GridCell gridItem = currentColumn.GetCell(i);
                    if (gridItem != null && gridItem.HasContent)
                    {
                        int x = gridItem.X;
                        int y = gridItem.Y;
                        canvas.OffsetCanvasOrigin(x, y);
                        updateArea.Offset(-x, -y);
                        var renderContent = gridItem.ContentElement as RenderElement;
                        if (renderContent != null)
                        {
                            if (canvas.PushClipAreaRect(gridItem.Width, gridItem.Height, ref updateArea))
                            {
                                renderContent.DrawToThisCanvas(canvas, updateArea);
                            }
                            canvas.PopClipAreaRect();
                        }


                        canvas.OffsetCanvasOrigin(-x, -y);
                        updateArea.Offset(x, y);
                    }
#if DEBUG
                    else
                    {
                        canvas.DrawText(new char[] { '.' }, gridItem.X, gridItem.Y);
                    }
#endif
                }

                currentColumn = currentColumn.NextColumn;
            } while (currentColumn != stopColumn);
            this.FinishDrawingChildContent();
        }
Ejemplo n.º 7
0
        static void ReCalculateColumnSize(GridColumn col)
        {
            int j = col.CellCount;
            if (j > 0)
            {
                col.DesiredHeight = 0;
                bool firstFoundContentCell = false;
                int local_desired_width = 0;
                for (int i = 0; i < j; i++)
                {
                    GridCell cell = col.GetCell(i);
                    ReCalculateContentSize(cell);
                    int cellDesiredWidth = col.Width;
                    int cellDesiredHeight = cell.Height;
                    var content = cell.ContentElement as RenderElement;
                    if (content != null)
                    {
                        if (content.Width > cellDesiredWidth)
                        {
                            cellDesiredWidth = content.Width;
                        }
                        if (content.Height > cellDesiredHeight)
                        {
                            cellDesiredHeight = content.Height;
                        }
                    }

                    col.DesiredHeight += cellDesiredHeight;
                    if (!firstFoundContentCell)
                    {
                        firstFoundContentCell = cell.HasContent;
                    }
                    if (cellDesiredWidth > local_desired_width)
                    {
                        if (firstFoundContentCell)
                        {
                            if (cell.HasContent)
                            {
                                local_desired_width = cellDesiredWidth;
                            }
                        }
                        else
                        {
                            local_desired_width = cellDesiredWidth;
                        }
                    }
                }
                col.CalculatedWidth = local_desired_width;
            }
            else
            {
                col.CalculatedWidth = col.Width;
            }
        }
Ejemplo n.º 8
0
        static void SetLeftAndPerformArrange(GridColumn col, int left)
        {
            int prevWidth = col.Width;
            if (!col.HasCustomSize)
            {
                col.Width = col.CalculatedWidth;
            }
            col.Left = left;
            int j = col.CellCount;
            int dW = col.Width;
            for (int i = 0; i < j; ++i)
            {
                var content = col.GetCell(i).ContentElement as RenderElement;
                if (content != null)
                {
                    //RenderElement.DirectSetVisualElementWidth(content, dW);
                    //if (content.IsVisualContainerBase)
                    //{

                    //    ArtVisualContainerBase vscont = (ArtVisualContainerBase)content;
                    //    vscont.InvalidateContentArrangementFromContainerSizeChanged();
                    //    vscont.TopDownReArrangeContentIfNeed(vinv);
                    //} 
                }
            }
        }