示例#1
0
        /// <summary>
        /// Tabs to previous.
        /// </summary>
        /// <param name="spreadsheet">The spreadsheet.</param>
        public static bool TabToPrevious(this SpreadsheetView spreadsheet)
        {
            if (spreadsheet == null)
                return false;

            var navigationInfo = new NavigationInfo(CommandType.TabPrevious);            

            var selectedCells = spreadsheet.GetTopLevelSpreadsheet().GetSelectedCells();
            if (selectedCells == null || !selectedCells.Any())
            {
                navigationInfo = spreadsheet.SelectLast(navigationInfo);
                if (navigationInfo.ActionState == MoveStates.NoItems)
                    return false;
            }
            else
            {
                var firstSelected = selectedCells.First();
                navigationInfo.InitialCell = firstSelected;

                navigationInfo = firstSelected.ProcessSelectionCommand(navigationInfo);
                if (navigationInfo.Command == CommandType.StopNavigation)
                    return false;
            }

            return true;
        }
示例#2
0
        /// <summary>
        /// Selects the cell.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo SelectCell(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (navigationInfo.ActionState == MoveStates.Default && (navigationInfo.Step > 1 ||
                !navigationInfo.CurrentCell.Equals(navigationInfo.InitialCell)))
            {
                if (Column.IsSelectable)
                {
                    switch (navigationInfo.Command)
                    {
                        case CommandType.MoveUp:
                            if (navigationInfo.InitialCell.Column == navigationInfo.CurrentCell.Column)
                                navigationInfo = SelectColumnToMove(navigationInfo, SideDirection.Up);
                            break;
                        case CommandType.MoveDown:
                            navigationInfo = SelectFirst(navigationInfo);
                            break;
                    }

                    if (navigationInfo.ActionState != MoveStates.Ok)
                        navigationInfo = base.SelectCell(navigationInfo);
                }
                else
                    navigationInfo.ActionState = MoveStates.IsNotSelectable;
            }

            return navigationInfo;
        }
示例#3
0
        /// <summary>
        /// Selects the cell.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="index">The index.</param>
        /// <returns>NavigationInfo.</returns>
        private NavigationInfo SelectCell(IWrap item, int index)
        {
            var navigationInfo = new NavigationInfo();

            var ic = GetContainerFromItem(item);
            if (ic != null)
                navigationInfo = ic.SelectByIndex(index);
            else
                navigationInfo.ActionState = MoveStates.Fail;

            return navigationInfo;
        }
        /// <summary>
        /// Jumps to next cell.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        internal NavigationInfo JumpToNextCell(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam;

            if (navigationInfo.Command == CommandType.TabNext)
            {
                switch (navigationInfo.ActionState)
                {                    
                    case MoveStates.Rightmost:
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = SelectFirst(navigationInfo);
                        break;
                    case MoveStates.Lowermost:
                        navigationInfo = Owner.ParentCell.ProcessSelectionCommand(navigationInfo);
                        break;
                    case MoveStates.Bottommost:
                        //navigationInfo.ActionState = MoveStates.Default;
                        //navigationInfo = Owner.GetContainerFromItem(Owner.Items.First() as IWrap).SelectFirst(navigationInfo);
                        navigationInfo = new NavigationInfo(CommandType.StopNavigation);
                        break;
                }                
            }
            else if (navigationInfo.Command == CommandType.TabPrevious)
            {
                switch (navigationInfo.ActionState)
                {
                    case MoveStates.Leftmost:
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = SelectLast(navigationInfo);
                        break;
                    case MoveStates.Uppermost:
                        navigationInfo = Owner.ParentCell.ProcessSelectionCommand(navigationInfo);
                        break;
                    case MoveStates.Topmost:
                        //navigationInfo.ActionState = MoveStates.Default;
                        //navigationInfo = Owner.GetContainerFromItem(Owner.Items.Last() as IWrap).SelectLast(navigationInfo);
                        navigationInfo = new NavigationInfo(CommandType.StopNavigation);
                        break;
                }
            }
            else if (navigationInfo.Command == CommandType.MoveUp)
            {
                switch (navigationInfo.ActionState)
                {
                    case MoveStates.Default:
                        navigationInfo = JumpToColumn(navigationInfo); break;
                    case MoveStates.Uppermost:
                        navigationInfo = Owner.ParentCell.ProcessSelectionCommand(navigationInfo);
                        break;
                    case MoveStates.Topmost:
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = Owner.GetContainerFromItem(Owner.Items.Last() as IWrap).JumpToNextCell(navigationInfo);
                        break;
                }    
            }
            else if (navigationInfo.Command == CommandType.MoveDown)
            {
                switch (navigationInfo.ActionState)
                {
                    case MoveStates.Default:
                        navigationInfo = JumpToColumn(navigationInfo); break;
                    case MoveStates.Lowermost:
                        navigationInfo = Owner.ParentCell.ProcessSelectionCommand(navigationInfo);
                        break;
                    case MoveStates.Bottommost:
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = Owner.GetContainerFromItem(Owner.Items.First() as IWrap).JumpToNextCell(navigationInfo);
                        break;
                }
            }

            return navigationInfo;
        }
