示例#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);
            }
        }
示例#2
0
 public void RemoveAllEventHandlers()
 {
     lock (focusChangedHandlers)
         focusChangedHandlers.Clear();
     foreach (DCI.IApplication app in GetUiaApplications().Values)
     {
         app.RemoveAllEventHandlers(EventHandlerManager.ClientPrefix);
     }
     RootElementEventsManager.RemoveAll();
 }
示例#3
0
        public void AddAutomationPropertyChangedEventHandler(IElement element,
                                                             TreeScope scope,
                                                             AutomationPropertyChangedEventHandler eventHandler,
                                                             AutomationProperty [] properties)
        {
            int [] propertyIds = new int [properties.Length];
            for (int i = 0; i < properties.Length; i++)
            {
                propertyIds [i] = properties [i].Id;
            }
            if (element == null)
            {
                //the element is the RootElement
                // TODO clean up registered handlers when they're removed
                int handlerId = eventHandlerManager.RegisterPropertyEventHandler(eventHandler);
                RootElementEventsManager.AddPropertyEventRequest(scope, handlerId, propertyIds);
                foreach (var entry in GetUiaApplications())
                {
                    string busName = entry.Key;
                    var    app     = entry.Value;
                    EnsurePropertyEventsSetUp(app, busName);
                    app.AddRootElementAutomationPropertyChangedEventHandler(
                        scope, handlerId, propertyIds);
                }
            }
            else
            {
                UiaDbusElement uiaDbusElement = element as UiaDbusElement;
                if (uiaDbusElement == null)
                {
                    Log.Error("[AddAutomationPropertyChangedEventHandler] 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.RegisterPropertyEventHandler(eventHandler);

                EnsurePropertyEventsSetUp(app, busName);
                app.AddAutomationPropertyChangedEventHandler(runtimeId, scope, handlerId, propertyIds);
            }
        }
示例#4
0
        public void AddAutomationEventHandler(AutomationEvent eventId,
                                              IElement element,
                                              TreeScope scope,
                                              AutomationEventHandler eventHandler)
        {
            if (element == null)
            {
                //the element is the RootElement
                // TODO clean up registered handlers when they're removed
                int handlerId = eventHandlerManager.RegisterAutomationEventHandler(eventHandler);
                RootElementEventsManager.AddAutomationEventRequest(eventId.Id, scope, handlerId);
                foreach (var entry in GetUiaApplications())
                {
                    string busName = entry.Key;
                    var    app     = entry.Value;
                    EnsureAutomationEventsSetUp(app, busName);
                    app.AddRootElementAutomationEventHandler(eventId.Id, scope, handlerId);
                }
            }
            else
            {
                UiaDbusElement uiaDbusElement = element as UiaDbusElement;
                if (uiaDbusElement == null)
                {
                    Log.Error("[AddAutomationEventHandler] 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.RegisterAutomationEventHandler(eventHandler);

                EnsureAutomationEventsSetUp(app, busName);
                app.AddAutomationEventHandler(eventId.Id, runtimeId, scope, handlerId);
            }
        }