コード例 #1
0
        public static AutomationElement FromIAccessible(Accessibility.IAccessible acc, int childId)
        {
            Utility.ValidateArgumentNonNull(acc, "acc");

            try
            {
                UIAutomationClient.IUIAutomationElement element =
                    Automation.Factory.ElementFromIAccessibleBuildCache(
                        (UIAutomationClient.IAccessible)acc,
                        childId,
                        CacheRequest.CurrentNativeCacheRequest);
                return(AutomationElement.Wrap(element));
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #2
0
        void UIAutomationClient.IUIAutomationFocusChangedEventHandler.HandleFocusChangedEvent(
            UIAutomationClient.IUIAutomationElement sender)
        {
            // Can't set the arguments -- they come from a WinEvent handler.
            AutomationFocusChangedEventArgs args = new AutomationFocusChangedEventArgs(0, 0);

            _focusHandler(AutomationElement.Wrap(sender), args);
        }
コード例 #3
0
        void UIAutomationClient.IUIAutomationPropertyChangedEventHandler.HandlePropertyChangedEvent(
            UIAutomationClient.IUIAutomationElement sender,
            int propertyId,
            object newValue)
        {
            AutomationProperty property             = AutomationProperty.LookupById(propertyId);
            object             wrappedObj           = Utility.WrapObjectAsProperty(property, newValue);
            AutomationPropertyChangedEventArgs args = new AutomationPropertyChangedEventArgs(
                property,
                null,
                wrappedObj);

            this._propChangeHandler(AutomationElement.Wrap(sender), args);
        }
コード例 #4
0
        void UIAutomationClient.IUIAutomationEventHandler.HandleAutomationEvent(
            UIAutomationClient.IUIAutomationElement sender, int eventId)
        {
            AutomationEventArgs args;

            if (eventId != WindowPatternIdentifiers.WindowClosedEvent.Id)
            {
                args = new AutomationEventArgs(AutomationEvent.LookupById(eventId));
            }
            else
            {
                args = new WindowClosedEventArgs((int[])sender.GetRuntimeId());
            }
            _basicHandler(AutomationElement.Wrap(sender), args);
        }
コード例 #5
0
 public static AutomationElement FromHandle(IntPtr hwnd)
 {
     Utility.ValidateArgument(hwnd != IntPtr.Zero, "Hwnd cannot be null");
     try
     {
         UIAutomationClient.IUIAutomationElement element =
             Automation.Factory.ElementFromHandleBuildCache(hwnd, CacheRequest.CurrentNativeCacheRequest);
         return(AutomationElement.Wrap(element));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx))
         {
             throw newEx;
         }
         else
         {
             throw;
         }
     }
 }
コード例 #6
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;
         }
     }
 }
コード例 #7
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;
         }
     }
 }
コード例 #8
0
 internal AutomationElement(UIAutomationClient.IUIAutomationElement obj)
 {
     Debug.Assert(obj != null);
     this._obj = obj;
 }
コード例 #9
0
        void UIAutomationClient.IUIAutomationStructureChangedEventHandler.HandleStructureChangedEvent(UIAutomationClient.IUIAutomationElement sender, UIAutomationClient.StructureChangeType changeType, Array runtimeId)
        {
            StructureChangedEventArgs args = new StructureChangedEventArgs(
                (StructureChangeType)changeType,
                (int[])runtimeId);

            this._structureChangeHandler(AutomationElement.Wrap(sender), args);
        }
コード例 #10
0
 internal static AutomationElement Wrap(UIAutomationClient.IUIAutomationElement obj)
 {
     return((obj == null) ? null : new AutomationElement(obj));
 }
コード例 #11
0
 internal AutomationElement(UIAutomationClient.IUIAutomationElement obj)
 {
     Debug.Assert(obj != null);
     this._obj = obj;
 }