Пример #1
0
        public void RemoveStructureChangedEventHandler(IElement element,
                                                       StructureChangedEventHandler eventHandler)
        {
            int handlerId = eventHandlerManager.GetStructureEventIdByHandler(eventHandler);

            if (handlerId == -1)
            {
                return;
            }

            if (element == null)
            {
                //the element is the RootElement
                RootElementEventsManager.RemoveStructureEventRequest(handlerId);
                foreach (var entry in GetUiaApplications())
                {
                    entry.Value.RemoveRootElementStructureChangedEventHandler(handlerId);
                }
            }
            else
            {
                UiaDbusElement uiaDbusElement = element as UiaDbusElement;
                if (uiaDbusElement == null)
                {
                    Log.Error("[RemoveStructureChangedEventHandler] " +
                              "The element sent to UiaDbusSource is not UiaDbusElement");
                    return;
                }
                string           busName = uiaDbusElement.BusName;
                DCI.IApplication app     = Bus.Session.GetObject <DCI.IApplication> (busName,
                                                                                     new ObjectPath(DC.Constants.ApplicationPath));
                int [] runtimeId = uiaDbusElement.RuntimeId;
                app.RemoveStructureChangedEventHandler(runtimeId, handlerId);
            }
        }
 StructureChangedEventHandlerImpl(
     IUIAutomationElement uiAutomationElement,
     StructureChangedEventHandler handlingDelegate)
 {
     this._uiAutomationElement = uiAutomationElement;
     this._handlingDelegate    = handlingDelegate;
 }
Пример #3
0
 public StructureChangedEventEntry(IRawElementProviderSimple provider,
                                   TreeScope scope,
                                   StructureChangedEventHandler handler)
     : base(provider, scope)
 {
     this.Handler = handler;
 }
Пример #4
0
 /// -------------------------------------------------------------------
 /// <summary>
 /// Method that registers the event handler OnEvent()
 /// </summary>
 /// -------------------------------------------------------------------
 public virtual void AddEventHandler(AutomationElement element, TreeScope treeScope)
 {
     base.AddEventHandler();
     Comment("Adding AddLogicalStructureChangedEventHandler(el, " + treeScope + ")");
     handler = new StructureChangedEventHandler(OnEvent);
     Automation.AddStructureChangedEventHandler(element, treeScope, handler);
 }
Пример #5
0
        ///--------------------------------------------------------------------
        /// <summary>
        /// Initialize both client and target applications.
        /// </summary>
        /// <param name="args">Startup arguments</param>
        ///--------------------------------------------------------------------
        protected override void OnStartup(StartupEventArgs args)
        {
            // Create our informational window
            CreateWindow();

            // Get the root element from our target application.
            // In general, you should try to obtain only direct children of
            // the RootElement. A search for descendants may iterate through
            // hundreds or even thousands of elements, possibly resulting in
            // a stack overflow. If you are attempting to obtain a specific
            // element at a lower level, you should start your search from the
            // application window or from a container at a lower level.
            targetApp =
                System.Windows.Forms.Application.StartupPath + "\\Target.exe";
            rootElement = StartApp(targetApp);
            if (rootElement == null)
            {
                return;
            }

            // Add a structure change listener for the root element.
            StructureChangedEventHandler structureChange =
                new StructureChangedEventHandler(ChildElementsAdded);

            Automation.AddStructureChangedEventHandler(
                rootElement, TreeScope.Descendants, structureChange);

            // Iterate through the controls in the target application.
            FindTreeViewsInTarget();
        }
Пример #6
0
 public static void AddStructureChangedEventHandler(
     AutomationElement element,
     TreeScope scope,
     StructureChangedEventHandler eventHandler)
 {
     StructureChangedEventHandlerImpl.Add(element: element, scope: scope, handlingDelegate: eventHandler);
 }
Пример #7
0
 public LoginUITest(AutoResetEvent eventControl = null)
 {
     user     = ConfigurationManager.AppSettings["user"];
     password = ConfigurationManager.AppSettings["password"];
     structureChangedEventHandler = new StructureChangedEventHandler(OnStructureChanged);
     LoginUITest.eventControl     = eventControl;
 }
Пример #8
0
 internal StructureChangedEventHandlerData(IElement element,
                                           TreeScope scope,
                                           StructureChangedEventHandler eventHandler)
 {
     this.Element      = element;
     this.Scope        = scope;
     this.EventHandler = eventHandler;
 }
Пример #9
0
 public override void Start(IEventSink sink)
 {
     Validate.ArgumentNotNull(parameter: sink, parameterName: nameof(sink));
     Stop();
     this._sinkReference    = new WeakReference(target: sink);
     this._handlingDelegate = Handler;
     Automation.AddStructureChangedEventHandler(element: this._root.AutomationElement, scope: (TreeScope)this._scope, eventHandler: this._handlingDelegate);
 }
Пример #10
0
		public static void AddStructureChangedEventHandler (
			IRawElementProviderSimple provider, TreeScope scope,
			StructureChangedEventHandler eventHandler)
		{
			var entry = new StructureChangedEventEntry (provider, scope, eventHandler);
			lock (structureChangedEventEntries)
				structureChangedEventEntries.Add (entry);
		}