示例#5
0
        /// <summary>
        /// Selects the last.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectLast(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (Items.Count == 0)
            {
                navigationInfo.ActionState = MoveStates.NoItems;
                return navigationInfo;
            }

            var container = GetContainerFromItem(Items.Last() as IWrap);
            if (container != null)
                navigationInfo = container.SelectLast(navigationInfo);
            else
                navigationInfo.ActionState = MoveStates.Fail;

            return navigationInfo;
        }
        /// <summary>
        /// Selects the previous.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectPrevious(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            var index = Cells.IndexOf(navigationInfo.CurrentCell);
            if (index > Owner.FirstRowIndex) // Not the first cell in a row
            {
                var newCell = Cells[index - 1];
                navigationInfo = newCell.ProcessSelectionCommand(navigationInfo);
            }
            else // first cell in a row
            {
                navigationInfo.ActionState = MoveStates.Leftmost;
                navigationInfo = navigationInfo.CurrentCell.ProcessSelectionCommand(navigationInfo);
            }

            return navigationInfo;
        }
        /// <summary>
        /// Selects the by column.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectByColumn(IColumn column, NavigationInfo navInfoParam = null)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (!Cells.Any())
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            return SelectByIndex(Owner.Columns.IndexOf(column), navigationInfo);
        }
示例#8
0
        /// <summary>
        /// Selects the last.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo SelectLast(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (ChildSpreadsheet != null && ChildSpreadsheet.IsVisible && !navigationInfo.SelectParents)
                navigationInfo = ChildSpreadsheet.SelectLast(navigationInfo);
            else
                navigationInfo = SelectFirst(navigationInfo);

            return navigationInfo;
        }
示例#9
0
        /// <summary>
        /// Tabs to previous.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo TabToPrevious(NavigationInfo navInfoParam)
        {
            var navigationInfo = base.TabToPrevious(navInfoParam);

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Uppermost:
                    navigationInfo.ActionState = MoveStates.Default;
                    navigationInfo = Container.SelectPrevious(navigationInfo); break;
            }

            return navigationInfo;
        }
示例#10
0
        /// <summary>
        /// Moves down.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo MoveDown(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Default:
                case MoveStates.Lowermost:
                    if (ValuePresenter.IsSelected &&
                        (ChildSpreadsheet != null && ChildSpreadsheet.IsVisible && ChildSpreadsheet.Items.Any()))
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = ChildSpreadsheet.GetContainerFromItem(ChildSpreadsheet.Items.First() as IWrap).JumpToNextCell(navigationInfo);
                    }
                    else
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = Container.SelectNextRowCell(navigationInfo);
                    }
                    break;
                case MoveStates.Bottommost:
                    if (ValuePresenter.IsSelected &&
                        (ChildSpreadsheet != null && ChildSpreadsheet.IsVisible && ChildSpreadsheet.Items.Any()))
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = ChildSpreadsheet.GetContainerFromItem(ChildSpreadsheet.Items.First() as IWrap).JumpToNextCell(navigationInfo);
                    }
                    else
                    {
                        var container = Owner.GetContainerFromItem(Owner.Items.First() as IWrap);
                        if (container != null)
                        {
                            navigationInfo.ActionState = MoveStates.Default;
                            navigationInfo = container.JumpToNextCell(navigationInfo);
                        }
                        else
                            navigationInfo.ActionState = MoveStates.Fail;
                    }
                    break;
            }

            navigationInfo = base.MoveDown(navigationInfo);

            return navigationInfo;
        }
