Ejemplo n.º 1
0
        /// <summary>
        /// Adds an automation event handler for the specified element in the
        /// specified window
        /// </summary>
        /// <param name="hWnd">window handle</param>
        /// <param name="autoEvent">the event to add</param>
        /// <param name="element">the automation element for the control</param>
        /// <param name="eventHandler">the event handler for the event</param>
        static public void AddAutomationEventHandler(IntPtr hWnd,
                                                     AutomationEvent autoEvent,
                                                     AutomationElement element,
                                                     AutomationEventHandler eventHandler)
        {
            Log.Debug();

            var windowElement = (WindowElement)WindowTable[hWnd];

            if (windowElement == null)
            {
                windowElement = new WindowElement(hWnd);
                WindowTable.Add(hWnd, windowElement);

                var control = Form.FromHandle(hWnd);
                if (control is Form)
                {
                    var form = control as Form;
                    form.VisibleChanged += form_VisibleChanged;
                    form.FormClosing    += form_FormClosing;
                }
                else
                {
                    windowElement.EvtOnWindowClosed += windowElement_EvtOnWindowClosed;
                }
            }
            else
            {
                Log.Debug("Found window element");
            }

            // create the item and add it
            var item = new AddEventHandlerItem
            {
                AutoEvent    = autoEvent,
                AutoElement  = element,
                EventHandler = eventHandler,
                WinElement   = windowElement
            };

            AddAutomationEvent(item);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Enqueues a request for the item for asynchronous handling
 /// </summary>
 /// <param name="item">item to add</param>
 private static void AddAutomationEvent(AddEventHandlerItem item)
 {
     _instance._queue.Enqueue(item);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Enqueues a request for the item for asynchronous handling
 /// </summary>
 /// <param name="item">item to add</param>
 private static void AddAutomationEvent(AddEventHandlerItem item)
 {
     _instance._queue.Enqueue(item);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds an automation event handler for the specified element in the
        /// specified window
        /// </summary>
        /// <param name="hWnd">window handle</param>
        /// <param name="autoEvent">the event to add</param>
        /// <param name="element">the automation element for the control</param>
        /// <param name="eventHandler">the event handler for the event</param>
        static public void AddAutomationEventHandler(IntPtr hWnd,
                                        AutomationEvent autoEvent,
                                        AutomationElement element,
                                        AutomationEventHandler eventHandler)
        {
            Log.Debug();

            var windowElement = (WindowElement)WindowTable[hWnd];
            if (windowElement == null)
            {
                windowElement = new WindowElement(hWnd);
                WindowTable.Add(hWnd, windowElement);

                var control = Form.FromHandle(hWnd);
                if (control is Form)
                {
                    var form = control as Form;
                    form.VisibleChanged += form_VisibleChanged;
                    form.FormClosing += form_FormClosing;
                }
                else
                {
                    windowElement.EvtOnWindowClosed += windowElement_EvtOnWindowClosed;
                }
            }
            else
            {
                Log.Debug("Found window element");
            }

            // create the item and add it
            var item = new AddEventHandlerItem
            {
                AutoEvent = autoEvent,
                AutoElement = element,
                EventHandler = eventHandler,
                WinElement = windowElement
            };

            AddAutomationEvent(item);
        }