Пример #11
0
        /// <summary>
        /// Initializes UI automation by finding the target form, adding event handlers,
        /// and displaying the current automation element structure.
        /// </summary>
        /// <returns>true on success; otherwise, false.</returns>
        public bool StartListening()
        {
            bool returnCode = false;
            AutomationElement rootElement = AutomationElement.RootElement;

            // Set a property condition that will be used to find the main form of the
            // target application. myTestForm is the name of the Form and in the case
            // of a WinForms control, it is also the AutomationId of the element representing the control.
            Condition cond = new PropertyCondition(AutomationElement.AutomationIdProperty, "myTestForm");

            // Find the main window of the target application.
            AutomationElement mainWindowElement = rootElement.FindFirst(TreeScope.Element | TreeScope.Children, cond);

            if (mainWindowElement == null)
            {
                MessageBox.Show("Could not find the main form for the target application.");
                returnCode = false;
            }
            else
            {
                // Find the "Show supported patterns" checkbox and add an event handler for when
                // the toggle state changes.
                AutomationElement    elementCheckBox = FindByAutomationId(mainWindowElement, "chkbxShowPatterns");
                AutomationProperty[] propsWanted     = { TogglePattern.ToggleStateProperty };

                if (elementCheckBox != null)
                {
                    if ((bool)elementCheckBox.GetCurrentPropertyValue(AutomationElement.IsTogglePatternAvailableProperty) == true)
                    {
                        IsElementToggledOn(elementCheckBox);
                        AutomationPropertyChangedEventHandler _onToggleStateChanged =
                            new AutomationPropertyChangedEventHandler(OnToggleStateChanged);
                        Automation.AddAutomationPropertyChangedEventHandler(elementCheckBox,
                                                                            TreeScope.Element,
                                                                            _onToggleStateChanged,
                                                                            propsWanted);
                    }
                }
                // Find the "UIAutomation is listening" textbox.
                listenElement = FindByAutomationId(mainWindowElement, "tbListen");

                // Find the tab control and add an event handler for when the automation tree structure changes.
                // This event will be raised whenever the user selects a tab.
                tabElement = FindByAutomationId(mainWindowElement, "tabControl1");
                if (tabElement != null)
                {
                    StructureChangedEventHandler _onStructureChanged = new StructureChangedEventHandler(onStructureChanged);
                    Automation.AddStructureChangedEventHandler(tabElement, TreeScope.Descendants, _onStructureChanged);
                }
                string StructureDescription = GetAutomationStructure(tabElement);
                ShowStructure(StructureDescription);
                // Check the "UIAutomation is listening" checkbox in the target application.
                InformTarget(true);

                returnCode = true;
            }
            return(returnCode);
        }
Пример #12
0
        public void StructureEventTest()
        //this test also tested WindowPattern.WindowOpenedEvent (i.e. AddAutomationEventHandler)
        {
            int                    automationEventCount = 0;
            int                    structureEventCount  = 0;
            AutomationEvent        eventId = null;
            AutomationEventHandler automationEventHandler = (o, e) =>
            {
                automationEventCount++;
                eventId = e.EventId;
            };

            At.AddAutomationEventHandler(
                WindowPattern.WindowOpenedEvent,
                AutomationElement.RootElement, TreeScope.Children,
                automationEventHandler);
            StructureChangedEventHandler structureEventHandler = (o, e) =>
            {
                if (e.StructureChangeType == StructureChangeType.ChildAdded)
                {
                    structureEventCount++;
                }
            };

            At.AddStructureChangedEventHandler(
                AutomationElement.RootElement, TreeScope.Children, structureEventHandler);
            int pid = OpenForm();

            Thread.Sleep(3000);
            Assert.AreEqual(1, structureEventCount, "[OpenForm] count of StructureChangedEvent");
            Assert.AreEqual(1, automationEventCount, "[OpenForm] count of WindowOpenedEvent");
            Assert.AreEqual(WindowPattern.WindowOpenedEvent, eventId);

            automationEventCount = 0;
            structureEventCount  = 0;
            At.RemoveAllEventHandlers();
            int pid2 = OpenForm();

            Thread.Sleep(3000);
            Assert.AreEqual(0, structureEventCount);
            Assert.AreEqual(0, automationEventCount);

            structureEventHandler = (o, e) =>
            {
                structureEventCount++;
            };
            At.AddStructureChangedEventHandler(
                AutomationElement.RootElement, TreeScope.Children, structureEventHandler);
            CloseForm(pid);
            CloseForm(pid2);
            Thread.Sleep(3000);
            // Note: I expect 2 events here (whose StructureChangeType are both ChildRemoved)
            // But as tested on Win 7, we'll actually get no event,
            // And with our current implementation, we'll get 4 events (i.e. besides the 2 expected events, we
            // get other 2 ChildRemoved events, whose sender is the "testFormElement")
            Assert.AreEqual(0, structureEventCount, "[CloseForm] count of StructureChangedEvent");
        }
Пример #13
0
        public void AddStructureChangedEventHandler(IElement element,
                                                    TreeScope scope,
                                                    StructureChangedEventHandler eventHandler)
        {
            StructureChangedEventHandlerData data = new StructureChangedEventHandlerData(
                element, scope, eventHandler);

            structureEventHandlers.Add(data);
        }