示例#11
0
        /// <summary>
        /// Selects the first.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo SelectFirst(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            navigationInfo = PerformSelection(navigationInfo);

            return navigationInfo;
        }
示例#12
0
        /// <summary>
        /// Moves up.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo MoveUp(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Uppermost:
                    if (ValuePresenter.IsSelected)
                        navigationInfo = Container.SelectPrevRowCell(navigationInfo);
                    else
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = PerformSelection(navigationInfo);
                    }
                    break;
                case MoveStates.Topmost:
                    if (ValuePresenter.IsSelected)
                    {
                        var container = Owner.GetContainerFromItem(Owner.Items.Last() as IWrap);
                        if (container != null)
                        {
                            navigationInfo.ActionState = MoveStates.Default;
                            navigationInfo = container.JumpToNextCell(navigationInfo);
                        }
                        else
                            navigationInfo.ActionState = MoveStates.Fail;
                    }
                    else
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = PerformSelection(navigationInfo);
                    }
                    break;
            }

            navigationInfo = base.MoveUp(navigationInfo);

            return navigationInfo;
        }
示例#13
0
        /// <summary>
        /// Tabs to previous.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo TabToPrevious(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Uppermost:
                    if (!ValuePresenter.IsSelected)
                        navigationInfo = SelectFirst(navigationInfo);
                    break;
            }

            navigationInfo = base.TabToPrevious(navInfoParam);

            return navigationInfo;
        }
示例#14
0
        /// <summary>
        /// Tabs to next.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo TabToNext(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Default:
                    if (ValuePresenter.IsSelected && ChildSpreadsheet != null && ChildSpreadsheet.IsVisible)
                        navigationInfo = base.SelectFirst(navigationInfo);
                    break;
            }

            navigationInfo = base.TabToNext(navigationInfo);

            return navigationInfo;
        }
        /// <summary>
        /// Selects the last.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectLast(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (!Cells.Any())
                navigationInfo.ActionState = MoveStates.Fail;
            else
            {
                var newCell = Cells.Last();
                if (navigationInfo.InitialCell == null)
                    navigationInfo.InitialCell = newCell;

                navigationInfo = newCell.ProcessSelectionCommand(navigationInfo);
            }

            return navigationInfo;
        }
示例#16
0
        /// <summary>
        /// Moves down.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo MoveDown(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Lowermost:
                    if (IsSelected)
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = Owner.ParentCell.Container.SelectNextRowCell(navigationInfo);
                    }
                    else
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = Container.SelectNextRowCell(navigationInfo);
                    }
                    break;
            }

            navigationInfo = base.MoveDown(navigationInfo);

            return navigationInfo;
        }
        /// <summary>
        /// Selects the next.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectNext(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            var index = Cells.IndexOf(navigationInfo.CurrentCell);
            if (Cells.Count - 1 > index) // Not the last cell in a row
            {
                var newCell = Cells[index + 1];
                navigationInfo = newCell.ProcessSelectionCommand(navigationInfo);
            }
            else // last cell in a row
            {                
                navigationInfo.ActionState = MoveStates.Rightmost;
                navigationInfo = navigationInfo.CurrentCell.ProcessSelectionCommand(navigationInfo);
            }

            return navigationInfo;
        }
示例#18
0
        /// <summary>
        /// Selects the last.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected virtual NavigationInfo SelectLast(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (ChildSpreadsheet != null && !navigationInfo.SelectParents)
                navigationInfo = ChildSpreadsheet.SelectLast(navigationInfo);
            else
                navigationInfo.ActionState = MoveStates.NoItems;

            return navigationInfo;
        }
 /// <summary>
 /// Selects the previous row cell.
 /// </summary>
 /// <param name="navInfoParam">The nav information parameter.</param>
 /// <returns>NavigationInfo.</returns>
 public NavigationInfo SelectPrevRowCell(NavigationInfo navInfoParam)
 {
     return _owner.SelectPrevRowCell(navInfoParam, this);
 }
