示例#1
0
        public bool GetScrollPositionToShowCell(Position position, List <int> visibleColumns, List <int> visibleRows, out Point newScrollPosition)
        {
            CellPositionType posType          = m_Grid.GetPositionType(position);
            Rectangle        displayRectangle = m_Grid.DisplayRectangle;

            bool isFixedLeft = posType == CellPositionType.FixedLeft || posType == CellPositionType.FixedTopLeft;
            int  x;

            if (visibleColumns.Contains(position.Column)) //Is x visible
            {
                x = m_Grid.CustomScrollPosition.X;
            }
            else
            {
                if (isFixedLeft)
                {
                    x = 0;
                }
                else
                {
                    x = position.Column - m_Grid.ActualFixedColumns;
                }

                //Check if the scrollable positioin if not outside the valid area
                int maxX = m_Grid.GetScrollColumns(displayRectangle.Width);
                if (x > maxX)
                {
                    x = maxX;
                }
            }

            bool isFixedTop = posType == CellPositionType.FixedTop || posType == CellPositionType.FixedTopLeft;
            int  y;

            if (visibleRows.Contains(position.Row)) //Is y visible
            {
                y = m_Grid.CustomScrollPosition.Y;
                //[email protected]:CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right
                //y = m_Grid.ExtendTopRowByHiddenRows(y);
            }
            else
            {
                //MICK(15): add direction dependent procedure of finding y (and x should be too).
                //It means that when you go from bottom to top, the selected item will be at top,
                //              (this already happens, so this part is not changed)
                //              when you go from top to bottom, the selected item will be at bottom,
                // y (and x) value is adjusted accordingly
                if (m_Grid.CustomScrollPosition.Y + m_Grid.ActualFixedRows > position.Row)
                {
                    //MICK(16): direction bottom to top
                    if (isFixedTop)
                    {
                        y = 0;
                    }
                    else
                    {
                        y = position.Row - m_Grid.FixedRows;
                    }

                    //Check if the scrollable positioin if not outside the valid area
                    int maxY = m_Grid.GetScrollRows(displayRectangle.Height);
                    if (y > maxY)
                    {
                        y = maxY;
                    }
                    //[email protected]:CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right
                    //MICK(21)
                    //y = m_Grid.ExtendTopRowByHiddenRows(y);
                }
                else
                {
                    //MICK(17): direction from top to bottom
                    y = m_Grid.GetTopVisibleRowFromBottomRow(position.Row) - m_Grid.ActualFixedRows;
                    //[email protected]: CHDOC00123837: it works as expected without changing y value. the calculation in this method doesn't seem right
                    //y = m_Grid.ExtendTopRowByHiddenRows(y);
                }
            }

            newScrollPosition = new Point(x, y);

            return(true);
        }