C# Class SIL.FieldWorks.Common.RootSites.AccessibilityWrapper

This class implements the DotNet Acessibility interface by wrapping the COM IAccessible interface implemented by the root box. It is uncomfortably similar to COMInterfaces.AccessibleObjectFromIAccessible, but was developed independently since we (JohnT and Dan) didn't find AccessibleObjectFromIAccessible until later. The most important difference is that this version stores the root site as well as its AccessibleRootObject. This handles the problem that DotNet apparently only asks any one object to CreateAccessibilityInstance() once; then it caches the result. So if we return null, or make an AccessibleObjectFromIAccessible that has a null IAccessible, it will never work later when the root box has been made and the IAccessible is available. (In fact, it crashes, because AccessibleObjectFromIAccessible is not coded to handle a null IAccessible.) This class, whenever it needs the IAccessble, checks whether it is null. If so, it checks the root site to see whether it is now possible to get a proper AccessibleRootObject, and if so starts using it. If not, it answers something safe and neutral. It's possible that we could refactor to share some code between the two classes, for example, give AccessibleObjectFromIAccessible a virtual method to get the IAccessible (and always use it), then this class might only need to override that method to try getting the IAcessible from the rootsite if it doesn't already have one. However, we'd have to merge into AccessibleObjectFromIAccessible all the code from here that handles IAccessible being null. Another possible way to remove the duplication is just to delete AccessibleObjectFromIAccessible, since it doesn't seem to be used and was possibly just an unsuccessful attempt at what this class seems to do successfully.
Inheritance: System.Windows.Forms.Control.ControlAccessibleObject
Datei anzeigen Open project: sillsdev/FieldWorks Class Usage Examples

Private Properties

Property Type Description
MakeRelatedWrapper System.Windows.Forms.AccessibleObject

Public Methods

Method Description
AccessibilityWrapper ( SimpleRootSite rootSite, Accessibility comAccessible ) : System

Make one. The root site is used in case comAccessible is null, to keep trying for a valid one later when the root box has been created.

GetChild ( int index ) : System.Windows.Forms.AccessibleObject

One of many methods that delegate to the IAccessible, with a suitable default if it is null.

GetChildCount ( ) : int

One of many methods that delegate to the IAccessible, with a suitable default if it is null.

HitTest ( int x, int y ) : System.Windows.Forms.AccessibleObject

One of many methods that delegate to the IAccessible, with a suitable default if it is null.

Navigate ( AccessibleNavigation navdir ) : System.Windows.Forms.AccessibleObject

One of many methods that delegate to the IAccessible, with a suitable default if it is null. Not directly tested so far...this will work provided the navdir enum uses the same values as the old C++ defines for NAVDIR_DOWN etc. ///

Private Methods

Method Description
MakeRelatedWrapper ( Accessibility iAccessible ) : System.Windows.Forms.AccessibleObject

Used wherever we need a C# AccessibleObject for some child. Note that this is NOT a wrapper for the whole contents of the rootsite, so we do NOT want to make one with its IAccessible null, because that would turn around and retrieve the IAccessible for the whole rootsite. I think we could make one with rootsite null, except that we have an assertion to prevent that! So just return null if we don't actually have a related IAccessible to wrap.

Method Details

AccessibilityWrapper() public method

Make one. The root site is used in case comAccessible is null, to keep trying for a valid one later when the root box has been created.
public AccessibilityWrapper ( SimpleRootSite rootSite, Accessibility comAccessible ) : System
rootSite SimpleRootSite
comAccessible Accessibility
return System

GetChild() public method

One of many methods that delegate to the IAccessible, with a suitable default if it is null.
public GetChild ( int index ) : System.Windows.Forms.AccessibleObject
index int
return System.Windows.Forms.AccessibleObject

GetChildCount() public method

One of many methods that delegate to the IAccessible, with a suitable default if it is null.
public GetChildCount ( ) : int
return int

HitTest() public method

One of many methods that delegate to the IAccessible, with a suitable default if it is null.
public HitTest ( int x, int y ) : System.Windows.Forms.AccessibleObject
x int
y int
return System.Windows.Forms.AccessibleObject

Navigate() public method

One of many methods that delegate to the IAccessible, with a suitable default if it is null. Not directly tested so far...this will work provided the navdir enum uses the same values as the old C++ defines for NAVDIR_DOWN etc. ///
public Navigate ( AccessibleNavigation navdir ) : System.Windows.Forms.AccessibleObject
navdir AccessibleNavigation
return System.Windows.Forms.AccessibleObject