示例#20
0
        /// <summary>
        /// Selects the first cell from last container.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected virtual NavigationInfo SelectFirstCellFromLastContainer(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (ChildSpreadsheet != null && ChildSpreadsheet.IsVisible && ChildSpreadsheet.Items.Any() && !navigationInfo.SelectParents)
            {
                var container = ChildSpreadsheet.GetContainerFromItem(ChildSpreadsheet.Items.Last() as IWrap);
                if (container != null)
                    navigationInfo = container.SelectFirst(navigationInfo);
                else
                    navigationInfo = ChildSpreadsheet.SelectFirst(navigationInfo);
            }
            else
                navigationInfo.ActionState = MoveStates.NoItems;

            return navigationInfo;
        }
        /// <summary>
        /// Selects the index of the by.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public NavigationInfo SelectByIndex(int index, NavigationInfo navInfoParam = null)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (Cells.Count < index) 
                throw new ArgumentOutOfRangeException(string.Format(CultureInfo.InvariantCulture, "index {0} is out of range", index));

            if (index == -1)
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            var newCell = Cells[index];
            return newCell.ProcessSelectionCommand(navigationInfo);
        }
示例#22
0
        /// <summary>
        /// Selects the column to move.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <param name="moveDirection">The move direction.</param>
        /// <returns>NavigationInfo.</returns>
        protected virtual NavigationInfo SelectColumnToMove(NavigationInfo navInfoParam, SideDirection moveDirection)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            var minLevel = 1;
            IColumn theDeepestColumn = null;

            foreach (var column in CellSelectionInspector.CellsSelectedChain.Where(x => x.LevelOfInheritance > 0))
            {
                if (minLevel < column.LevelOfInheritance)
                {
                    minLevel = column.LevelOfInheritance;
                    theDeepestColumn = column;
                }
            }

            if (theDeepestColumn == null || theDeepestColumn.LevelOfInheritance <= Column.LevelOfInheritance)
            {
                if (moveDirection == SideDirection.Up)
                    navigationInfo = SelectFirstCellFromLastContainer(navigationInfo);
                else if (moveDirection == SideDirection.Down)
                    navigationInfo = SelectFirst(navigationInfo);
            }
            else
            {
                CellSelectionInspector.CellsSelectedChain.RemoveAll(x => x != theDeepestColumn);

                if (ChildSpreadsheet != null && ChildSpreadsheet.IsVisible && ChildSpreadsheet.Items.Any())
                {
                    IColumn column;
                    if (theDeepestColumn.LevelOfInheritance == Column.LevelOfInheritance + 1)
                        column = theDeepestColumn;
                    else
                        column = theDeepestColumn.GetParentColumnOfLevel(Column.LevelOfInheritance + 1);

                    IWrap item = null;
                    if (moveDirection == SideDirection.Up)
                        item = ChildSpreadsheet.Items.Last() as IWrap;
                    else if (moveDirection == SideDirection.Down)
                        item = ChildSpreadsheet.Items.First() as IWrap;

                    var container = ChildSpreadsheet.GetContainerFromItem(item);
                    if (column != null && container != null)
                    {
                        container.SelectByColumn(column, navigationInfo);
                    }
                }

                if (navigationInfo.ActionState != MoveStates.Ok)
                {
                    if (moveDirection == SideDirection.Up)
                        navigationInfo = SelectFirstCellFromLastContainer(navigationInfo);
                    else if (moveDirection == SideDirection.Down)
                        navigationInfo = SelectFirst(navigationInfo);
                }
            }

            return navigationInfo;
        }
        /// <summary>
        /// Jumps to column.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        private NavigationInfo JumpToColumn(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam;

            var targetColumn = CellSelectionInspector.CellsSelectedChain.FirstOrDefault(x => Owner.Columns.Contains(x));
            if (targetColumn != null)
                navigationInfo = SelectByColumn(targetColumn, navigationInfo);
            else
            {
                targetColumn = navigationInfo.CurrentCell.Column;
                while (targetColumn != null && !Owner.Columns.Contains(targetColumn))
                    targetColumn = targetColumn.ParentColumn;

                if (targetColumn != null)
                    navigationInfo = SelectByColumn(targetColumn, navigationInfo);
                else
                    SelectFirst(navigationInfo);
            }

            return navigationInfo;
        }
