public override IAutomationEventHandler RegisterEvent(EventId @event, TreeScope treeScope, Action <AutomationElement, EventId> action) { var eventHandler = new UIA3BasicEventHandler(Automation, action); Automation.NativeAutomation.AddAutomationEventHandler(@event.Id, NativeElement, (UIA.TreeScope)treeScope, null, eventHandler); return(eventHandler); }
public override IDisposable SubscribeToEvent(EventId @event, TreeScope treeScope, Action <AutomationElement, EventId> action) { var eventHandler = new UIA3BasicEventHandler(this.Automation, action); this.Automation.NativeAutomation.AddAutomationEventHandler(@event.Id, this.NativeElement, (Interop.UIAutomationClient.TreeScope)treeScope, null, eventHandler); return(Disposable.Create(() => this.Automation.NativeAutomation.RemoveAutomationEventHandler(@event.Id, this.NativeElement, eventHandler))); }