/// <summary> /// Reimplementation of <see cref="ITree.GetNavigationTarget"/> to fix issues with the Down navigation direction /// </summary> protected new VirtualTreeCoordinate GetNavigationTarget(TreeNavigation direction, int sourceRow, int sourceColumn, ColumnPermutation columnPermutation) { // UNDONE: MSBUG GetNavigationTarget calls the internal method to get its blank expansion, not // the interface, so we have no way to override it. Duplicate the GetNavigationTarget fix here for // the 'Down' navigation target. BlankExpansionData blankExpansion; switch (direction) { case TreeNavigation.Down: blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, columnPermutation); if (blankExpansion.Anchor.IsValid) { int lastRow = ((ITree)this).VisibleItemCount - 1; while (blankExpansion.BottomRow < lastRow) { // Just return the next non-blank column int testRow = blankExpansion.BottomRow + 1; blankExpansion = GetBlankExpansion(testRow, sourceColumn, columnPermutation); if (!blankExpansion.Anchor.IsValid) { break; } int topRow = blankExpansion.TopRow; if (sourceColumn == blankExpansion.AnchorColumn && topRow >= testRow) { return new VirtualTreeCoordinate(topRow, sourceColumn); } } } return VirtualTreeCoordinate.Invalid; case TreeNavigation.Right: // If no column permutation is specified and we're on the first row in a complex // subitem expansion, then the provided implementation does not go right. // MSBUG: VirtualTree.GetNavigationTarget is looking at the column count of the // ParentNode of a complex subitem. The column count in this case is always 1. if (columnPermutation == null) { VirtualTreeCoordinate retVal = base.GetNavigationTarget(TreeNavigation.Right, sourceRow, sourceColumn, null); int lastAllowedSourceColumn; if (!retVal.IsValid && sourceColumn < (lastAllowedSourceColumn = (ColumnCount - 1)) && (blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, null)).Anchor.IsValid && blankExpansion.RightColumn < lastAllowedSourceColumn) { retVal = GetBlankExpansion(sourceRow, blankExpansion.RightColumn + 1, null).Anchor; } return retVal; } break; case TreeNavigation.LeftColumn: if (sourceColumn == 0) { // UNDONE: MSBUG Navigating LeftColumn from column 0 is crashing return VirtualTreeCoordinate.Invalid; } break; } return base.GetNavigationTarget(direction, sourceRow, sourceColumn, columnPermutation); }
/// <summary> /// Reimplementation of <see cref="ITree.GetBlankExpansion"/> /// </summary> protected new BlankExpansionData GetBlankExpansion(int row, int column, ColumnPermutation columnPermutation) { // UNDONE: MSBUG GetBlankExpansion is returning a blank cell for the top node in a complex subitem. This // causes the Down arrow to skip any expanded subitems, which is obviously not good. This does not appear to // happen in all cases, and may be related to the SubItemCellStyle. BlankExpansionData retVal = base.GetBlankExpansion(row, column, columnPermutation); int topRow; if (retVal.Height > 1 && row == (topRow = retVal.TopRow)) { // If the next cell down does not return the same anchor, then the // initial information is incorrect and we really have a single cell. if (base.GetBlankExpansion(topRow + 1, column, columnPermutation).Anchor != retVal.Anchor) { return(BlankExpansionDataConstructor(topRow, retVal.LeftColumn, retVal.TopRow, retVal.RightColumn, retVal.AnchorColumn)); } } return(retVal); }
/// <summary> /// Reimplementation of <see cref="ITree.GetNavigationTarget"/> to fix issues with the Down navigation direction /// </summary> protected new VirtualTreeCoordinate GetNavigationTarget(TreeNavigation direction, int sourceRow, int sourceColumn, ColumnPermutation columnPermutation) { // UNDONE: MSBUG GetNavigationTarget calls the internal method to get its blank expansion, not // the interface, so we have no way to override it. Duplicate the GetNavigationTarget fix here for // the 'Down' navigation target. BlankExpansionData blankExpansion; switch (direction) { case TreeNavigation.Down: blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, columnPermutation); if (blankExpansion.Anchor.IsValid) { int lastRow = ((ITree)this).VisibleItemCount - 1; while (blankExpansion.BottomRow < lastRow) { // Just return the next non-blank column int testRow = blankExpansion.BottomRow + 1; blankExpansion = GetBlankExpansion(testRow, sourceColumn, columnPermutation); if (!blankExpansion.Anchor.IsValid) { break; } int topRow = blankExpansion.TopRow; if (sourceColumn == blankExpansion.AnchorColumn && topRow >= testRow) { return(new VirtualTreeCoordinate(topRow, sourceColumn)); } } } return(VirtualTreeCoordinate.Invalid); case TreeNavigation.Right: // If no column permutation is specified and we're on the first row in a complex // subitem expansion, then the provided implementation does not go right. // MSBUG: VirtualTree.GetNavigationTarget is looking at the column count of the // ParentNode of a complex subitem. The column count in this case is always 1. if (columnPermutation == null) { VirtualTreeCoordinate retVal = base.GetNavigationTarget(TreeNavigation.Right, sourceRow, sourceColumn, null); int lastAllowedSourceColumn; if (!retVal.IsValid && sourceColumn < (lastAllowedSourceColumn = (ColumnCount - 1)) && (blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, null)).Anchor.IsValid && blankExpansion.RightColumn < lastAllowedSourceColumn) { retVal = GetBlankExpansion(sourceRow, blankExpansion.RightColumn + 1, null).Anchor; } return(retVal); } break; case TreeNavigation.LeftColumn: if (sourceColumn == 0) { // UNDONE: MSBUG Navigating LeftColumn from column 0 is crashing return(VirtualTreeCoordinate.Invalid); } break; } return(base.GetNavigationTarget(direction, sourceRow, sourceColumn, columnPermutation)); }
BlankExpansionData ITree.GetBlankExpansion(int row, int column, ColumnPermutation columnPermutation) { return(GetBlankExpansion(row, column, columnPermutation)); }
VirtualTreeCoordinate ITree.GetNavigationTarget(TreeNavigation direction, int sourceRow, int sourceColumn, ColumnPermutation columnPermutation) { return(GetNavigationTarget(direction, sourceRow, sourceColumn, columnPermutation)); }
BlankExpansionData ITree.GetBlankExpansion(int row, int column, ColumnPermutation columnPermutation) { return GetBlankExpansion(row, column, columnPermutation); }
/// <summary> /// Reimplementation of <see cref="ITree.GetBlankExpansion"/> /// </summary> protected new BlankExpansionData GetBlankExpansion(int row, int column, ColumnPermutation columnPermutation) { // UNDONE: MSBUG GetBlankExpansion is returning a blank cell for the top node in a complex subitem. This // causes the Down arrow to skip any expanded subitems, which is obviously not good. This does not appear to // happen in all cases, and may be related to the SubItemCellStyle. BlankExpansionData retVal = base.GetBlankExpansion(row, column, columnPermutation); int topRow; if (retVal.Height > 1 && row == (topRow = retVal.TopRow)) { // If the next cell down does not return the same anchor, then the // initial information is incorrect and we really have a single cell. if (base.GetBlankExpansion(topRow + 1, column, columnPermutation).Anchor != retVal.Anchor) { return BlankExpansionDataConstructor(topRow, retVal.LeftColumn, retVal.TopRow, retVal.RightColumn, retVal.AnchorColumn); } } return retVal; }
VirtualTreeCoordinate ITree.GetNavigationTarget(TreeNavigation direction, int sourceRow, int sourceColumn, ColumnPermutation columnPermutation) { return GetNavigationTarget(direction, sourceRow, sourceColumn, columnPermutation); }