Пример #14
0
        public void StructureEventTest()
        {
            List <AutomationElement>     elementEventSenders      = new List <AutomationElement> ();
            List <StructureChangeType>   elementEventChangeTypes  = new List <StructureChangeType> ();
            List <AutomationElement>     childrenEventSenders     = new List <AutomationElement> ();
            List <StructureChangeType>   childrenEventChangeTypes = new List <StructureChangeType> ();
            StructureChangedEventHandler elementHandler           = delegate(object sender, StructureChangedEventArgs args) {
                elementEventSenders.Add(sender as AutomationElement);
                elementEventChangeTypes.Add(args.StructureChangeType);
            };

            At.AddStructureChangedEventHandler(panel1Element, TreeScope.Element, elementHandler);
            StructureChangedEventHandler childrenHandler = delegate(object sender, StructureChangedEventArgs args) {
                childrenEventSenders.Add(sender as AutomationElement);
                childrenEventChangeTypes.Add(args.StructureChangeType);
            };

            At.AddStructureChangedEventHandler(panel1Element, TreeScope.Children, childrenHandler);
            InvokePattern addAction    = (InvokePattern)btnAddTextboxElement.GetCurrentPattern(InvokePattern.Pattern);
            InvokePattern removeAction = (InvokePattern)btnRemoveTextboxElement.GetCurrentPattern(InvokePattern.Pattern);

            addAction.Invoke();
            Thread.Sleep(1000);
            Assert.AreEqual(1, elementEventSenders.Count, "Check event count");
            Assert.AreEqual(panel1Element, elementEventSenders [0], "Check ChildrenInvalidated event sender");
            Assert.AreEqual(StructureChangeType.ChildrenInvalidated,
                            elementEventChangeTypes [0], "Check ChildrenInvalidated event type");
            Assert.AreEqual(1, childrenEventSenders.Count, "Check event count");
            Assert.AreEqual(StructureChangeType.ChildAdded,
                            childrenEventChangeTypes [0], "Check ChildAdded event type");
            removeAction.Invoke();
            Thread.Sleep(1000);
            Assert.AreEqual(3, elementEventSenders.Count, "Check event count");
            Assert.AreEqual(panel1Element, elementEventSenders [1], "Check event sender");
            Assert.AreEqual(panel1Element, elementEventSenders [2], "Check event sender");
            Assert.IsTrue((elementEventChangeTypes [1] == StructureChangeType.ChildRemoved &&
                           elementEventChangeTypes [2] == StructureChangeType.ChildrenInvalidated) ||
                          (elementEventChangeTypes [1] == StructureChangeType.ChildrenInvalidated &&
                           elementEventChangeTypes [2] == StructureChangeType.ChildRemoved),
                          "Check event type");
            addAction.Invoke();
            Thread.Sleep(1000);
            Assert.AreEqual(4, elementEventSenders.Count, "Check event count");
            Assert.AreEqual(panel1Element, elementEventSenders [3], "Check ChildrenInvalidated event sender");
            Assert.AreEqual(StructureChangeType.ChildrenInvalidated,
                            elementEventChangeTypes [3], "Check ChildrenInvalidated event type");
            Assert.AreEqual(2, childrenEventSenders.Count, "Check event count");
            Assert.AreEqual(StructureChangeType.ChildAdded,
                            childrenEventChangeTypes [1], "Check ChildAdded event type");

            At.RemoveStructureChangedEventHandler(panel1Element, elementHandler);
            At.RemoveStructureChangedEventHandler(panel1Element, childrenHandler);
            addAction.Invoke();
            Thread.Sleep(1000);
            Assert.AreEqual(4, elementEventSenders.Count, "Element event count didn't change");
            Assert.AreEqual(2, childrenEventSenders.Count, "Children event count didn't change");
        }
Пример #15
0
        // </Snippet101>

        // <Snippet102>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Set up grid event listeners.
        /// </summary>
        /// <param name="targetControl">
        /// The automation element of interest.
        /// </param>
        ///--------------------------------------------------------------------
        private void SetGridEventListeners(AutomationElement targetControl)
        {
            StructureChangedEventHandler gridStructureChangedListener = 
                new StructureChangedEventHandler(OnGridStructureChange);
            Automation.AddStructureChangedEventHandler(
                targetControl, 
                TreeScope.Element, 
                gridStructureChangedListener);
        }
Пример #16
0
        public static void AddStructureChangedEventHandler(
            IRawElementProviderSimple provider, TreeScope scope,
            StructureChangedEventHandler eventHandler)
        {
            var entry = new StructureChangedEventEntry(provider, scope, eventHandler);

            lock (structureChangedEventEntries)
                structureChangedEventEntries.Add(entry);
        }