示例#24
0
        /// <summary>
        /// Moves the left or right.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <param name="moveDirection">The move direction.</param>
        /// <returns>NavigationInfo.</returns>
        private NavigationInfo MoveLeftOrRight(NavigationInfo navInfoParam, SideDirection moveDirection)
        {
            var navigationInfo = navInfoParam;

            if (CellSelectionInspector.CellHierarchyPath.Any())
            {
                var coordinates = navigationInfo.InitialCell.GetCellCoordinates(moveDirection);
                var targetCell = NavigationHelper.FindAppropriateCellToMove(this, coordinates.CellBeginsAt, coordinates.CellEndsAt, moveDirection);

                CellSelectionInspector.CellHierarchyPath.Clear();
                if (targetCell != null)
                    navigationInfo = targetCell.ProcessSelectionCommand(navigationInfo);
            }
            else
            {
                if (moveDirection == SideDirection.Right)
                    navigationInfo = SelectFirst(navigationInfo);
                else if (moveDirection == SideDirection.Left)
                {
                    if (this is DetailCell)
                        navigationInfo = SelectFirst(navigationInfo);
                    else
                    {
                        if (ChildSpreadsheet != null && ChildSpreadsheet.Items.Any())
                        {
                            var container = ChildSpreadsheet.GetContainerFromItem(ChildSpreadsheet.Items[0] as IWrap);
                            if (container != null)
                                navigationInfo = container.SelectLast(navigationInfo);
                            else
                                navigationInfo = SelectLast(navigationInfo);
                        }
                        else
                            navigationInfo = SelectLast(navigationInfo);
                    }
                }
            }

            return navigationInfo;
        }
示例#25
0
        /// <summary>
        /// Selects the next row cell.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <param name="spreadsheetItemContainer">The spreadsheet item container.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectNextRowCell(NavigationInfo navInfoParam, SpreadsheetItemContainer spreadsheetItemContainer)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (spreadsheetItemContainer == null)
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            var index = spreadsheetItemContainer.Item != null ? spreadsheetItemContainer.Item.Index : -1;
            if (index < 0)
            {
                navigationInfo.ActionState = MoveStates.Fail;
                return navigationInfo;
            }

            if (index >= Items.Count - 1) // last row
            {
                if (ParentSpreadsheet == null) // top-level last row
                    navigationInfo.ActionState = MoveStates.Bottommost;
                else
                    navigationInfo.ActionState = MoveStates.Lowermost;

                navigationInfo = spreadsheetItemContainer.JumpToNextCell(navigationInfo);
            }
            else
            {
                var container = GetContainerFromItem(Items[index + 1] as IWrap);
                if (container != null)
                {
                    navigationInfo = container.JumpToNextCell(navigationInfo);
                }
                else
                    navigationInfo.ActionState = MoveStates.Fail;
            }

            return navigationInfo;
        }
