Ejemplo n.º 1
0
            internal override UiaCore.IRawElementProviderFragment?FragmentNavigate(UiaCore.NavigateDirection direction)
            {
                AccessibleObject _parentInternal = OwningGroup?.AccessibilityObject ?? _owningListView.AccessibilityObject;

                switch (direction)
                {
                case UiaCore.NavigateDirection.Parent:
                    return(_parentInternal);

                case UiaCore.NavigateDirection.NextSibling:
                    int childIndex = _parentInternal.GetChildIndex(this);
                    return(childIndex == -1 ? null : _parentInternal.GetChild(childIndex + 1));

                case UiaCore.NavigateDirection.PreviousSibling:
                    return(_parentInternal.GetChild(_parentInternal.GetChildIndex(this) - 1));

                case UiaCore.NavigateDirection.FirstChild:
                    if (_owningItem.SubItems.Count > 0)
                    {
                        return(GetChild(0));
                    }

                    break;

                case UiaCore.NavigateDirection.LastChild:
                    return(GetChildInternal(LastChildIndex));
                }

                return(base.FragmentNavigate(direction));
            }
Ejemplo n.º 2
0
            internal override UiaCore.IRawElementProviderFragment?FragmentNavigate(UiaCore.NavigateDirection direction)
            {
                AccessibleObject _parentInternal = _owningListView.AccessibilityObject;

                switch (direction)
                {
                case UiaCore.NavigateDirection.Parent:
                    return(_parentInternal);

                case UiaCore.NavigateDirection.NextSibling:
                    int childIndex = _parentInternal.GetChildIndex(this);
                    return(childIndex == -1 ? null : _parentInternal.GetChild(childIndex + 1));

                case UiaCore.NavigateDirection.PreviousSibling:
                    return(_parentInternal.GetChild(_parentInternal.GetChildIndex(this) - 1));
                }

                return(base.FragmentNavigate(direction));
            }
