public override AccessibleObject Navigate(AccessibleNavigation navdir) { TreeNavigation navAction; switch (navdir) { case AccessibleNavigation.Down: navAction = TreeNavigation.NextSibling; break; case AccessibleNavigation.FirstChild: navAction = TreeNavigation.FirstChild; break; case AccessibleNavigation.LastChild: navAction = TreeNavigation.LastChild; break; case AccessibleNavigation.Up: navAction = TreeNavigation.PreviousSibling; break; case AccessibleNavigation.Left: navAction = TreeNavigation.Left; break; case AccessibleNavigation.Next: navAction = TreeNavigation.Down; break; case AccessibleNavigation.Previous: navAction = TreeNavigation.Up; break; case AccessibleNavigation.Right: navAction = TreeNavigation.Right; break; default: return null; } AccessibleObject retVal = null; var tree = myCtl.Tree; var colPerm = myCtl.ColumnPermutation; if (colPerm != null && myDisplayColumn >= colPerm.VisibleColumnCount) { // Handle a stale object so the rest of this doesn't crash return null; } var target = tree.GetNavigationTarget(navAction, myRow, myDisplayColumn, colPerm); if (target.IsValid) { var nativeColumn = target.Column; var settings = AccItemSettings.None; if (colPerm != null) { nativeColumn = colPerm.GetNativeColumn(nativeColumn); if (colPerm.GetPermutedColumn(nativeColumn) == -1) { settings |= AccItemSettings.HiddenItem; } } var newInfo = tree.GetItemInfo(target.Row, nativeColumn, true); retVal = new AccPrimaryItem(myCtl, target.Row, nativeColumn, target.Column, settings, ref newInfo); } return retVal; }
/// <summary> /// Return either a Cell or Column object, depending on the branch settings /// </summary> /// <param name="ctl">The parent control</param> /// <param name="baseRow">The row coordinate</param> /// <param name="nativeBaseColumn">The column coordinate for the owning branch</param> /// <param name="localColumn">The native column offset</param> /// <param name="returnColumn">Return an AccColumn object if this is true, otherwise return the AccPrimaryItem directly</param> /// <returns>An AccSimpleCell or AccColumn</returns> public static AccessibleObject GetColumnObject( VirtualTreeControl ctl, int baseRow, int nativeBaseColumn, int localColumn, bool returnColumn) { // Note: if this logic changes, corresponding change should be made to IsSimpleItem below. Debug.Assert(localColumn > 0); AccessibleObject retVal = null; var tree = ctl.Tree; var info = tree.GetItemInfo(baseRow, nativeBaseColumn, false); var mcBranch = info.Branch as IMultiColumnBranch; if (mcBranch != null) { var simpleCell = true; var useColInfo = false; var nativeColumn = nativeBaseColumn + localColumn; var displayColumn = nativeColumn; var colPerm = ctl.myColumnPermutation; var settings = AccItemSettings.None; if (colPerm != null) { displayColumn = colPerm.GetPermutedColumn(nativeColumn); if (displayColumn == -1) { displayColumn = 0; settings |= AccItemSettings.HiddenItem; } } var style = mcBranch.ColumnStyles(localColumn); var colInfo = new VirtualTreeItemInfo(); style = mcBranch.ColumnStyles(localColumn); switch (style) { case SubItemCellStyles.Expandable: // Use a simple cell unless the item is expandable. An item // in an expandable column cannot have subitems, so // we will not need a column object for this purpose. simpleCell = !info.Branch.IsExpandable(info.Row, localColumn); break; case SubItemCellStyles.Mixed: case SubItemCellStyles.Complex: colInfo = tree.GetItemInfo(baseRow, nativeColumn, true); if (colInfo.Column == 0) { var columns = (0 == (info.Branch.Features & BranchFeatures.JaggedColumns)) ? mcBranch.ColumnCount : mcBranch.GetJaggedColumnCount(info.Row); // The data is provided by a different branch. The item is simple only // if the branch has one unexpandable item and no sub items. if (!(colInfo.Branch.VisibleItemCount == 1 && !colInfo.Branch.IsExpandable(0, 0) && (localColumn < columns || (null != (colInfo.Branch as IMultiColumnBranch) && 0 == tree.GetSubItemCount(baseRow, nativeColumn))))) { simpleCell = false; } useColInfo = true; } else if (style == SubItemCellStyles.Mixed) { goto case SubItemCellStyles.Expandable; } break; } if (simpleCell) { if (useColInfo) { retVal = new AccSimpleCell(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo); } else { var cellInfo = tree.GetItemInfo(baseRow, nativeColumn, true); if (!cellInfo.Blank) { retVal = new AccSimpleCell(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo); } } } else if (returnColumn) { if (useColInfo) { retVal = new AccColumn(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo); } else { var cellInfo = tree.GetItemInfo(baseRow, nativeBaseColumn + localColumn, true); retVal = new AccColumn(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo); } } else { if (useColInfo) { retVal = new AccPrimaryItem(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo); } else { var cellInfo = tree.GetItemInfo(baseRow, nativeBaseColumn + localColumn, true); retVal = new AccPrimaryItem(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo); } } } return retVal; }