Пример #17
0
 public override void Stop()
 {
     if (!IsStarted)
     {
         return;
     }
     Automation.RemoveStructureChangedEventHandler(element: this._root.AutomationElement, eventHandler: this._handlingDelegate);
     this._handlingDelegate = null;
     this._sinkReference    = null;
 }
        internal static void Add(
            AutomationElement element,
            TreeScope scope,
            StructureChangedEventHandler handlingDelegate)
        {
            var e            = new StructureChangedEventHandlerImpl(uiAutomationElement: element.IUIAutomationElement, handlingDelegate: handlingDelegate);
            var cacheRequest = AutomationElement.DefaultCacheRequest.IUIAutomationCacheRequest;

            Boundary.UIAutomation(a: () => Automation.AutomationClass.AddStructureChangedEventHandler(element: e._uiAutomationElement, scope: UiaConvert.Convert(treeScope: scope), cacheRequest: cacheRequest, handler: e));
            Add(instance: e);
        }
Пример #19
0
 public override void Observe()
 {
     try
     {
         _eventHandler = new StructureChangedEventHandler(OnEvent);
         Automation.AddStructureChangedEventHandler(AutomationElement.RootElement, TreeScope.Descendants, _eventHandler);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Print($"{ex.Message}");
     }
 }
Пример #20
0
        public void RemoveStructureChangedEventHandler(IElement element, StructureChangedEventHandler eventHandler)
        {
            if (element == null)
            {
                return;
            }
            ClientElement clientElement = element as ClientElement;

            if (clientElement == null)
            {
                Log.Error("[ClientAutomationSource.RemoveStructureChangedEventHandler] Not ClientElement");
                return;
            }
            ClientEventManager.RemoveStructureChangedEventHandler(
                clientElement.Provider, eventHandler);
        }
Пример #21
0
        public void RemoveStructureChangedEventHandler(IElement element,
                                                       StructureChangedEventHandler eventHandler)
        {
            List <StructureChangedEventHandlerData> handlersToDelete = new List <StructureChangedEventHandlerData> ();

            foreach (var handlerData in structureEventHandlers)
            {
                if (handlerData.Element == element && handlerData.EventHandler == eventHandler)
                {
                    handlersToDelete.Add(handlerData);
                }
            }
            foreach (var h in handlersToDelete)
            {
                structureEventHandlers.Remove(h);
            }
        }
Пример #22
0
        public static void RemoveStructureChangedEventHandler(
            AutomationElement element, StructureChangedEventHandler eventHandler)
        {
            ArgumentCheck.NotNull(element, "element");
            ArgumentCheck.NotNull(eventHandler, "eventHandler");

            if (element == AutomationElement.RootElement)
            {
                foreach (var source in SourceManager.GetAutomationSources())
                {
                    source.RemoveStructureChangedEventHandler(
                        null, eventHandler);
                }
            }
            else
            {
                var source = element.SourceElement.AutomationSource;
                source.RemoveStructureChangedEventHandler(
                    element.SourceElement, eventHandler);
            }
        }
Пример #23
0
 public void AddStructureChangedEventHandler(IElement element,
                                             TreeScope scope,
                                             StructureChangedEventHandler eventHandler)
 {
     if (element == null)
     {
         //the element is the RootElement
         // TODO clean up registered handlers when they're removed
         int handlerId = eventHandlerManager.RegisterStructureEventHandler(eventHandler);
         RootElementEventsManager.AddStructureEventRequest(scope, handlerId);
         foreach (var entry in GetUiaApplications())
         {
             string busName = entry.Key;
             var    app     = entry.Value;
             EnsureStructureEventsSetUp(app, busName);
             app.AddRootElementStructureChangedEventHandler(
                 scope, handlerId);
         }
     }
     else
     {
         UiaDbusElement uiaDbusElement = element as UiaDbusElement;
         if (uiaDbusElement == null)
         {
             Log.Error("[AddStructureChangedEventHandler] The element sent to UiaDbusSource is not UiaDbusElement");
             return;
         }
         string           busName = uiaDbusElement.BusName;
         DCI.IApplication app     = Bus.Session.GetObject <DCI.IApplication> (busName,
                                                                              new ObjectPath(DC.Constants.ApplicationPath));
         int [] runtimeId = uiaDbusElement.RuntimeId;
         int    handlerId = eventHandlerManager.RegisterStructureEventHandler(eventHandler);
         EnsureStructureEventsSetUp(app, busName);
         app.AddStructureChangedEventHandler(runtimeId, scope, handlerId);
     }
 }
Пример #24
0
 public override void Add(WrappedEventHandler handler, AutomationElementWrapper element)
 {
     _handler = (o, e) => handler(element, e);
     _element = element.Element;
     Automation.AddStructureChangedEventHandler(_element, _scope, _handler);
 }
Пример #25
0
 public static IDisposable ToStructureChangedEvent(AutomationElement element, TreeScope treeScope, StructureChangedEventHandler handler)
 {
     Automation.AddStructureChangedEventHandler(element, treeScope, handler);
     return(Disposable.Create(() => Automation.RemoveStructureChangedEventHandler(element, handler)));
 }
Пример #26
0
 /// -------------------------------------------------------------------
 /// <summary>
 /// Method that registers the event handler OnEvent()
 /// </summary>
 /// -------------------------------------------------------------------
 public virtual void AddEventHandler(AutomationElement element, TreeScope treeScope)
 {
     base.AddEventHandler();
     Comment("Adding AddLogicalStructureChangedEventHandler(el, " + treeScope + ")");
     handler = new StructureChangedEventHandler(OnEvent);
     Automation.AddStructureChangedEventHandler(element, treeScope, handler);
 }