Ejemplo n.º 3
0
 private AccessibleObject NavigateForward(bool wrapAround)
 {
     if (_owner.OwningColumn == _owner.DataGridView.Columns.GetLastColumn(DataGridViewElementStates.Visible,
                                                                          DataGridViewElementStates.None))
     {
         if (wrapAround)
         {
             // Return the first cell in the next visible row.
             //
             AccessibleObject nextRow = Owner.OwningRow.AccessibilityObject.Navigate(AccessibleNavigation.Next);
             if (nextRow != null && nextRow.GetChildCount() > 0)
             {
                 if (Owner.DataGridView.RowHeadersVisible)
                 {
                     return(nextRow.GetChild(1));
                 }
                 else
                 {
                     return(nextRow.GetChild(0));
                 }
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
     else
     {
         int nextVisibleColumnIndex = _owner.DataGridView.Columns.GetNextColumn(_owner.OwningColumn,
                                                                                DataGridViewElementStates.Visible,
                                                                                DataGridViewElementStates.None).Index;
         return(_owner.OwningRow.Cells[nextVisibleColumnIndex].AccessibilityObject);
     }
 }
            public override AccessibleObject Navigate(AccessibleNavigation navigationDirection)
            {
                if (Owner.OwningColumn == null)
                {
                    return(null);
                }

                switch (navigationDirection)
                {
                case AccessibleNavigation.Right:
                    if (Owner.DataGridView.RightToLeft == RightToLeft.No)
                    {
                        return(NavigateForward());
                    }
                    else
                    {
                        return(NavigateBackward());
                    }

                case AccessibleNavigation.Next:
                    return(NavigateForward());

                case AccessibleNavigation.Left:
                    if (Owner.DataGridView.RightToLeft == RightToLeft.No)
                    {
                        return(NavigateBackward());
                    }
                    else
                    {
                        return(NavigateForward());
                    }

                case AccessibleNavigation.Previous:
                    return(NavigateBackward());

                case AccessibleNavigation.FirstChild:
                    // return the top left header cell accessible object
                    return(Owner.DataGridView.AccessibilityObject.GetChild(0).GetChild(0));

                case AccessibleNavigation.LastChild:
                    // return the last column header cell in the top row header accessible object
                    AccessibleObject topRowHeaderAccessibleObject = Owner.DataGridView.AccessibilityObject.GetChild(0);
                    return(topRowHeaderAccessibleObject.GetChild(topRowHeaderAccessibleObject.GetChildCount() - 1));

                default:
                    return(null);
                }
            }
Ejemplo n.º 5
0
            public override AccessibleObject?Navigate(AccessibleNavigation navigationDirection)
            {
                if (Owner is null)
                {
                    throw new InvalidOperationException(SR.DataGridViewCellAccessibleObject_OwnerNotSet);
                }

                if (Owner.OwningColumn is null || Owner.DataGridView is null)
                {
                    return(null);
                }

                switch (navigationDirection)
                {
                case AccessibleNavigation.Right:
                    return(Owner.DataGridView.RightToLeft == RightToLeft.No ? NavigateForward() : NavigateBackward());

                case AccessibleNavigation.Next:
                    return(NavigateForward());

                case AccessibleNavigation.Left:
                    return(Owner.DataGridView.RightToLeft == RightToLeft.No ? NavigateBackward() : NavigateForward());

                case AccessibleNavigation.Previous:
                    return(NavigateBackward());

                case AccessibleNavigation.FirstChild:
                    // return the top left header cell accessible object
                    return(Parent?.GetChild(0));

                case AccessibleNavigation.LastChild:
                    // return the last column header cell in the top row header accessible object
                    AccessibleObject?topRowHeaderAccessibleObject = Parent;
                    return(topRowHeaderAccessibleObject?.GetChild(topRowHeaderAccessibleObject.GetChildCount() - 1));

                default:
                    return(null);
                }
            }
Ejemplo n.º 6
0
 private AccessibleObject NavigateBackward(bool wrapAround)
 {
     if (_owner.OwningColumn == _owner.DataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible))
     {
         if (wrapAround)
         {
             // Return the last accessible object in the previous row
             AccessibleObject previousRow = Owner.OwningRow.AccessibilityObject.Navigate(AccessibleNavigation.Previous);
             if (previousRow != null && previousRow.GetChildCount() > 0)
             {
                 return(previousRow.GetChild(previousRow.GetChildCount() - 1));
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             // return the row header cell if the row headers are visible.
             if (_owner.DataGridView.RowHeadersVisible)
             {
                 return(_owner.OwningRow.AccessibilityObject.GetChild(0));
             }
             else
             {
                 return(null);
             }
         }
     }
     else
     {
         int previousVisibleColumnIndex = _owner.DataGridView.Columns.GetPreviousColumn(_owner.OwningColumn,
                                                                                        DataGridViewElementStates.Visible,
                                                                                        DataGridViewElementStates.None).Index;
         return(_owner.OwningRow.Cells[previousVisibleColumnIndex].AccessibilityObject);
     }
 }
            public override AccessibleObject Navigate(AccessibleNavigation navigationDirection)
            {
                if (base.Owner.OwningColumn != null)
                {
                    switch (navigationDirection)
                    {
                    case AccessibleNavigation.Left:
                        if (base.Owner.DataGridView.RightToLeft != RightToLeft.No)
                        {
                            return(this.NavigateForward());
                        }
                        return(this.NavigateBackward());

                    case AccessibleNavigation.Right:
                        if (base.Owner.DataGridView.RightToLeft != RightToLeft.No)
                        {
                            return(this.NavigateBackward());
                        }
                        return(this.NavigateForward());

                    case AccessibleNavigation.Next:
                        return(this.NavigateForward());

                    case AccessibleNavigation.Previous:
                        return(this.NavigateBackward());

                    case AccessibleNavigation.FirstChild:
                        return(base.Owner.DataGridView.AccessibilityObject.GetChild(0).GetChild(0));

                    case AccessibleNavigation.LastChild:
                    {
                        AccessibleObject child = base.Owner.DataGridView.AccessibilityObject.GetChild(0);
                        return(child.GetChild(child.GetChildCount() - 1));
                    }
                    }
                }
                return(null);
            }
Ejemplo n.º 8
0
		private static void DumpAccessibilityReport(AccessibleObject parent, string indent)
		{
			Debug.WriteLine(string.Format("{0}Name: {1}, Value: {2}, Role: {3}, Description: {4}", indent, parent.Name, parent.Value, parent.Role.ToString(), parent.Description));
			int childCount = parent.GetChildCount();
			if (childCount != 0)
			{
				string childIndent = indent + "\t";
				for (int i = 0; i < childCount; ++i)
				{
					DumpAccessibilityReport(parent.GetChild(i), childIndent);
				}
			}
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Find the accessible object matching the given path
		/// </summary>
		/// <param name="parent">The starting accessible object</param>
		/// <param name="nodePath">A list of AccessiblePathNode structures. Note that the
		/// easiest way to populate this is with an array of path nodes</param>
		/// <returns>Matching AccessibleObject, or null</returns>
		public static AccessibleObject FindAccessibleObject(AccessibleObject parent, IList<AccessiblePathNode> nodePath)
		{
			int pathCount = nodePath.Count;
			if (pathCount == 0)
			{
				return null;
			}
			AccessibleObject nextParent = parent;
			for (int currentNodeIndex = 0; currentNodeIndex < pathCount && nextParent != null; ++currentNodeIndex)
			{
				parent = nextParent;
				nextParent = null;
				int childCount = parent.GetChildCount();
				if (childCount != 0)
				{
					AccessiblePathNode currentNode = nodePath[currentNodeIndex];
					int testIndex = currentNode.Index;
					for (int i = 0; i < childCount; ++i)
					{
						AccessibleObject child = parent.GetChild(i);
						if (child != null &&
							child.Name == currentNode.Name &&
							(currentNode.Value == null || currentNode.Value == child.Value))
						{
							if (testIndex > 0)
							{
								--testIndex;
							}
							else
							{
								nextParent = child;
								break;
							}
						}
					}
				}
			}
			return nextParent;
		}
 internal Rectangle GetAccessibleObjectBounds(AccessibleObject parentAccObject)
 {
     Rectangle columnDisplayRectangle;
     if (this.owner == null)
     {
         throw new InvalidOperationException(System.Windows.Forms.SR.GetString("DataGridViewCellAccessibleObject_OwnerNotSet"));
     }
     if (this.owner.OwningColumn == null)
     {
         return Rectangle.Empty;
     }
     Rectangle bounds = parentAccObject.Bounds;
     int num = this.owner.DataGridView.Columns.ColumnIndexToActualDisplayIndex(this.owner.DataGridView.FirstDisplayedScrollingColumnIndex, DataGridViewElementStates.Visible);
     int num2 = this.owner.DataGridView.Columns.ColumnIndexToActualDisplayIndex(this.owner.ColumnIndex, DataGridViewElementStates.Visible);
     bool rowHeadersVisible = this.owner.DataGridView.RowHeadersVisible;
     if (num2 < num)
     {
         columnDisplayRectangle = parentAccObject.GetChild((num2 + 1) + (rowHeadersVisible ? 1 : 0)).Bounds;
         if (this.Owner.DataGridView.RightToLeft == RightToLeft.No)
         {
             columnDisplayRectangle.X -= this.owner.OwningColumn.Width;
         }
         else
         {
             columnDisplayRectangle.X = columnDisplayRectangle.Right;
         }
         columnDisplayRectangle.Width = this.owner.OwningColumn.Width;
     }
     else if (num2 == num)
     {
         columnDisplayRectangle = this.owner.DataGridView.GetColumnDisplayRectangle(this.owner.ColumnIndex, false);
         int firstDisplayedScrollingColumnHiddenWidth = this.owner.DataGridView.FirstDisplayedScrollingColumnHiddenWidth;
         if (firstDisplayedScrollingColumnHiddenWidth != 0)
         {
             if (this.owner.DataGridView.RightToLeft == RightToLeft.No)
             {
                 columnDisplayRectangle.X -= firstDisplayedScrollingColumnHiddenWidth;
             }
             columnDisplayRectangle.Width += firstDisplayedScrollingColumnHiddenWidth;
         }
         columnDisplayRectangle = this.owner.DataGridView.RectangleToScreen(columnDisplayRectangle);
     }
     else
     {
         columnDisplayRectangle = parentAccObject.GetChild((num2 - 1) + (rowHeadersVisible ? 1 : 0)).Bounds;
         if (this.owner.DataGridView.RightToLeft == RightToLeft.No)
         {
             columnDisplayRectangle.X = columnDisplayRectangle.Right;
         }
         else
         {
             columnDisplayRectangle.X -= this.owner.OwningColumn.Width;
         }
         columnDisplayRectangle.Width = this.owner.OwningColumn.Width;
     }
     bounds.X = columnDisplayRectangle.X;
     bounds.Width = columnDisplayRectangle.Width;
     return bounds;
 }
Ejemplo n.º 11
0
            internal Rectangle GetAccessibleObjectBounds(AccessibleObject parentAccObject)
            {
                if (this.owner == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.DataGridViewCellAccessibleObject_OwnerNotSet));
                }

                if (this.owner.OwningColumn == null)
                {
                    return Rectangle.Empty;
                }

                // use the accessibility bounds from the parent row acc obj
                Rectangle rowRect = parentAccObject.Bounds;
                Rectangle columnRect;

                int firstVisibleColumnIndex = this.owner.DataGridView.Columns.ColumnIndexToActualDisplayIndex(this.owner.DataGridView.FirstDisplayedScrollingColumnIndex, DataGridViewElementStates.Visible);
                int visibleColumnIndex = this.owner.DataGridView.Columns.ColumnIndexToActualDisplayIndex(this.owner.ColumnIndex, DataGridViewElementStates.Visible);

                bool rowHeadersVisible = this.owner.DataGridView.RowHeadersVisible;
                if (visibleColumnIndex < firstVisibleColumnIndex)
                {
                    // Get the bounds for the cell to the RIGHT
                    columnRect = parentAccObject.GetChild(visibleColumnIndex
                                                          + 1                                       // + 1 for the next cell to the RIGHT
                                                          + (rowHeadersVisible ? 1 : 0)).Bounds;    // + 1 but only if the row headers are visible

                    // From the bounds of the cell to the RIGHT decrement the width of the owning column
                    if (this.Owner.DataGridView.RightToLeft == RightToLeft.No)
                    {
                        columnRect.X -= this.owner.OwningColumn.Width;
                    }
                    else
                    {
                        columnRect.X = columnRect.Right;
                    }
                    columnRect.Width = this.owner.OwningColumn.Width;
                }
                else if (visibleColumnIndex == firstVisibleColumnIndex)
                {
                    columnRect = this.owner.DataGridView.GetColumnDisplayRectangle(this.owner.ColumnIndex, false /*cutOverflow*/);
                    int negOffset = this.owner.DataGridView.FirstDisplayedScrollingColumnHiddenWidth;

                    if (negOffset != 0)
                    {
                        if (this.owner.DataGridView.RightToLeft == RightToLeft.No)
                        {
                            columnRect.X -= negOffset;
                        }
                        columnRect.Width += negOffset;
                    }
                    columnRect = this.owner.DataGridView.RectangleToScreen(columnRect);
                }
                else
                {
                    // Get the bounds for the cell to the LEFT
                    columnRect = parentAccObject.GetChild(visibleColumnIndex
                                                          - 1                                       // -1 because we want the previous cell to the LEFT
                                                          + (rowHeadersVisible ? 1 : 0)).Bounds;    // +1 but only if the row headers are visible

                    // From the bounds of the cell to the LEFT increment the width of the owning column
                    if (this.owner.DataGridView.RightToLeft == RightToLeft.No)
                    {
                        columnRect.X = columnRect.Right;
                    }
                    else
                    {
                        columnRect.X -= this.owner.OwningColumn.Width;
                    }

                    columnRect.Width = this.owner.OwningColumn.Width;
                }

                rowRect.X = columnRect.X;
                rowRect.Width = columnRect.Width;

                return rowRect;
            }