示例#26
0
        /// <summary>
        /// Selects the cell.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected override NavigationInfo SelectCell(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (navigationInfo.ActionState == MoveStates.Default && (navigationInfo.Step > 1 ||
                !navigationInfo.CurrentCell.Equals(navigationInfo.InitialCell)))
            {
                if (Column.IsSelectable)
                {                    
                    switch (navigationInfo.Command)
                    {
                        case CommandType.Undefined:
                        case CommandType.TabNext:
                            navigationInfo = SelectFirst(navigationInfo);
                            break;
                        case CommandType.TabPrevious:
                            navigationInfo = SelectLast(navigationInfo);
                            break;
                        case CommandType.MoveRight:
                            navigationInfo = MoveLeftOrRight(navigationInfo, SideDirection.Right);
                            break;
                        case CommandType.MoveLeft:
                            navigationInfo = MoveLeftOrRight(navigationInfo, SideDirection.Left);
                            break;
                        case CommandType.MoveUp:
                            navigationInfo = SelectColumnToMove(navigationInfo, SideDirection.Up);
                            break;
                        case CommandType.MoveDown:
                            navigationInfo = SelectColumnToMove(navigationInfo, SideDirection.Down);
                            break;
                    }                    
                }
                else
                    navigationInfo.ActionState = MoveStates.IsNotSelectable;
            }

            if (navigationInfo.ActionState == MoveStates.NoItems)
            {
                navigationInfo.ActionState = MoveStates.Default;
                base.SelectCell(navigationInfo);
            }

            return navigationInfo;
        }
示例#27
0
        /// <summary>
        /// Moves down.
        /// </summary>
        /// <param name="spreadsheet">The spreadsheet.</param>
        public static void MoveDown(this SpreadsheetView spreadsheet)
        {
            if (spreadsheet == null)
                return;

            var navigationInfo = new NavigationInfo(CommandType.MoveDown);            

            var selectedCells = spreadsheet.GetTopLevelSpreadsheet().GetSelectedCells();
            if (selectedCells == null || !selectedCells.Any())
            {
                spreadsheet.SelectFirst(navigationInfo);
            }
            else
            {
                var firstSelected = selectedCells.First();
                navigationInfo.InitialCell = firstSelected;

                if (firstSelected is StackCell)
                    navigationInfo.SelectParents = true;

                firstSelected.ProcessSelectionCommand(navigationInfo);
            }
        }
        /// <summary>
        /// Selects the first.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        public NavigationInfo SelectFirst(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            if (!Cells.Any())
                navigationInfo.ActionState = MoveStates.Fail;
            else
            {
                if (navigationInfo.InitialCell == null && navigationInfo.CurrentCell == null)
                    navigationInfo.InitialCell = Cells[0];

                navigationInfo = Cells[0].ProcessSelectionCommand(navigationInfo);
            }

            return navigationInfo;
        }
示例#29
0
        /// <summary>
        /// Moves the right.
        /// </summary>
        /// <param name="spreadsheet">The spreadsheet.</param>
        public static void MoveRight(this SpreadsheetView spreadsheet)
        {
            if (spreadsheet == null)
                return;

            var navigationInfo = new NavigationInfo(CommandType.MoveRight);            

            var selectedCells = spreadsheet.GetTopLevelSpreadsheet().GetSelectedCells();
            if (selectedCells == null || !selectedCells.Any())
            {
                spreadsheet.SelectFirst(navigationInfo);
            }
            else
            {
                var lastSelected = selectedCells.Last();
                navigationInfo.InitialCell = lastSelected;

                lastSelected.ProcessSelectionCommand(navigationInfo);
            }
        }
示例#30
0
        /// <summary>
        /// Moves down.
        /// </summary>
        /// <param name="navInfoParam">The nav information parameter.</param>
        /// <returns>NavigationInfo.</returns>
        protected virtual NavigationInfo MoveDown(NavigationInfo navInfoParam)
        {
            var navigationInfo = navInfoParam ?? new NavigationInfo();

            switch (navigationInfo.ActionState)
            {
                case MoveStates.Default:
                    navigationInfo = Container.SelectNextRowCell(navigationInfo); break;
                case MoveStates.Lowermost:
                    navigationInfo.ActionState = MoveStates.Default;
                    navigationInfo = Owner.ParentCell.Container.SelectNextRowCell(navigationInfo);
                    break;
                case MoveStates.Bottommost:
                    var container = Owner.GetContainerFromItem(Owner.Items.First() as IWrap);
                    if (container != null)
                    {
                        navigationInfo.ActionState = MoveStates.Default;
                        navigationInfo = container.JumpToNextCell(navigationInfo);
                    }
                    else
                        navigationInfo.ActionState = MoveStates.Fail;
                    break;
            }

            return navigationInfo;
        }