/// <summary> /// Finds the appropriate cell to move. /// </summary> /// <param name="parentCell">The parent cell.</param> /// <param name="lowerLimit">The lower limit.</param> /// <param name="upperLimit">The upper limit.</param> /// <param name="moveDirection">The move direction.</param> /// <returns>CellBase.</returns> internal static CellBase FindAppropriateCellToMove(CellBase parentCell, double lowerLimit, double upperLimit, SideDirection moveDirection) { var parentCellBeginsAt = 0.0; var parentCellEndsAt = 0.0; Func<CellBase, CellBase> calculator = null; calculator = cell => { var currentCell = cell; var spreadsheet = currentCell.HasNested ? ((StackCell)currentCell).ChildSpreadsheet : null; var detailCell = currentCell as DetailCell; if (detailCell != null) { parentCellBeginsAt = parentCellEndsAt; parentCellEndsAt += currentCell.Container.ActualHeight; if (spreadsheet != null && spreadsheet.IsVisible) parentCellEndsAt -= spreadsheet.ActualHeight; if (CellSuites(parentCellBeginsAt, parentCellEndsAt, upperLimit, lowerLimit)) return currentCell; } if (spreadsheet != null && spreadsheet.Items.Any() && spreadsheet.IsVisible) { foreach (IWrap item in spreadsheet.Items) { var itemContainer = spreadsheet.GetContainerFromItem(item); currentCell = moveDirection == SideDirection.Right ? itemContainer.Cells[itemContainer.Owner.FirstRowIndex] : itemContainer.Cells.Last(); var expectant = calculator(currentCell); if (expectant != null) return expectant; } } else { parentCellBeginsAt = parentCellEndsAt; parentCellEndsAt += currentCell.Container.ActualHeight; } if (CellSuites(parentCellBeginsAt, parentCellEndsAt, upperLimit, lowerLimit)) return currentCell; return null; }; return calculator(parentCell); }
/// <summary> /// Unselects the specified cell. /// </summary> /// <param name="cell">The cell.</param> /// <param name="caller">The caller.</param> public void Unselect(CellBase cell, SpreadsheetView caller = null) { foreach (var child in _childSpreadsheets.Where(x => x.IsVisible)) { if (child != caller) child.Unselect(cell, caller); } foreach (var item in Items) { var container = GetContainerFromItem((IWrap) item); if (container != null) container.Unselect(cell); } }
/// <summary> /// Draws the horizontal lines. /// </summary> /// <param name="cell">The cell.</param> /// <param name="topLevelSpreadSheet">The top level spread sheet.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private static bool DrawHorizontalLines(CellBase cell, SpreadsheetView topLevelSpreadSheet) { if ((topLevelSpreadSheet.GridLinesVisibility & GridLinesVisibility.Horizontal) == GridLinesVisibility.Horizontal) { if (cell != null && cell.Owner.Items.Any() && !cell.Owner.Items.Last().Equals(cell.Container.Item)) { return true; } } return false; }
/// <summary> /// Draws the vertical lines. /// </summary> /// <param name="cell">The cell.</param> /// <param name="topLevelSpreadSheet">The top level spread sheet.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> private static bool DrawVerticalLines(CellBase cell, SpreadsheetView topLevelSpreadSheet) { if ((topLevelSpreadSheet.GridLinesVisibility & GridLinesVisibility.Vertical) == GridLinesVisibility.Vertical) { var stackCell = cell as StackCell; if (cell != null && (cell.Owner.Columns.Last() != cell.Column || cell.Owner.ParentSpreadsheet != null) && ((!cell.HasNested || (stackCell != null && (stackCell.ChildSpreadsheet == null || !stackCell.ChildSpreadsheet.Items.Any()))))) { return true; } } return false; }
/// <summary> /// Unselects the specified cell. /// </summary> /// <param name="cell">The cell.</param> public void Unselect(CellBase cell) { foreach (var value in Cells) { if (value != cell && value.IsSelected) value.IsSelected = false; } }