Esempio n. 1
0
 public override void BringCellToVisible(TabularPosition position)
 {
     if ((!position.IsEmpty && (position.Area == SheetArea.Cells)) && (_excel.ActiveSheet != null))
     {
         NavigatorHelper.BringCellToVisible(_excel, position.Row, position.Column);
     }
 }
Esempio n. 2
0
 public override void BringCellToVisible(CompositePosition position)
 {
     if ((!position.IsEmpty && (position.Type == DataSheetElementType.Cell)) && (_excel.ActiveSheet != null))
     {
         NavigatorHelper.BringCellToVisible(_excel, position.Row, position.Column);
     }
 }
Esempio n. 3
0
        CellRange KeyboardThroughSelect(CellRange currentRange, NavigationDirection direction)
        {
            int       row         = (currentRange.Row < 0) ? 0 : currentRange.Row;
            int       column      = (currentRange.Column < 0) ? 0 : currentRange.Column;
            int       rowCount    = (currentRange.Row < 0) ? _excel.ActiveSheet.RowCount : currentRange.RowCount;
            int       columnCount = (currentRange.Column < 0) ? _excel.ActiveSheet.ColumnCount : currentRange.ColumnCount;
            CellRange activeCell  = GetActiveCell();
            CellRange range2      = null;

            if (direction == NavigationDirection.Home)
            {
                range2 = new CellRange(row, 0, rowCount, activeCell.Column + activeCell.ColumnCount);
            }
            else if (direction == NavigationDirection.End)
            {
                range2 = new CellRange(row, activeCell.Column, rowCount, _excel.ActiveSheet.ColumnCount - activeCell.Column);
            }
            else if (direction == NavigationDirection.Top)
            {
                range2 = new CellRange(0, column, activeCell.Row + activeCell.RowCount, columnCount);
            }
            else if (direction == NavigationDirection.Bottom)
            {
                range2 = new CellRange(activeCell.Row, column, _excel.ActiveSheet.RowCount - activeCell.Row, columnCount);
            }
            else if (direction == NavigationDirection.First)
            {
                range2 = new CellRange(_excel.ActiveSheet.FrozenRowCount, _excel.ActiveSheet.FrozenColumnCount, (activeCell.Row + activeCell.RowCount) - _excel.ActiveSheet.FrozenRowCount, (activeCell.Column + activeCell.ColumnCount) - _excel.ActiveSheet.FrozenColumnCount);
            }
            else if (direction == NavigationDirection.Last)
            {
                range2 = new CellRange(activeCell.Row, activeCell.Column, (_excel.ActiveSheet.RowCount - _excel.ActiveSheet.FrozenTrailingRowCount) - activeCell.Row, (_excel.ActiveSheet.ColumnCount - _excel.ActiveSheet.FrozenTrailingColumnCount) - activeCell.Column);
            }
            if (range2 != null)
            {
                int viewCellRow    = range2.Row;
                int num6           = (range2.Row + range2.RowCount) - 1;
                int viewCellColumn = range2.Column;
                int num8           = (range2.Column + range2.ColumnCount) - 1;
                if ((direction == NavigationDirection.Top) || (direction == NavigationDirection.First))
                {
                    NavigatorHelper.BringCellToVisible(_excel, viewCellRow, viewCellColumn);
                    return(range2);
                }
                if ((direction == NavigationDirection.Home) || (direction == NavigationDirection.End))
                {
                    int activeRowViewportIndex = _excel.GetActiveRowViewportIndex();
                    int viewportTopRow         = _excel.GetViewportTopRow(activeRowViewportIndex);
                    int viewportBottomRow      = _excel.GetViewportBottomRow(activeRowViewportIndex);
                    if (direction == NavigationDirection.Home)
                    {
                        if (num6 < viewportTopRow)
                        {
                            NavigatorHelper.BringCellToVisible(_excel, row, viewCellColumn);
                            return(range2);
                        }
                        if (viewCellRow > viewportBottomRow)
                        {
                            NavigatorHelper.BringCellToVisible(_excel, num6, viewCellColumn);
                            return(range2);
                        }
                        NavigatorHelper.BringCellToVisible(_excel, viewportTopRow, viewCellColumn);
                        return(range2);
                    }
                    if (num6 < viewportTopRow)
                    {
                        NavigatorHelper.BringCellToVisible(_excel, row, num8);
                        return(range2);
                    }
                    if (viewCellRow > viewportBottomRow)
                    {
                        NavigatorHelper.BringCellToVisible(_excel, num6, num8);
                        return(range2);
                    }
                    NavigatorHelper.BringCellToVisible(_excel, viewportTopRow, num8);
                    return(range2);
                }
                if ((direction == NavigationDirection.Bottom) || (direction == NavigationDirection.Last))
                {
                    NavigatorHelper.BringCellToVisible(_excel, num6, num8);
                }
            }
            return(range2);
        }
