예제 #1
0
 /// <summary>
 /// Create an accessible object from an IAccessible instance and a child ID.
 /// </summary>
 public SystemAccessibleObject(IAccessible iacc, int childID)
 {
     if (iacc == null)
     {
         throw new ArgumentNullException();
     }
     //if (childID < 0) throw new ArgumentException();
     if (childID != 0)
     {
         try
         {
             object realChild = iacc.get_accChild(childID);
             if (realChild != null)
             {
                 iacc    = (IAccessible)realChild;
                 childID = 0;
             }
         }
         //catch (ArgumentException) { }
         //catch (InvalidCastException) { }
         catch (Exception) { } // general error handling, e.g. IBM/Lotus Notes otherwise crashes with COMException here
     }
     this.iacc    = iacc;
     this.childID = childID;
 }
예제 #2
0
 public override AccessibleObject GetChild(int index)
 {
     try {
         object o = acc.get_accChild(index);
         if (o == null && this.GetChildCount() > 0)
         {
             return(new SystemAccessible(this, this.acc, index));
         }
         return(Wrap(o));
     } catch {
         return(null);
     }
 }
예제 #3
0
        /// <summary>
        ///     Create an accessible object from an IAccessible instance and a child ID.
        /// </summary>
        public SystemAccessibleObject(IAccessible iacc, int childID)
        {
            if (iacc == null)
            {
                throw new ArgumentNullException();
            }
            //if (childID < 0) throw new ArgumentException();
            if (childID != 0)
            {
                try {
                    object realChild = iacc.get_accChild(childID);
                    if (realChild != null)
                    {
                        iacc    = (IAccessible)realChild;
                        childID = 0;
                    }
                } catch (ArgumentException) { }
            }

            IAccessible = iacc;
            ChildID     = childID;
        }
예제 #4
0
 object?IAccessibleInternal.get_accChild(object childID)
 => AsNativeAccessible(publicIAccessible.get_accChild(childID));
예제 #5
0
 /// <summary>
 /// Create an accessible object from an IAccessible instance and a child ID.
 /// </summary>
 public SystemAccessibleObject(IAccessible iacc, int childID)
 {
     if (iacc == null) throw new ArgumentNullException();
     //if (childID < 0) throw new ArgumentException();
     if (childID != 0)
     {
         try
         {
             object realChild = iacc.get_accChild(childID);
             if (realChild != null)
             {
                 iacc = (IAccessible)realChild;
                 childID = 0;
             }
         }
         //catch (ArgumentException) { }
         //catch (InvalidCastException) { }
         catch (Exception) { } // general error handling, e.g. IBM/Lotus Notes otherwise crashes with COMException here
     }
     this.iacc = iacc;
     this.childID = childID;
 }
 /// <summary>
 /// Create an accessible object from an IAccessible instance and a child ID.
 /// </summary>
 public SystemAccessibleObject(IAccessible iacc, int childID)
 {
     if (iacc == null) throw new ArgumentNullException();
     //if (childID < 0) throw new ArgumentException();
     if (childID != 0)
     {
         try
         {
             object realChild = iacc.get_accChild(childID);
             if (realChild != null)
             {
                 iacc = (IAccessible)realChild;
                 childID = 0;
             }
         }
         catch (ArgumentException) { }
     }
     this.iacc = iacc;
     this.childID = childID;
 }
예제 #7
0
        // CreateObjRef not overridden; not sure of relevance.
        // DoDefaultAction not yet delegated.
        // Equals not delegated.

        /// <summary>
        /// The nth child. Apparently they don't have to be indexed sequentially...
        /// perhaps MS expects you to use Navigate(next)? The Views impl indexes
        /// children sequentially starting from 1.
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public override AccessibleObject GetChild(int index)
        {
            return(new AccessibleObjectFromIAccessible((IAccessible)(m_acc.get_accChild(index))));
        }
예제 #8
0
        // Gets an IAccessible and idChild for an object that may be a full IAccessible or a ChildID of 'parent'
        private static void IAccessibleFromObject(object obj, IAccessible parent, out IAccessible acc, out int idChild)
        {
            idChild = 0;
            acc = obj as IAccessible;

            // first see if o is a full IAccessible object
            if (acc != null)
            {
                idChild = NativeMethods.CHILD_SELF;
            }
            else if (obj is int)
            {
                // call get_accChild to check if the object has its own IAccessible...
                object test = null;
                try
                {
                    try
                    {
                        test = parent.get_accChild((int)obj);
                    }
                    catch (System.Security.SecurityException)
                    {
                        // Workaround for Partial Trust [....] issue - they sometimes return
                        // a security error - use workaround to get a new IAccessible for the same
                        // object, and retry...
                        IAccessible accNew = WashPartialTrustWinformsAccessible(parent);
                        if (accNew != null)
                            test = accNew.get_accChild((int)obj);
                    }
                }
                catch (Exception e)
                {
                    // Some impls of get_accChild return inappropriate error codes (eg. Trident
                    // used to return E_INVALIDCAST; others returned E_FAIL). To be more robust,
                    // do what the MSAA tools (eg. inspect etc) do and ignore the error, using
                    // the VT_I4 to access the child instead. If there really is an error, we'll
                    // hit it when we try to access the child itself.
                    // Some impls (MediaPlayer) return E_POINTER, which translates
                    // to NullReferenceException; ignore that also.
                    if (Misc.IsCriticalException(e) && ! (e is NullReferenceException))
                    {
                        throw;
                    }
                }

                if (test is IAccessible)
                {
                    acc = (IAccessible)test;
                    idChild = NativeMethods.CHILD_SELF;
                }
                else
                {
                    // it is a ChildID and parent is handling
                    acc = parent;
                    idChild = (int)obj;
                }
            }
        }
 object UnsafeNativeMethods.IAccessibleInternal.get_accChild(object childID)
 {
     IntSecurity.UnmanagedCode.Assert();
     return(AsNativeAccessible(publicIAccessible.get_accChild(childID)));
 }