Wrap() static private method

static private Wrap ( UIAutomationClient obj ) : AutomationElement
obj UIAutomationClient
return AutomationElement
 public AutomationElement GetPreviousSibling(AutomationElement element, CacheRequest request)
 {
     Utility.ValidateArgumentNonNull(element, "element");
     Utility.ValidateArgumentNonNull(request, "request");
     try
     {
         return(AutomationElement.Wrap(this._obj.GetPreviousSiblingElementBuildCache(
                                           element.NativeElement,
                                           request.NativeCacheRequest)));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx))
         {
             throw newEx;
         }
         else
         {
             throw;
         }
     }
 }
Esempio n. 2
0
 public static AutomationElement FromPoint(Point pt)
 {
     try
     {
         UIAutomationClient.IUIAutomationElement element =
             Automation.Factory.ElementFromPointBuildCache(
                 Utility.PointManagedToNative(pt),
                 CacheRequest.CurrentNativeCacheRequest);
         return(AutomationElement.Wrap(element));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx))
         {
             throw newEx;
         }
         else
         {
             throw;
         }
     }
 }
Esempio n. 3
0
 public AutomationElement FindItemByProperty(AutomationElement startAfter, AutomationProperty property, object value)
 {
     try
     {
         return(AutomationElement.Wrap(
                    this._pattern.FindItemByProperty(
                        (startAfter == null) ? null : startAfter.NativeElement,
                        (property == null) ? 0 : property.Id,
                        Utility.UnwrapObject(value))));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx))
         {
             throw newEx;
         }
         else
         {
             throw;
         }
     }
 }
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        /// Find item by specified property/value. It will return
        /// placeholder which depending upon it's virtualization state may
        /// or may not have the information of the complete peer/Wrapper.
        ///
        /// Throws ArgumentException if the property requested is not one that the
        /// container supports searching over. Supports Name property, AutomationId,
        /// IsSelected and ControlType.
        ///
        /// This method is expected to be relatively slow, since it may need to
        /// traverse multiple objects in order to find a matching one.
        /// When used in a loop to return multiple items, no specific order is
        /// defined so long as each item is returned only once (ie. loop should
        /// terminate). This method is also item-centric, not UI-centric, so items
        /// with multiple UI representations need only be returned once.
        ///
        /// A special propertyId of 0 means ‘match all items’. This can be used
        /// with startAfter=NULL to get the first item, and then to get successive
        /// items.
        /// </summary>
        /// <param name="startAfter">this represents the item after which the container wants to begin search</param>
        /// <param name="property">corresponds to property for whose value it want to search over.</param>
        /// <param name="value">value to be searched for, for specified property</param>
        /// <returns>The first item which matches the searched criterion, if no item matches, it returns null  </returns>
        public AutomationElement FindItemByProperty(AutomationElement startAfter, AutomationProperty property, object value)
        {
            SafeNodeHandle hNode;

            // Invalidate the "value" passed against the "property" before passing it to UIACore, Don't invalidate if search is being done for "null" property
            // FindItemByProperty supports find for null property.
            if (property != null)
            {
                value = PropertyValueValidateAndMap(property, value);
            }

            if (startAfter != null)
            {
                if (property != null)
                {
                    hNode = UiaCoreApi.ItemContainerPattern_FindItemByProperty(_hPattern, startAfter.RawNode, property.Id, value);
                }
                else
                {
                    hNode = UiaCoreApi.ItemContainerPattern_FindItemByProperty(_hPattern, startAfter.RawNode, 0, null);
                }
            }
            else
            {
                if (property != null)
                {
                    hNode = UiaCoreApi.ItemContainerPattern_FindItemByProperty(_hPattern, new SafeNodeHandle(), property.Id, value);
                }
                else
                {
                    hNode = UiaCoreApi.ItemContainerPattern_FindItemByProperty(_hPattern, new SafeNodeHandle(), 0, null);
                }
            }


            AutomationElement wrappedElement = AutomationElement.Wrap(hNode);

            return(wrappedElement);
        }
Esempio n. 5
0
 public AutomationElement FindFirst(TreeScope scope, Condition condition)
 {
     Utility.ValidateArgumentNonNull(condition, "condition");
     try
     {
         UIAutomationClient.IUIAutomationElement elem =
             this._obj.FindFirstBuildCache(
                 (UIAutomationClient.TreeScope)scope,
                 condition.NativeCondition,
                 CacheRequest.CurrentNativeCacheRequest);
         return(AutomationElement.Wrap(elem));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx))
         {
             throw newEx;
         }
         else
         {
             throw;
         }
     }
 }
Esempio n. 6
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods
        /// <summary>
        /// Obtain the AutomationElement at an zero based absolute position in the grid.
        /// Where 0,0 is top left
        /// </summary>
        /// <param name="row">Row of item to get</param>
        /// <param name="column">Column of item to get</param>
        ///
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public AutomationElement GetItem(int row, int column)
        {
            SafeNodeHandle hNode = UiaCoreApi.GridPattern_GetItem(_hPattern, row, column);

            return(AutomationElement.Wrap(hNode));
        }