Esempio n. 4
0
        CellRange KeyboardLineSelect(CellRange currentRange, NavigationDirection navigationDirection, bool shrink)
        {
            TabularPosition position;
            TabularPosition position2;
            TabularPosition currentCell;
            CellRange       expandIntersectedRange;
            int             row         = (currentRange.Row < 0) ? 0 : currentRange.Row;
            int             column      = (currentRange.Column < 0) ? 0 : currentRange.Column;
            int             rowCount    = (currentRange.Row < 0) ? _excel.ActiveSheet.RowCount : currentRange.RowCount;
            int             columnCount = (currentRange.Column < 0) ? _excel.ActiveSheet.ColumnCount : currentRange.ColumnCount;

            GetAdjustedEdge(row, column, rowCount, columnCount, navigationDirection, shrink, out position, out position2);
            if ((position == TabularPosition.Empty) || (position2 == TabularPosition.Empty))
            {
                return(null);
            }
            _keyboardNavigator.CurrentCell = position2;
            CellRange activeCell = GetActiveCell();

            do
            {
                if (!_keyboardNavigator.MoveCurrent(navigationDirection))
                {
                    return(null);
                }
                currentCell            = _keyboardNavigator.CurrentCell;
                expandIntersectedRange = GetExpandIntersectedRange(TabularPositionUnion(position, currentCell));
                if (!expandIntersectedRange.Contains(activeCell))
                {
                    return(null);
                }
            }while (expandIntersectedRange.Equals(row, column, rowCount, columnCount));
            bool flag                      = true;
            int  viewCellRow               = currentCell.Row;
            int  viewCellColumn            = currentCell.Column;
            int  activeRowViewportIndex    = _excel.GetActiveRowViewportIndex();
            int  activeColumnViewportIndex = _excel.GetActiveColumnViewportIndex();
            int  viewportTopRow            = _excel.GetViewportTopRow(activeRowViewportIndex);
            int  viewportBottomRow         = _excel.GetViewportBottomRow(activeRowViewportIndex);
            int  viewportLeftColumn        = _excel.GetViewportLeftColumn(activeColumnViewportIndex);
            int  viewportRightColumn       = _excel.GetViewportRightColumn(activeColumnViewportIndex);

            if ((navigationDirection == NavigationDirection.Up) || (navigationDirection == NavigationDirection.Down))
            {
                if ((expandIntersectedRange.Column == 0) && (expandIntersectedRange.ColumnCount == _excel.ActiveSheet.ColumnCount))
                {
                    if ((currentCell.Row >= viewportTopRow) && (currentCell.Row < viewportBottomRow))
                    {
                        flag = false;
                    }
                    else
                    {
                        viewCellColumn = viewportLeftColumn;
                    }
                }
            }
            else if (((navigationDirection == NavigationDirection.Left) || (navigationDirection == NavigationDirection.Right)) && ((expandIntersectedRange.Row == 0) && (expandIntersectedRange.RowCount == _excel.ActiveSheet.RowCount)))
            {
                if ((currentCell.Column >= viewportLeftColumn) && (currentCell.Column < viewportRightColumn))
                {
                    flag = false;
                }
                else
                {
                    viewCellRow = viewportTopRow;
                }
            }
            if (flag)
            {
                NavigatorHelper.BringCellToVisible(_excel, viewCellRow, viewCellColumn);
            }
            return(expandIntersectedRange);
        }