Пример #27
0
        /// <summary>
        /// Called by a client to add a listener for structure change events.
        /// </summary>
        /// <param name="element">Element on which to listen for structure change events.</param>
        /// <param name="scope">Specifies whether to listen to property changes events on the specified element, and/or its ancestors and children.</param>
        /// <param name="eventHandler">Delegate to call when a structure change event occurs.</param>
        /// 
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public static void AddStructureChangedEventHandler(AutomationElement element, TreeScope scope, StructureChangedEventHandler eventHandler)
        {
            Misc.ValidateArgumentNonNull(element, "element");
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler");

            // Add a client-side listener for for this event request
            EventListener l = new EventListener(AutomationElement.StructureChangedEvent, scope, null, CacheRequest.CurrentUiaCacheRequest);

            ClientEventManager.AddListener(element, eventHandler, l);
        }
Пример #28
0
        public static void AddStructureChangedEventHandler(AutomationElement element, TreeScope scope, StructureChangedEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");

            try
            {
                StructureEventListener listener = new StructureEventListener(AutomationElement.StructureChangedEvent, element, eventHandler);
                Factory.AddStructureChangedEventHandler(
                    element.NativeElement,
                    (UIAutomationClient.TreeScope)scope,
                    CacheRequest.CurrentNativeCacheRequest,
                    listener);
                ClientEventList.Add(listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }
Пример #29
0
        // </SnippetPlayback>

        //private void OnFocusChange(object src, PropertyChangedEventArgs e)
        //{
        //    FocusHandler focusedElement = src as FocusHandler;
        //    ElementStore focusChange = new ElementStore();
        //    try
        //    {
        //        focusChange.AutomationID = focusedElement.CurrentlyFocusedElement.Current.AutomationId;
        //        focusChange.ClassName = focusedElement.CurrentlyFocusedElement.Current.ClassName;
        //        focusChange.ControlType = focusedElement.CurrentlyFocusedElement.Current.ControlType.ProgrammaticName;
        //        focusChange.EventID = e.PropertyName;
        //        focusChange.SupportedPatterns = focusedElement.CurrentlyFocusedElement.GetSupportedPatterns();
        //        //if (elementStore.Contains(focusChange))
        //        //{
        //        //    return;
        //        //}
        //        elementStore.Enqueue(focusChange);
        //    }
        //    catch (NullReferenceException)
        //    {
        //        return;
        //    }
        //}

        private void RegisterStructureChangeEventListener(AutomationElement targetApp)
        {
            StructureChangedEventHandler structureChangeListener = new StructureChangedEventHandler(OnStructureChange);

            Automation.AddStructureChangedEventHandler(targetApp, TreeScope.Descendants, structureChangeListener);
        }
Пример #30
0
        public static void AddStructureChangedEventHandler(AutomationElement element, TreeScope scope, StructureChangedEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");

            try
            {
                StructureEventListener listener = new StructureEventListener(AutomationElement.StructureChangedEvent, element, eventHandler);
                Factory.AddStructureChangedEventHandler(
                    element.NativeElement,
                    (UIAutomationClient.TreeScope)scope,
                    CacheRequest.CurrentNativeCacheRequest,
                    listener);
                ClientEventList.Add(listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
        }
Пример #31
0
		public void AddStructureChangedEventHandler (IElement element,
		                                             TreeScope scope,
		                                             StructureChangedEventHandler eventHandler)
		{
			if (element == null) {
				//the element is the RootElement
				// TODO clean up registered handlers when they're removed
				int handlerId = eventHandlerManager.RegisterStructureEventHandler (eventHandler);
				RootElementEventsManager.AddStructureEventRequest (scope, handlerId);
				foreach (var entry in GetUiaApplications ()) {
					string busName = entry.Key;
					var app = entry.Value;
					EnsureStructureEventsSetUp (app, busName);
					app.AddRootElementStructureChangedEventHandler (
						scope, handlerId);
				}
			} else {
				UiaDbusElement uiaDbusElement = element as UiaDbusElement;
				if (uiaDbusElement == null) {
					Log.Error ("[AddStructureChangedEventHandler] The element sent to UiaDbusSource is not UiaDbusElement");
					return;
				}
				string busName = uiaDbusElement.BusName;
				DCI.IApplication app = Bus.Session.GetObject<DCI.IApplication> (busName,
					new ObjectPath (DC.Constants.ApplicationPath));
				int [] runtimeId = uiaDbusElement.RuntimeId;
				int handlerId = eventHandlerManager.RegisterStructureEventHandler (eventHandler);
				EnsureStructureEventsSetUp (app, busName);
				app.AddStructureChangedEventHandler (runtimeId, scope, handlerId);
			}
		}
Пример #32
0
        /// <summary>
        /// Called by a client to add a listener for structure change events.
        /// </summary>
        /// <param name="element">Element on which to listen for structure change events.</param>
        /// <param name="scope">Specifies whether to listen to property changes events on the specified element, and/or its ancestors and children.</param>
        /// <param name="eventHandler">Delegate to call when a structure change event occurs.</param>
        ///
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public static void AddStructureChangedEventHandler(AutomationElement element, TreeScope scope, StructureChangedEventHandler eventHandler)
        {
            Misc.ValidateArgumentNonNull(element, "element");
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler");

            // Add a client-side listener for for this event request
            EventListener l = new EventListener(AutomationElement.StructureChangedEvent, scope, null, CacheRequest.CurrentUiaCacheRequest);

            ClientEventManager.AddListener(element, eventHandler, l);
        }
Пример #33
0
		public static void RemoveStructureChangedEventHandler (IRawElementProviderSimple provider, StructureChangedEventHandler eventHandler)
		{
			lock (structureChangedEventEntries)
				structureChangedEventEntries.RemoveAll (e =>
					e.Provider == provider &&
					e.Handler == eventHandler);
		}
Пример #34
0
		internal StructureChangedEventHandlerData (IElement element,
			TreeScope scope,
			StructureChangedEventHandler eventHandler)
		{
			this.Element = element;
			this.Scope = scope;
			this.EventHandler = eventHandler;
		}
Пример #35
0
			public StructureChangedEventEntry (IRawElementProviderSimple provider,
			                                   TreeScope scope,
			                                   StructureChangedEventHandler handler)
				: base (provider, scope)
			{
				this.Handler = handler;
			}
Пример #36
0
		public void AddStructureChangedEventHandler (IElement element, TreeScope scope, StructureChangedEventHandler eventHandler)
		{
			if (element == null)
				return;
			ClientElement clientElement = element as ClientElement;
			if (clientElement == null) {
				Log.Error ("[ClientAutomationSource.AddStructureChangedEventHandler] Not ClientElement");
				return;
			}
			ClientEventManager.AddStructureChangedEventHandler (clientElement.Provider,
				scope, eventHandler);
		}
Пример #37
0
		public static void RemoveStructureChangedEventHandler (
			AutomationElement element, StructureChangedEventHandler eventHandler)
		{
			ArgumentCheck.NotNull (element, "element");
			ArgumentCheck.NotNull (eventHandler, "eventHandler");

			if (element == AutomationElement.RootElement)
				foreach (var source in SourceManager.GetAutomationSources ())
					source.RemoveStructureChangedEventHandler (
						null, eventHandler);
			else {
				var source = element.SourceElement.AutomationSource;
				source.RemoveStructureChangedEventHandler (
					element.SourceElement, eventHandler);
			}
		}
Пример #38
0
        protected internal void SubscribeToEvents(HasControlInputCmdletBase cmdlet,
                                                  AutomationElement inputObject,
                                                  AutomationEvent eventType,
                                                  AutomationProperty prop)
        {
            AutomationEventHandler uiaEventHandler;
            AutomationPropertyChangedEventHandler uiaPropertyChangedEventHandler;
            StructureChangedEventHandler uiaStructureChangedEventHandler;
            AutomationFocusChangedEventHandler uiaFocusChangedEventHandler;

            // 20130109
            if (null == CurrentData.Events) {
                CurrentData.InitializeEventCollection();
            }

            try {

                CacheRequest cacheRequest = new CacheRequest();
                cacheRequest.AutomationElementMode = AutomationElementMode.Full; //.None;
                cacheRequest.TreeFilter = Automation.RawViewCondition;
                cacheRequest.Add(AutomationElement.NameProperty);
                cacheRequest.Add(AutomationElement.AutomationIdProperty);
                cacheRequest.Add(AutomationElement.ClassNameProperty);
                cacheRequest.Add(AutomationElement.ControlTypeProperty);
                //cacheRequest.Add(AutomationElement.ProcessIdProperty);
                // cache patterns?

                // cacheRequest.Activate();
                cacheRequest.Push();

                switch (eventType.ProgrammaticName) {
                    case "InvokePatternIdentifiers.InvokedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the InvokedEvent handler");
                        Automation.AddAutomationEventHandler(
                            InvokePattern.InvokedEvent,
                            inputObject,
                            TreeScope.Element, // TreeScope.Subtree, // TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "TextPatternIdentifiers.TextChangedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the TextChangedEvent handler");
                        Automation.AddAutomationEventHandler(
                            TextPattern.TextChangedEvent,
                            inputObject,
                            TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "TextPatternIdentifiers.TextSelectionChangedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the TextSelectionChangedEvent handler");
                        Automation.AddAutomationEventHandler(
                            TextPattern.TextSelectionChangedEvent,
                            inputObject,
                            TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "WindowPatternIdentifiers.WindowOpenedProperty":
                        this.WriteVerbose(cmdlet, "subscribing to the WindowOpenedEvent handler");
                        Automation.AddAutomationEventHandler(
                            WindowPattern.WindowOpenedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.AutomationPropertyChangedEvent":
                        if (prop != null) {
                            this.WriteVerbose(cmdlet, "subscribing to the AutomationPropertyChangedEvent handler");
                            Automation.AddAutomationPropertyChangedEventHandler(
                                inputObject,
                                TreeScope.Subtree,
                                uiaPropertyChangedEventHandler =
                                    // new AutomationPropertyChangedEventHandler(OnUIAutomationPropertyChangedEvent),
                                    //new AutomationPropertyChangedEventHandler(handler),
                                    //new AutomationPropertyChangedEventHandler(((EventCmdletBase)cmdlet).AutomationPropertyChangedEventHandler),
                                    new AutomationPropertyChangedEventHandler(cmdlet.AutomationPropertyChangedEventHandler),
                                prop);
                            UIAHelper.WriteEventToCollection(cmdlet, uiaPropertyChangedEventHandler);
                            // 20130327
                            //this.WriteObject(cmdlet, uiaPropertyChangedEventHandler);
                            if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaPropertyChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        }
                        break;
                    case "AutomationElementIdentifiers.StructureChangedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the StructureChangedEvent handler");
                        Automation.AddStructureChangedEventHandler(
                            inputObject,
                            TreeScope.Subtree,
                            uiaStructureChangedEventHandler =
                            // new StructureChangedEventHandler(OnUIStructureChangedEvent));
                            //new StructureChangedEventHandler(handler));
                            //new StructureChangedEventHandler(((EventCmdletBase)cmdlet).StructureChangedEventHandler));
                            new StructureChangedEventHandler(cmdlet.StructureChangedEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaStructureChangedEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaStructureChangedEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaStructureChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "WindowPatternIdentifiers.WindowClosedProperty":
                        this.WriteVerbose(cmdlet, "subscribing to the WindowClosedEvent handler");
                        Automation.AddAutomationEventHandler(
                            WindowPattern.WindowClosedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.MenuClosedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the MenuClosedEvent handler");
                        Automation.AddAutomationEventHandler(
                            AutomationElement.MenuClosedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.MenuOpenedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the MenuOpenedEvent handler");
                        Automation.AddAutomationEventHandler(
                            AutomationElement.MenuOpenedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.ToolTipClosedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the ToolTipClosedEvent handler");
                        Automation.AddAutomationEventHandler(
                            AutomationElement.ToolTipClosedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.ToolTipOpenedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the ToolTipOpenedEvent handler");
                        Automation.AddAutomationEventHandler(
                            AutomationElement.ToolTipOpenedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.AutomationFocusChangedEvent":
                        WriteVerbose(cmdlet, "subscribing to the AutomationFocusChangedEvent handler");
                        Automation.AddAutomationFocusChangedEventHandler(
                            //AutomationElement.AutomationFocusChangedEvent,
                            //inputObject,
                            //System.Windows.Automation.AutomationElement.RootElement,
                            //TreeScope.Subtree,
                            uiaFocusChangedEventHandler = new AutomationFocusChangedEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaFocusChangedEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaFocusChangedEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaFocusChangedEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    default:
                        this.WriteVerbose(cmdlet,
                                     "the following event has not been subscribed to: " +
                                     eventType.ProgrammaticName);
                        break;
                }
                this.WriteVerbose(cmdlet, "on the object " + inputObject.Current.Name);
                cacheRequest.Pop();

            }
            catch (Exception e) {
            // try {
            // ErrorRecord err = new ErrorRecord(
            // e,
            // "RegisteringEvent",
            // ErrorCategory.OperationStopped,
            // inputObject);
            // err.ErrorDetails =
            // new ErrorDetails("Unable to register event handler " +
            //  // handler.ToString());
            // eventType.ProgrammaticName +
            // " for " +
            // inputObject.Current.Name);
            //  // this.OnSuccessAction.ToString());
            // WriteError(this, err, false);
            // }
            // catch {
            // ErrorRecord err = new ErrorRecord(
            // e,
            // "RegisteringEvent",
            // ErrorCategory.OperationStopped,
            // inputObject);
            // err.ErrorDetails =
            // new ErrorDetails("Unable to register event handler " +
            // eventType.ProgrammaticName);;
            // WriteError(this, err, false);
            // }

                WriteVerbose(cmdlet,
                              "Unable to register event handler " +
                              eventType.ProgrammaticName +
                              " for " +
                              inputObject.Current.Name);
                 WriteVerbose(cmdlet,
                              e.Message);
            }
        }
Пример #39
0
		public void RemoveStructureChangedEventHandler (IElement element,
		                                                StructureChangedEventHandler eventHandler)
		{
			List<StructureChangedEventHandlerData> handlersToDelete = new List<StructureChangedEventHandlerData> ();
			foreach (var handlerData in structureEventHandlers) {
				if (handlerData.Element == element && handlerData.EventHandler == eventHandler) {
					handlersToDelete.Add (handlerData);
				}
			}
			foreach (var h in handlersToDelete)
				structureEventHandlers.Remove (h);
		}
Пример #40
0
        public static void RemoveStructureChangedEventHandler(AutomationElement element, StructureChangedEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");

            try
            {
                StructureEventListener listener = (StructureEventListener)ClientEventList.Remove(AutomationElement.StructureChangedEvent, element, eventHandler);
                Factory.RemoveStructureChangedEventHandler(element.NativeElement, listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx))
                {
                    throw newEx;
                }
                else
                {
                    throw;
                }
            }
        }
Пример #41
0
        /// --------------------------------------------------------------------
        /// <summary>
        ///     Initialize both client and target applications.
        /// </summary>
        /// <param name="args">Startup arguments</param>
        /// --------------------------------------------------------------------
        protected override void OnStartup(StartupEventArgs args)
        {
            // Create our informational window
            CreateWindow();

            // Get the root element from our target application.
            // In general, you should try to obtain only direct children of 
            // the RootElement. A search for descendants may iterate through 
            // hundreds or even thousands of elements, possibly resulting in 
            // a stack overflow. If you are attempting to obtain a specific 
            // element at a lower level, you should start your search from the 
            // application window or from a container at a lower level.
            _targetApp =
                System.Windows.Forms.Application.StartupPath + "\\Target.exe";
            _rootElement = StartApp(_targetApp);
            if (_rootElement == null)
            {
                return;
            }

            // Add a structure change listener for the root element.
            var structureChange =
                new StructureChangedEventHandler(ChildElementsAdded);
            Automation.AddStructureChangedEventHandler(
                _rootElement, TreeScope.Descendants, structureChange);

            // Iterate through the controls in the target application.
            FindTreeViewsInTarget();
        }
Пример #42
0
		public void RemoveStructureChangedEventHandler (IElement element,
		                                                StructureChangedEventHandler eventHandler)
		{
			int handlerId = eventHandlerManager.GetStructureEventIdByHandler (eventHandler);
			if (handlerId == -1)
				return;

			if (element == null) {
				//the element is the RootElement
				RootElementEventsManager.RemoveStructureEventRequest (handlerId);
				foreach (var entry in GetUiaApplications ())
					entry.Value.RemoveRootElementStructureChangedEventHandler (handlerId);
			} else {
				UiaDbusElement uiaDbusElement = element as UiaDbusElement;
				if (uiaDbusElement == null) {
					Log.Error ("[RemoveStructureChangedEventHandler] " +
						"The element sent to UiaDbusSource is not UiaDbusElement");
					return;
				}
				string busName = uiaDbusElement.BusName;
				DCI.IApplication app = Bus.Session.GetObject<DCI.IApplication> (busName,
					new ObjectPath (DC.Constants.ApplicationPath));
				int [] runtimeId = uiaDbusElement.RuntimeId;
				app.RemoveStructureChangedEventHandler (runtimeId, handlerId);
			}
		}
Пример #43
0
		public void AddStructureChangedEventHandler (IElement element,
		                                             TreeScope scope,
		                                             StructureChangedEventHandler eventHandler)
		{
			StructureChangedEventHandlerData data = new StructureChangedEventHandlerData (
				element, scope, eventHandler);
			structureEventHandlers.Add (data);
		}
Пример #44
0
        public static void RemoveStructureChangedEventHandler(AutomationElement element, StructureChangedEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");

            try
            {
                StructureEventListener listener = (StructureEventListener)ClientEventList.Remove(AutomationElement.StructureChangedEvent, element, eventHandler);
                Factory.RemoveStructureChangedEventHandler(element.NativeElement, listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }
Пример #45
0
 public StructureEventListener(AutomationEvent eventKind, AutomationElement element, StructureChangedEventHandler handler) :
     base(AutomationElement.StructureChangedEvent.Id, element.GetRuntimeId(), handler)
 {
     Debug.Assert(handler != null);
     this._structureChangeHandler = handler;
 }
Пример #46
0
        /// <summary>
        /// Called by a client to remove a listener for structure change events.
        /// </summary>
        /// <param name="element">Element to remove listener for</param>
        /// <param name="eventHandler">The handler object that was passed to AddStructureChangedListener</param>
        /// 
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public static void RemoveStructureChangedEventHandler(AutomationElement element, StructureChangedEventHandler eventHandler)
        {
            Misc.ValidateArgumentNonNull(element, "element");
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler");
            //CASRemoval:AutomationPermission.Demand(AutomationPermissionFlag.Read);

            // Remove the client-side listener for for this event
            ClientEventManager.RemoveListener(AutomationElement.StructureChangedEvent, element, eventHandler);
        }
Пример #47
0
 public StructureEventListener(AutomationEvent eventKind, AutomationElement element, StructureChangedEventHandler handler) :
     base(AutomationElement.StructureChangedEvent.Id, element.GetRuntimeId(), handler)
 {
     Debug.Assert(handler != null);
     this._structureChangeHandler = handler;
 }
Пример #48
0
        /// <summary>
        /// Called by a client to remove a listener for structure change events.
        /// </summary>
        /// <param name="element">Element to remove listener for</param>
        /// <param name="eventHandler">The handler object that was passed to AddStructureChangedListener</param>
        ///
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        /// <exception cref="System.Security.Permissions.SecurityPermission"/>
        /// </outside_see>
        public static void RemoveStructureChangedEventHandler(AutomationElement element, StructureChangedEventHandler eventHandler)
        {
            Misc.ValidateArgumentNonNull(element, "element");
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler");

            // Remove the client-side listener for for this event
            ClientEventManager.RemoveListener(AutomationElement.StructureChangedEvent, element, eventHandler);
        }
Пример #49
0
 public override void Add(WrappedEventHandler handler, AutomationElementWrapper element)
 {
     _handler = (o, e) => handler(element, e);
     _element = element.Element;
     Automation.AddStructureChangedEventHandler(_element, _scope, _handler);
 }