Inheritance: AutomationIdentifier
Ejemplo n.º 1
0
		static WindowPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "WindowPatternIdentifiers.Pattern");
			CanMaximizeProperty =
				new AutomationProperty (CanMaximizePropertyId,
				                        "WindowPatternIdentifiers.CanMaximizeProperty");
			CanMinimizeProperty =
				new AutomationProperty (CanMinimizePropertyId,
				                        "WindowPatternIdentifiers.CanMinimizeProperty");
			IsModalProperty =
				new AutomationProperty (IsModalPropertyId,
				                        "WindowPatternIdentifiers.IsModalProperty");
			IsTopmostProperty =
				new AutomationProperty (IsTopmostPropertyId,
				                        "WindowPatternIdentifiers.IsTopmostProperty");
			WindowInteractionStateProperty =
				new AutomationProperty (WindowInteractionStatePropertyId,
				                        "WindowPatternIdentifiers.WindowInteractionStateProperty");
			WindowVisualStateProperty =
				new AutomationProperty (WindowVisualStatePropertyId,
				                        "WindowPatternIdentifiers.WindowVisualStateProperty");
			WindowClosedEvent =
				new AutomationEvent (WindowClosedEventId,
				                     "WindowPatternIdentifiers.WindowClosedProperty");
			WindowOpenedEvent =
				new AutomationEvent (WindowOpenedEventId,
				                     "WindowPatternIdentifiers.WindowOpenedProperty");
		}
Ejemplo n.º 2
0
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxyHwnd Methods

        // ------------------------------------------------------
        //
        // Internal Methods
        //
        // ------------------------------------------------------

        // Advises proxy that an event has been added.
        // Maps the Automation Events into WinEvents and add those to the list of WinEvents notification hooks
        internal virtual void AdviseEventAdded (AutomationEvent eventId, AutomationProperty [] aidProps)
        {
            // No RawElementBase creation callback, exit from here
            if (_createOnEvent == null)
            {
                return;
            }

            int cEvents = 0;
            WinEventTracker.EvtIdProperty [] aEvents;

            // Gets an Array of WinEvents to trap on a per window handle basis
            if (eventId == AutomationElement.AutomationPropertyChangedEvent)
            {
                aEvents = PropertyToWinEvent (aidProps, out cEvents);
            }
            else
            {
                aEvents = EventToWinEvent (eventId, out cEvents);
            }

            // If we have WinEvents to trap, add those to the list of WinEvent
            // notification list
            if (cEvents > 0)
            {
                WinEventTracker.AddToNotificationList (_hwnd, _createOnEvent, aEvents, cEvents);
            }
        }
Ejemplo n.º 3
0
		public void RaiseAutomationEvent (AutomationEvent eventId, object provider, AutomationEventArgs e)
		{
			var providerSimple = provider as IRawElementProviderSimple;
			if (providerSimple == null)
				return;
			ClientEventManager.RaiseAutomationEvent (eventId, providerSimple, e);
		}
Ejemplo n.º 4
0
		public override void RaiseAutomationEvent (AutomationEvent eventId, AutomationEventArgs e)
		{
			if (eventId == GridPatternIdentifiers.ColumnReorderedEvent)
				EmitSignal ("column_reordered");
			else
				base.RaiseAutomationEvent (eventId, e);
			// TODO
		}
Ejemplo n.º 5
0
		public static void AddAutomationEventHandler (AutomationEvent eventId,
			IRawElementProviderSimple provider, TreeScope scope,
			AutomationEventHandler eventHandler)
		{
			var entry = new AutomationEventEntry (eventId, provider, scope, eventHandler);
			lock (automationEventEntries)
				automationEventEntries.Add (entry);
		}
Ejemplo n.º 6
0
		public static void RemoveAutomationEventHandler (AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventHandler eventHandler)
		{
			lock (automationEventEntries)
				automationEventEntries.RemoveAll (e =>
					e.EventId == eventId &&
					e.Provider == provider &&
					e.Handler == eventHandler);
		}
Ejemplo n.º 7
0
		public override void RaiseAutomationEvent (AutomationEvent eventId, AutomationEventArgs e)
		{
			if (eventId != AutomationElementIdentifiers.MenuClosedEvent)
				base.RaiseAutomationEvent (eventId, e);

			TopLevelRootItem.Instance.RemoveChild (Parent);
			((ParentAdapter)Parent).RemoveChild (this);
			AutomationBridge.HandleTotalElementRemoval (this.Provider);
		}
Ejemplo n.º 8
0
		static InvokePatternIdentifiers ()
		{
			InvokedEvent =
				new AutomationEvent (InvokedEventId, 
				                     "InvokePatternIdentifiers.InvokedEvent");
			Pattern =
				new AutomationPattern (PatternId,
				                       "InvokePatternIdentifiers.Pattern");
		}
Ejemplo n.º 9
0
		public override void RaiseAutomationEvent (AutomationEvent eventId, AutomationEventArgs e)
		{
			if (eventId == AutomationElementIdentifiers.AsyncContentLoadedEvent) {
				// TODO: Handle AsyncContentLoadedEvent
			} else if (eventId == AutomationElementIdentifiers.StructureChangedEvent) {
				// TODO: Handle StructureChangedEvent
			}
			else
				base.RaiseAutomationEvent (eventId, e);
		}
Ejemplo n.º 10
0
	internal static async Task<AutomationEventArgs> Event(
		AutomationEvent eventId, 
		AutomationElement element = null, 
		TreeScope scope = TreeScope.Descendants)
	{
		using (var waitr = new Waiter(eventId, element, scope))
		{
			await waitr.Completion.Task;
			return waitr.EvtArgs;
		}
	}
Ejemplo n.º 11
0
		public void AddAutomationEventHandler (AutomationEvent eventId, IElement element, TreeScope scope, AutomationEventHandler eventHandler)
		{
			if (element == null)
				// elements from local providers are not descendants of the RootElement.
				return;
			ClientElement clientElement = element as ClientElement;
			if (clientElement == null) {
				Log.Error ("[ClientAutomationSource.AddAutomationEventHandler] Not ClientElement");
				return;
			}
			ClientEventManager.AddAutomationEventHandler (eventId,
				clientElement.Provider, scope, eventHandler);
		}
Ejemplo n.º 12
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        // full ctor
        internal EventListener(
            AutomationEvent eventId, 
            TreeScope scope, 
            AutomationProperty [] properties,
            UiaCoreApi.UiaCacheRequest cacheRequest
            )
        {
            _eventId = eventId;
            _scope = scope;
            if (properties != null)
                _properties = (AutomationProperty[])properties.Clone();
            else
                _properties = null;
            _cacheRequest = cacheRequest;
        }
Ejemplo n.º 13
0
        private void AddEventHandler(
			AutomationEvent automationEvent,
			AutomationEventHandler eventHandler)
        {
            _currentElement = AutomationElement.FocusedElement;
            if (_currentElement != null)
            {
                Automation.AddAutomationEventHandler(
                    automationEvent,
                    _currentElement,
                    TreeScope.Element,
                    eventHandler);
            }
            else
                this.UiFeedback("(no element)");
        }
Ejemplo n.º 14
0
		internal Waiter(AutomationEvent eventId, 
						AutomationElement element = null, 
						TreeScope scope = TreeScope.Descendants)
		{
			this._eventId = eventId;
			this._element = element ?? AutomationElement.RootElement;
			this._scope   = scope;
			this._handler = new AutomationEventHandler((src, e) => 
			{
				this.EvtArgs = e;
				this.Completion.SetResult(true);
			});

			Automation.AddAutomationEventHandler(
				this._eventId, this._element,
				this._scope,   this._handler);
		}
Ejemplo n.º 15
0
 public static EventListener Remove(AutomationEvent eventId, AutomationElement element, Delegate handler)
 {
     // Create a prototype to seek
     int[] runtimeId = (element == null) ? null : element.GetRuntimeId();
     EventListener prototype = new EventListener(eventId.Id, runtimeId, handler);
     lock (_events)
     {
         LinkedListNode<EventListener> node = _events.Find(prototype);
         if (node == null)
         {
             throw new ArgumentException("event handler not found");
         }
         EventListener result = node.Value;
         _events.Remove(node);
         return result;
     }
 }
Ejemplo n.º 16
0
		static GridPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
						"GridPatternIdentifiers.Pattern");

			RowCountProperty =
				new AutomationProperty (RowCountPropertyId,
						"GridPatternIdentifiers.RowCountProperty");

			ColumnCountProperty =
				new AutomationProperty (ColumnCountPropertyId,
						"GridPatternIdentifiers.ColumnCountProperty");
			ColumnReorderedEvent =
				new AutomationEvent (ColumnReorderedEventId,
				                     "GridPatternIdentifiers.ColumnReorderedEvent");
		}
Ejemplo n.º 17
0
        // a client is listening for an event on object(s) in the specified window.
        internal void AdviseEventAdded(IntPtr hwnd, AutomationEvent eventId, AutomationProperty[] properties)
        {
            // 





            // we have a two-level table structure. the top-level table maps an hwnd to another table.
            // the second-level table maps an event (or a property in the case of property-changed-event)
            // in that hwnd to a reference count of the number of clients listening for that event.

            // use a lock to update our tables in one atomic operation.
            lock (this)
            {
                // if we aren't listening for WinEvents then start listening.
                if (_hwndTable.Count == 0)
                {
                    //Debug.WriteLine("Starting listening for WinEvents.", "NativeMsaaProxy");
                    // Posting an item to the queue to start listening for WinEvents. This makes sure it is done on the proper thread
                    // Notably the same thread WinEventTracker uses, which guarantees the thread that SetWinEventHook is called on is
                    // actively pumping messages, which is required for SetWinEventHook to function properly.
                    WinEventTracker.GetCallbackQueue().PostSyncWorkItem(new QueueItem.MSAAWinEventItem(StartListening));
                }

                // if we already have a 2-nd level table for this hwnd then simply update the 2nd-level table.
                // otherwise we need to create a 2-nd level table.
                Hashtable eventTable;
                if (_hwndTable.ContainsKey(hwnd))
                {
                    eventTable = (Hashtable)(_hwndTable[hwnd]);
                }
                else
                {
                    eventTable = new Hashtable();
                    _hwndTable[hwnd] = eventTable;
                }

                // for the single event or each of possibly multiple properties increment the reference counter.
                foreach (AutomationIdentifier key in EventKeys(eventId, properties))
                {
                    eventTable[key] = eventTable.ContainsKey(key) ? (int)eventTable[key] + 1 : 1;
                }
            }
        }
Ejemplo n.º 18
0
		static SelectionPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "SelectionPatternIdentifiers.Pattern");
			CanSelectMultipleProperty =
				new AutomationProperty (CanSelectMultiplePropertyId,
				                        "SelectionPatternIdentifiers.CanSelectMultipleProperty");
			IsSelectionRequiredProperty =
				new AutomationProperty (IsSelectionRequiredPropertyId,
				                        "SelectionPatternIdentifiers.IsSelectionRequiredProperty");
			SelectionProperty =
				new AutomationProperty (SelectionPropertyId,
				                        "SelectionPatternIdentifiers.SelectionProperty");
			InvalidatedEvent =
				new AutomationEvent (InvalidatedEventId,
				                     "SelectionPatternIdentifiers.InvalidatedEvent");
		}
Ejemplo n.º 19
0
		static SelectionItemPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "SelectionItemPatternIdentifiers.Pattern");
			ElementAddedToSelectionEvent =
				new AutomationEvent (ElementAddedToSelectionEventId,
				                     "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");
			ElementRemovedFromSelectionEvent =
				new AutomationEvent (ElementRemovedFromSelectionEventId,
				                     "SelectionItemPatternIdentifiers.ElementRemovedFromSelectionEvent");
			ElementSelectedEvent =
				new AutomationEvent (ElementSelectedEventId,
				                     "SelectionItemPatternIdentifiers.ElementSelectedEvent");
			IsSelectedProperty =
				new AutomationProperty (IsSelectedPropertyId,
				                     "SelectionItemPatternIdentifiers.IsSelectedProperty");
			SelectionContainerProperty =
				new AutomationProperty (SelectionContainerPropertyId,
				                     "SelectionItemPatternIdentifiers.SelectionContainerProperty");
		}
Ejemplo n.º 20
0
        internal override void AdviseEventRemoved (AutomationEvent eventId, AutomationProperty [] aidProps)
        {
            // we need to create the menu proxy so that the global event for menu will be listened for.
            // This proxy will get advise of events needed for menus
            ProxyHwnd menuProxy = CreateNonClientMenu();
            if (menuProxy == null)
            {
                // If the window does not have a menu, it at least has a system menu.
                WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                if (titleBar != null)
                {
                    menuProxy = (ProxyHwnd)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);
                }
            }

            if (menuProxy != null)
            {
                menuProxy.AdviseEventRemoved(eventId, aidProps);
            }

            base.AdviseEventRemoved(eventId, aidProps);
        }
Ejemplo n.º 21
0
        public static void AddAutomationEventHandler(AutomationEvent eventId, AutomationElement element, TreeScope scope, AutomationEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationFocusChangedEvent, "Use FocusChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.StructureChangedEvent, "Use StructureChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationPropertyChangedEvent, "Use PropertyChange notification instead");

            try
            {
                BasicEventListener listener = new BasicEventListener(eventId, element, eventHandler);
                Factory.AddAutomationEventHandler(
                    eventId.Id,
                    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; }
            }
        }
Ejemplo n.º 22
0
        // IsListeningFor - called by UIAccess client during removal of listeners. Returns
        // true if rid, eventId and clientCallback represent this listener instance.
        internal bool IsListeningFor(AutomationEvent eventId, AutomationElement el, Delegate clientCallback)
        {
            // Removing the event handler using the element RuntimeId prevents problems with dead elements
            int[] rid = null;
            try
            {
                rid = el.GetRuntimeId();
            }
            catch( ElementNotAvailableException )
            {
                // This can't be the element this instance is holding because when
                // creating this instance we caused the RuntimeId to be cached.
                return false;
            }

            if( !Misc.Compare( _refRid, rid ) )
                return false;

            if( _eventListener.EventId != eventId )
                return false;

            if (_clientCallback != clientCallback)
                return false;

            return true;
        }
Ejemplo n.º 23
0
        // Builds a list of Win32 WinEvents to process a UIAutomation Event.
        // Returns an array of Events to Set. The number of valid entries in this array pass back in cEvent.
        protected override WinEventTracker.EvtIdProperty [] EventToWinEvent (AutomationEvent idEvent, out int cEvent)
        {
            if (idEvent == AutomationElement.StructureChangedEvent)
            {
                cEvent = 3;
                return new WinEventTracker.EvtIdProperty [3] {
                    new WinEventTracker.EvtIdProperty (NativeMethods.EventObjectStateChange, idEvent),
                    new WinEventTracker.EvtIdProperty (NativeMethods.EventObjectCreate, idEvent),
                    new WinEventTracker.EvtIdProperty (NativeMethods.EventObjectDestroy, idEvent)
                };
            }

            return base.EventToWinEvent (idEvent, out cEvent);
        }
Ejemplo n.º 24
0
		public override void RaiseAutomationEvent (AutomationEvent eventId, AutomationEventArgs args)
		{
			base.RaiseAutomationEvent (eventId, args);
		}
Ejemplo n.º 25
0
        public static void RemoveAutomationEventHandler(AutomationEvent eventId, AutomationElement element, AutomationEventHandler eventHandler)
        {
            Utility.ValidateArgumentNonNull(element, "element");
            Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationFocusChangedEvent, "Use FocusChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.StructureChangedEvent, "Use StructureChange notification instead");
            Utility.ValidateArgument(eventId != AutomationElement.AutomationPropertyChangedEvent, "Use PropertyChange notification instead");

            try
            {
                BasicEventListener listener = (BasicEventListener)ClientEventList.Remove(eventId, element, eventHandler);
                Factory.RemoveAutomationEventHandler(eventId.Id, element.NativeElement, listener);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Called by a client to add a listener for pattern or custom events.
        /// </summary>
        /// <param name="eventId">A control pattern or custom event identifier.</param>
        /// <param name="element">Element on which to listen for control pattern or custom 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 the specified 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 AddAutomationEventHandler(
            AutomationEvent eventId,
            AutomationElement element,
            TreeScope scope,
            AutomationEventHandler eventHandler
            )
        {
            Misc.ValidateArgumentNonNull(element, "element");
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler");
            Misc.ValidateArgument(eventId != AutomationElement.AutomationFocusChangedEvent, SRID.EventIdMustNotBeAutomationFocusChanged);
            Misc.ValidateArgument(eventId != AutomationElement.StructureChangedEvent, SRID.EventIdMustNotBeStructureChanged);
            Misc.ValidateArgument(eventId != AutomationElement.AutomationPropertyChangedEvent, SRID.EventIdMustNotBeAutomationPropertyChanged);

            if (eventId == WindowPattern.WindowClosedEvent)
            {
                // Once a window closes and the hwnd is destroyed we won't be able to determine where it was in the
                // Automation tree; therefore only support WindowClosed events for all windows (eg. src==root and scope
                // is descendants) or a specific WindowPattern element (src==root of a Window and scope is the element).
                // Also handle odd combinations (eg. src==specific element and scope is subtree|ancestors).

                bool paramsValidated = false;

                if (Misc.Compare(element, AutomationElement.RootElement))
                {
                    // For root element need to have Descendants scope set (Note: Subtree includes Descendants)
                    if ((scope & TreeScope.Descendants) == TreeScope.Descendants)
                    {
                        paramsValidated = true;
                    }
                }
                else
                {
                    // otherwise non-root elements must have the entire tree (Anscestors, Element and Descendants)...
                    if ((scope & (TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants)) == (TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants))
                    {
                        paramsValidated = true;
                    }
                    else if ((scope & TreeScope.Element) == TreeScope.Element)
                    {
                        // ...OR Element where the element implements WindowPattern
                        // PRESHARP will flag this as warning 56506/6506:Parameter 'element' to this public method must be validated: A null-dereference can occur here.
                        // False positive, element is checked, see above
#pragma warning suppress 6506
                        object val = element.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty);
                        if (val != null && val is int && (int)val != 0)
                        {
                            if (HwndProxyElementProvider.IsWindowPatternWindow(NativeMethods.HWND.Cast(new IntPtr((int)val))))
                            {
                                paramsValidated = true;
                            }
                        }
                    }
                }

                if (!paramsValidated)
                {
                    throw new ArgumentException(SR.Get(SRID.ParamsNotApplicableToWindowClosedEvent));
                }
            }

            // Add a client-side Handler for for this event request
            EventListener l = new EventListener(eventId, scope, null, CacheRequest.CurrentUiaCacheRequest);
            ClientEventManager.AddListener(element, eventHandler, l);
        }
Ejemplo n.º 27
0
        internal static AutomationIdentifier Register(UiaCoreIds.AutomationIdType type, Guid guid, string programmaticName)
        {
            int id = UiaCoreIds.UiaLookupId(type, ref guid);
            if (id == 0)
            {
                return null;
            }
            lock (_identifierDirectory)
            {
                AutomationIdentifier identifier = (AutomationIdentifier)_identifierDirectory[guid];
                if (identifier == null)
                {
                    switch (type)
                    {
                        case UiaCoreIds.AutomationIdType.Property:
                            identifier = new AutomationProperty(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.Pattern:
                            identifier = new AutomationPattern(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.Event:
                            identifier = new AutomationEvent(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.ControlType:
                            identifier = new ControlType(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.TextAttribute:
                            identifier = new AutomationTextAttribute(id, guid, programmaticName);
                            break;

                        default:
                            throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                    }
                    _identifierDirectory[id] = identifier;
                }
                return identifier;
            }
        }
Ejemplo n.º 28
0
 internal override void AdviseEventRemoved(
     AutomationEvent eventId, AutomationProperty[] aidProps)
 {
     if (eventId == AutomationElementIdentifiers.AutomationPropertyChangedEvent
         && aidProps.Length > 0
         && aidProps[0] == ScrollPatternIdentifiers.HorizontalScrollPercentProperty)
     {
         IntPtr upDownHwnd = GetUpDownHwnd();
         if (upDownHwnd != IntPtr.Zero)
         {
             WinEventTracker.RemoveToNotificationList(
                 upDownHwnd, _upDownEvents, null, 1);
         }
     }
     base.AdviseEventRemoved(eventId, aidProps);
 }
Ejemplo n.º 29
0
		static TextPatternIdentifiers ()
		{
			MixedAttributeValue = new object ();

			Pattern =
				new AutomationPattern (PatternId,
				                       "TextPatternIdentifiers.Pattern");
			CaretMovedEvent = 
				new AutomationEvent (CaretMovedEventId,
				                     "TextPatternIdentifiers.CaretMovedEvent");
			TextChangedEvent = 
				new AutomationEvent (TextChangedEventId,
				                     "TextPatternIdentifiers.TextChangedEvent");
			TextSelectionChangedEvent = 
				new AutomationEvent (TextSelectionChangedEventId,
				                     "TextPatternIdentifiers.TextSelectionChangedEvent");

			AnimationStyleAttribute =
				new AutomationTextAttribute (AnimationStyleAttributeId,
			                                     "TextPatternIdentifiers.AnimationStyleAttribute");
			BackgroundColorAttribute =
				new AutomationTextAttribute (BackgroundColorAttributeId,
			                                     "TextPatternIdentifiers.BackgroundColorAttribute");
			BulletStyleAttribute =
				new AutomationTextAttribute (BulletStyleAttributeId,
			                                     "TextPatternIdentifiers.BulletStyleAttribute");
			CapStyleAttribute =
				new AutomationTextAttribute (CapStyleAttributeId,
			                                     "TextPatternIdentifiers.CapStyleAttribute");
			CultureAttribute =
				new AutomationTextAttribute (CultureAttributeId,
			                                     "TextPatternIdentifiers.CultureAttribute");
			FontNameAttribute =
				new AutomationTextAttribute (FontNameAttributeId,
			                                     "TextPatternIdentifiers.FontNameAttribute");
			FontSizeAttribute =
				new AutomationTextAttribute (FontSizeAttributeId,
			                                     "TextPatternIdentifiers.FontSizeAttribute");
			FontWeightAttribute =
				new AutomationTextAttribute (FontWeightAttributeId,
			                                     "TextPatternIdentifiers.FontWeightAttribute");
			ForegroundColorAttribute =
				new AutomationTextAttribute (ForegroundColorAttributeId,
			                                     "TextPatternIdentifiers.ForegroundColorAttribute");
			HorizontalTextAlignmentAttribute =
				new AutomationTextAttribute (HorizontalTextAlignmentAttributeId,
			                                     "TextPatternIdentifiers.HorizontalTextAlignmentAttribute");
			IndentationFirstLineAttribute =
				new AutomationTextAttribute (IndentationFirstLineAttributeId,
			                                     "TextPatternIdentifiers.IndentationFirstLineAttribute");
			IndentationLeadingAttribute =
				new AutomationTextAttribute (IndentationLeadingAttributeId,
			                                     "TextPatternIdentifiers.IndentationLeadingAttribute");
			IndentationTrailingAttribute =
				new AutomationTextAttribute (IndentationTrailingAttributeId,
			                                     "TextPatternIdentifiers.IndentationTrailingAttribute");
			IsHiddenAttribute =
				new AutomationTextAttribute (IsHiddenAttributeId,
			                                     "TextPatternIdentifiers.IsHiddenAttribute");
			IsItalicAttribute =
				new AutomationTextAttribute (IsItalicAttributeId,
			                                     "TextPatternIdentifiers.IsItalicAttribute");
			IsReadOnlyAttribute =
				new AutomationTextAttribute (IsReadOnlyAttributeId,
			                                     "TextPatternIdentifiers.IsReadOnlyAttribute");
			IsSubscriptAttribute =
				new AutomationTextAttribute (IsSubscriptAttributeId,
			                                     "TextPatternIdentifiers.IsSubscriptAttribute");
			IsSuperscriptAttribute =
				new AutomationTextAttribute (IsSuperscriptAttributeId,
			                                     "TextPatternIdentifiers.IsSuperscriptAttribute");
			MarginBottomAttribute =
				new AutomationTextAttribute (MarginBottomAttributeId,
			                                     "TextPatternIdentifiers.MarginBottomAttribute");
			MarginLeadingAttribute =
				new AutomationTextAttribute (MarginLeadingAttributeId,
			                                     "TextPatternIdentifiers.MarginLeadingAttribute");
			MarginTopAttribute =
				new AutomationTextAttribute (MarginTopAttributeId,
			                                     "TextPatternIdentifiers.MarginTopAttribute");
			MarginTrailingAttribute =
				new AutomationTextAttribute (MarginTrailingAttributeId,
			                                     "TextPatternIdentifiers.MarginTrailingAttribute");
			OutlineStylesAttribute =
				new AutomationTextAttribute (OutlineStylesAttributeId,
			                                     "TextPatternIdentifiers.OutlineStylesAttribute");
			OverlineColorAttribute =
				new AutomationTextAttribute (OverlineColorAttributeId,
			                                     "TextPatternIdentifiers.OverlineColorAttribute");
			OverlineStyleAttribute =
				new AutomationTextAttribute (OverlineStyleAttributeId,
			                                     "TextPatternIdentifiers.OverlineStyleAttribute");
			StrikethroughColorAttribute =
				new AutomationTextAttribute (StrikethroughColorAttributeId,
			                                     "TextPatternIdentifiers.StrikethroughColorAttribute");
			StrikethroughStyleAttribute =
				new AutomationTextAttribute (StrikethroughStyleAttributeId,
			                                     "TextPatternIdentifiers.StrikethroughStyleAttribute");
			TabsAttribute =
				new AutomationTextAttribute (TabsAttributeId,
			                                     "TextPatternIdentifiers.TabsAttribute");
			TextFlowDirectionsAttribute =
				new AutomationTextAttribute (TextFlowDirectionsAttributeId,
			                                     "TextPatternIdentifiers.TextFlowDirectionsAttribute");
			UnderlineColorAttribute =
				new AutomationTextAttribute (UnderlineColorAttributeId,
			                                     "TextPatternIdentifiers.UnderlineColorAttribute");
			UnderlineStyleAttribute =
				new AutomationTextAttribute (UnderlineStyleAttributeId,
			                                     "TextPatternIdentifiers.UnderlineStyleAttribute");
		}
Ejemplo n.º 30
0
        static AutomationElementIdentifiers()
        {
            NotSupported = new object();

            // Automation Properties
            HasNativeAccessibilityObjectProperty =
                new AutomationProperty(HasNativeAccessibilityObjectPropertyId,
                                       "AutomationElementIdentifiers.HasNativeAccessibilityObjectProperty");
            NativeAccessibilityObjectProperty =
                new AutomationProperty(NativeAccessibilityObjectPropertyId,
                                       "AutomationElementIdentifiers.NativeAccessibilityObjectProperty");
            IsNotifyIconProperty =
                new AutomationProperty(IsNotifyIconPropertyId,
                                       "AutomationElementIdentifiers.IsNotifyIconProperty");
            AcceleratorKeyProperty =
                new AutomationProperty(AcceleratorKeyPropertyId,
                                       "AutomationElementIdentifiers.AcceleratorKeyProperty");
            AccessKeyProperty =
                new AutomationProperty(AccessKeyPropertyId,
                                       "AutomationElementIdentifiers.AccessKeyProperty");
            AutomationIdProperty =
                new AutomationProperty(AutomationIdPropertyId,
                                       "AutomationElementIdentifiers.AutomationIdProperty");
            BoundingRectangleProperty =
                new AutomationProperty(BoundingRectanglePropertyId,
                                       "AutomationElementIdentifiers.BoundingRectangleProperty");
            ClassNameProperty =
                new AutomationProperty(ClassNamePropertyId,
                                       "AutomationElementIdentifiers.ClassNameProperty");
            ClickablePointProperty =
                new AutomationProperty(ClickablePointPropertyId,
                                       "AutomationElementIdentifiers.ClickablePointProperty");
            ControlTypeProperty =
                new AutomationProperty(ControlTypePropertyId,
                                       "AutomationElementIdentifiers.ControlTypeProperty");
            CultureProperty =
                new AutomationProperty(CulturePropertyId,
                                       "AutomationElementIdentifiers.CultureProperty");
            FrameworkIdProperty =
                new AutomationProperty(FrameworkIdPropertyId,
                                       "AutomationElementIdentifiers.FrameworkIdProperty");
            HasKeyboardFocusProperty =
                new AutomationProperty(HasKeyboardFocusPropertyId,
                                       "AutomationElementIdentifiers.HasKeyboardFocusProperty");
            HelpTextProperty =
                new AutomationProperty(HelpTextPropertyId,
                                       "AutomationElementIdentifiers.HelpTextProperty");
            IsContentElementProperty =
                new AutomationProperty(IsContentElementPropertyId,
                                       "AutomationElementIdentifiers.IsContentElementProperty");
            IsControlElementProperty =
                new AutomationProperty(IsControlElementPropertyId,
                                       "AutomationElementIdentifiers.IsControlElementProperty");
            IsDockPatternAvailableProperty =
                new AutomationProperty(IsDockPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsDockPatternAvailableProperty");
            IsEnabledProperty =
                new AutomationProperty(IsEnabledPropertyId,
                                       "AutomationElementIdentifiers.IsEnabledProperty");
            IsExpandCollapsePatternAvailableProperty =
                new AutomationProperty(IsExpandCollapsePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsExpandCollapsePatternAvailableProperty");
            IsGridItemPatternAvailableProperty =
                new AutomationProperty(IsGridItemPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsGridItemPatternAvailableProperty");
            IsGridPatternAvailableProperty =
                new AutomationProperty(IsGridPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsGridPatternAvailableProperty");
            IsInvokePatternAvailableProperty =
                new AutomationProperty(IsInvokePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsInvokePatternAvailableProperty");
            IsKeyboardFocusableProperty =
                new AutomationProperty(IsKeyboardFocusablePropertyId,
                                       "AutomationElementIdentifiers.IsKeyboardFocusableProperty");
            IsLegacyIAccessiblePatternAvailableProperty =
                new AutomationProperty(IsLegacyIAccessiblePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsLegacyIAccessiblePatternAvailableProperty");
            IsMultipleViewPatternAvailableProperty =
                new AutomationProperty(IsMultipleViewPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsMultipleViewPatternAvailableProperty");
            IsOffscreenProperty =
                new AutomationProperty(IsOffscreenPropertyId,
                                       "AutomationElementIdentifiers.IsOffscreenProperty");
            IsPasswordProperty =
                new AutomationProperty(IsPasswordPropertyId,
                                       "AutomationElementIdentifiers.IsPasswordProperty");
            IsRangeValuePatternAvailableProperty =
                new AutomationProperty(IsRangeValuePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsRangeValuePatternAvailableProperty");
            IsRequiredForFormProperty =
                new AutomationProperty(IsRequiredForFormPropertyId,
                                       "AutomationElementIdentifiers.IsRequiredForFormProperty");
            IsScrollItemPatternAvailableProperty =
                new AutomationProperty(IsScrollItemPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsScrollItemPatternAvailableProperty");
            IsScrollPatternAvailableProperty =
                new AutomationProperty(IsScrollPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsScrollPatternAvailableProperty");
            IsSelectionItemPatternAvailableProperty =
                new AutomationProperty(IsSelectionItemPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsSelectionItemPatternAvailableProperty");
            IsSelectionPatternAvailableProperty =
                new AutomationProperty(IsSelectionPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsSelectionPatternAvailableProperty");
            IsTableItemPatternAvailableProperty =
                new AutomationProperty(IsTableItemPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsTableItemPatternAvailableProperty");
            IsTablePatternAvailableProperty =
                new AutomationProperty(IsTablePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsTablePatternAvailableProperty");
            IsTextPatternAvailableProperty =
                new AutomationProperty(IsTextPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsTextPatternAvailableProperty");
            IsTogglePatternAvailableProperty =
                new AutomationProperty(IsTogglePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsTogglePatternAvailableProperty");
            IsTransformPatternAvailableProperty =
                new AutomationProperty(IsTransformPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsTransformPatternAvailableProperty");
            IsValuePatternAvailableProperty =
                new AutomationProperty(IsValuePatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsValuePatternAvailableProperty");
            IsWindowPatternAvailableProperty =
                new AutomationProperty(IsWindowPatternAvailablePropertyId,
                                       "AutomationElementIdentifiers.IsWindowPatternAvailableProperty");
            ItemStatusProperty =
                new AutomationProperty(ItemStatusPropertyId,
                                       "AutomationElementIdentifiers.ItemStatusProperty");
            ItemTypeProperty =
                new AutomationProperty(ItemTypePropertyId,
                                       "AutomationElementIdentifiers.ItemTypeProperty");
            LabeledByProperty =
                new AutomationProperty(LabeledByPropertyId,
                                       "AutomationElementIdentifiers.LabeledByProperty");
            LocalizedControlTypeProperty =
                new AutomationProperty(LocalizedControlTypePropertyId,
                                       "AutomationElementIdentifiers.LocalizedControlTypeProperty");
            NameProperty =
                new AutomationProperty(NamePropertyId,
                                       "AutomationElementIdentifiers.NameProperty");
            NativeWindowHandleProperty =
                new AutomationProperty(NativeWindowHandlePropertyId,
                                       "AutomationElementIdentifiers.NativeWindowHandleProperty");
            OrientationProperty =
                new AutomationProperty(OrientationPropertyId,
                                       "AutomationElementIdentifiers.OrientationProperty");
            ProcessIdProperty =
                new AutomationProperty(ProcessIdPropertyId,
                                       "AutomationElementIdentifiers.ProcessIdProperty");
            RuntimeIdProperty =
                new AutomationProperty(RuntimeIdPropertyId,
                                       "AutomationElementIdentifiers.RuntimeIdProperty");

            // Automation Events
            WindowDeactivatedEvent =
                new AutomationEvent(WindowDeactivatedEventId,
                                    "AutomationElementIdentifiers.WindowDeactivatedEvent");
            KeyEvent =
                new AutomationEvent(KeyEventId,
                                    "AutomationElementIdentifiers.KeyEvent");
            AsyncContentLoadedEvent =
                new AutomationEvent(AsyncContentLoadedEventId,
                                    "AutomationElementIdentifiers.AsyncContentLoadedEvent");
            AutomationFocusChangedEvent =
                new AutomationEvent(AutomationFocusChangedEventId,
                                    "AutomationElementIdentifiers.AutomationFocusChangedEvent");
            AutomationPropertyChangedEvent =
                new AutomationEvent(AutomationPropertyChangedEventId,
                                    "AutomationElementIdentifiers.AutomationPropertyChangedEvent");
            LayoutInvalidatedEvent =
                new AutomationEvent(LayoutInvalidatedEventId,
                                    "AutomationElementIdentifiers.LayoutInvalidatedEvent");
            MenuClosedEvent =
                new AutomationEvent(MenuClosedEventId,
                                    "AutomationElementIdentifiers.MenuClosedEvent");
            MenuOpenedEvent =
                new AutomationEvent(MenuOpenedEventId,
                                    "AutomationElementIdentifiers.MenuOpenedEvent");
            StructureChangedEvent =
                new AutomationEvent(StructureChangedEventId,
                                    "AutomationElementIdentifiers.StructureChangedEvent");
            ToolTipClosedEvent =
                new AutomationEvent(ToolTipClosedEventId,
                                    "AutomationElementIdentifiers.ToolTipClosedEvent");
            ToolTipOpenedEvent =
                new AutomationEvent(ToolTipOpenedEventId,
                                    "AutomationElementIdentifiers.ToolTipOpenedEvent");
        }
Ejemplo n.º 31
0
 public AutomationEventArgs(AutomationEvent eventId)
 {
     this._eventId = eventId;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Called by a client to add a listener for pattern or custom events.
        /// </summary>
        /// <param name="eventId">A control pattern or custom event identifier.</param>
        /// <param name="element">Element on which to listen for control pattern or custom 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 the specified 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 AddAutomationEventHandler(
            AutomationEvent eventId,
            AutomationElement element,
            TreeScope scope,
            AutomationEventHandler eventHandler
            )
        {
            Misc.ValidateArgumentNonNull(element, "element" );
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler" );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationFocusChangedEvent, SRID.EventIdMustNotBeAutomationFocusChanged );
            Misc.ValidateArgument( eventId != AutomationElement.StructureChangedEvent,SRID.EventIdMustNotBeStructureChanged );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationPropertyChangedEvent, SRID.EventIdMustNotBeAutomationPropertyChanged );

            if (eventId == WindowPattern.WindowClosedEvent)
            {
                // Once a window closes and the hwnd is destroyed we won't be able to determine where it was in the 
                // Automation tree; therefore only support WindowClosed events for all windows (eg. src==root and scope 
                // is descendants) or a specific WindowPattern element (src==root of a Window and scope is the element).
                // Also handle odd combinations (eg. src==specific element and scope is subtree|ancestors).

                bool paramsValidated = false;

                if ( Misc.Compare( element, AutomationElement.RootElement ) )
                {
                    // For root element need to have Descendants scope set (Note: Subtree includes Descendants)
                    if ( ( scope & TreeScope.Descendants ) == TreeScope.Descendants )
                    {
                        paramsValidated = true;
                    }
                }
                else
                {
                    // otherwise non-root elements must have the entire tree (Anscestors, Element and Descendants)...
                    if ( ( scope & ( TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants ) ) == ( TreeScope.Ancestors | TreeScope.Element | TreeScope.Descendants ) )
                    {
                        paramsValidated = true;
                    }
                    else if ( ( scope & TreeScope.Element ) == TreeScope.Element )
                    {
                        // ...OR Element where the element implements WindowPattern
                        // PRESHARP will flag this as warning 56506/6506:Parameter 'element' to this public method must be validated: A null-dereference can occur here.
                        // False positive, element is checked, see above
#pragma warning suppress 6506
                        object val = element.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty);
                        if ( val != null && val is int && (int)val != 0 )
                        {
                            if ( HwndProxyElementProvider.IsWindowPatternWindow( NativeMethods.HWND.Cast( new IntPtr( (int)val ) ) ) )
                            {
                                paramsValidated = true;
                            }
                        }
                    }
                }

                if ( !paramsValidated )
                {
                    throw new ArgumentException( SR.Get( SRID.ParamsNotApplicableToWindowClosedEvent ) );
                }
            }

            // Add a client-side Handler for for this event request
            EventListener l = new EventListener(eventId, scope, null, CacheRequest.CurrentUiaCacheRequest);
            ClientEventManager.AddListener(element, eventHandler, l);
        }
Ejemplo n.º 33
0
        internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, Guid guid, string programmaticName)
        {
            int num = UiaCoreTypesApi.UiaLookupId(type, ref guid);

            if (num == 0)
            {
                if ((!AutomationIdentifier.IsWin7OnlyPatternGuid(guid) && Environment.OSVersion.Version.Major <= 6) || Environment.OSVersion.Version.Major >= 7)
                {
                    int num2 = 1;
                    while (num == 0 && num2 < 1000)
                    {
                        Thread.Sleep(num2);
                        num   = UiaCoreTypesApi.UiaLookupId(type, ref guid);
                        num2 *= 2;
                    }
                }
                if (num == 0)
                {
                    return(null);
                }
            }
            Hashtable            idTable = AutomationIdentifier._idTable;
            AutomationIdentifier result;

            lock (idTable)
            {
                AutomationIdentifier automationIdentifier = (AutomationIdentifier)AutomationIdentifier._idTable[guid];
                if (automationIdentifier != null)
                {
                    result = automationIdentifier;
                }
                else
                {
                    switch (type)
                    {
                    case UiaCoreTypesApi.AutomationIdType.Property:
                        automationIdentifier = new AutomationProperty(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Pattern:
                        automationIdentifier = new AutomationPattern(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Event:
                        automationIdentifier = new AutomationEvent(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.ControlType:
                        automationIdentifier = new ControlType(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.TextAttribute:
                        automationIdentifier = new AutomationTextAttribute(num, guid, programmaticName);
                        break;

                    default:
                        throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                    }
                    AutomationIdentifier._idTable[num] = automationIdentifier;
                    result = automationIdentifier;
                }
            }
            return(result);
        }
Ejemplo n.º 34
0
        static TextPatternIdentifiers()
        {
            MixedAttributeValue = new object();

            Pattern =
                new AutomationPattern(PatternId,
                                      "TextPatternIdentifiers.Pattern");
            CaretMovedEvent =
                new AutomationEvent(CaretMovedEventId,
                                    "TextPatternIdentifiers.CaretMovedEvent");
            TextChangedEvent =
                new AutomationEvent(TextChangedEventId,
                                    "TextPatternIdentifiers.TextChangedEvent");
            TextSelectionChangedEvent =
                new AutomationEvent(TextSelectionChangedEventId,
                                    "TextPatternIdentifiers.TextSelectionChangedEvent");

            AnimationStyleAttribute =
                new AutomationTextAttribute(AnimationStyleAttributeId,
                                            "TextPatternIdentifiers.AnimationStyleAttribute");
            BackgroundColorAttribute =
                new AutomationTextAttribute(BackgroundColorAttributeId,
                                            "TextPatternIdentifiers.BackgroundColorAttribute");
            BulletStyleAttribute =
                new AutomationTextAttribute(BulletStyleAttributeId,
                                            "TextPatternIdentifiers.BulletStyleAttribute");
            CapStyleAttribute =
                new AutomationTextAttribute(CapStyleAttributeId,
                                            "TextPatternIdentifiers.CapStyleAttribute");
            CultureAttribute =
                new AutomationTextAttribute(CultureAttributeId,
                                            "TextPatternIdentifiers.CultureAttribute");
            FontNameAttribute =
                new AutomationTextAttribute(FontNameAttributeId,
                                            "TextPatternIdentifiers.FontNameAttribute");
            FontSizeAttribute =
                new AutomationTextAttribute(FontSizeAttributeId,
                                            "TextPatternIdentifiers.FontSizeAttribute");
            FontWeightAttribute =
                new AutomationTextAttribute(FontWeightAttributeId,
                                            "TextPatternIdentifiers.FontWeightAttribute");
            ForegroundColorAttribute =
                new AutomationTextAttribute(ForegroundColorAttributeId,
                                            "TextPatternIdentifiers.ForegroundColorAttribute");
            HorizontalTextAlignmentAttribute =
                new AutomationTextAttribute(HorizontalTextAlignmentAttributeId,
                                            "TextPatternIdentifiers.HorizontalTextAlignmentAttribute");
            IndentationFirstLineAttribute =
                new AutomationTextAttribute(IndentationFirstLineAttributeId,
                                            "TextPatternIdentifiers.IndentationFirstLineAttribute");
            IndentationLeadingAttribute =
                new AutomationTextAttribute(IndentationLeadingAttributeId,
                                            "TextPatternIdentifiers.IndentationLeadingAttribute");
            IndentationTrailingAttribute =
                new AutomationTextAttribute(IndentationTrailingAttributeId,
                                            "TextPatternIdentifiers.IndentationTrailingAttribute");
            IsHiddenAttribute =
                new AutomationTextAttribute(IsHiddenAttributeId,
                                            "TextPatternIdentifiers.IsHiddenAttribute");
            IsItalicAttribute =
                new AutomationTextAttribute(IsItalicAttributeId,
                                            "TextPatternIdentifiers.IsItalicAttribute");
            IsReadOnlyAttribute =
                new AutomationTextAttribute(IsReadOnlyAttributeId,
                                            "TextPatternIdentifiers.IsReadOnlyAttribute");
            IsSubscriptAttribute =
                new AutomationTextAttribute(IsSubscriptAttributeId,
                                            "TextPatternIdentifiers.IsSubscriptAttribute");
            IsSuperscriptAttribute =
                new AutomationTextAttribute(IsSuperscriptAttributeId,
                                            "TextPatternIdentifiers.IsSuperscriptAttribute");
            MarginBottomAttribute =
                new AutomationTextAttribute(MarginBottomAttributeId,
                                            "TextPatternIdentifiers.MarginBottomAttribute");
            MarginLeadingAttribute =
                new AutomationTextAttribute(MarginLeadingAttributeId,
                                            "TextPatternIdentifiers.MarginLeadingAttribute");
            MarginTopAttribute =
                new AutomationTextAttribute(MarginTopAttributeId,
                                            "TextPatternIdentifiers.MarginTopAttribute");
            MarginTrailingAttribute =
                new AutomationTextAttribute(MarginTrailingAttributeId,
                                            "TextPatternIdentifiers.MarginTrailingAttribute");
            OutlineStylesAttribute =
                new AutomationTextAttribute(OutlineStylesAttributeId,
                                            "TextPatternIdentifiers.OutlineStylesAttribute");
            OverlineColorAttribute =
                new AutomationTextAttribute(OverlineColorAttributeId,
                                            "TextPatternIdentifiers.OverlineColorAttribute");
            OverlineStyleAttribute =
                new AutomationTextAttribute(OverlineStyleAttributeId,
                                            "TextPatternIdentifiers.OverlineStyleAttribute");
            StrikethroughColorAttribute =
                new AutomationTextAttribute(StrikethroughColorAttributeId,
                                            "TextPatternIdentifiers.StrikethroughColorAttribute");
            StrikethroughStyleAttribute =
                new AutomationTextAttribute(StrikethroughStyleAttributeId,
                                            "TextPatternIdentifiers.StrikethroughStyleAttribute");
            TabsAttribute =
                new AutomationTextAttribute(TabsAttributeId,
                                            "TextPatternIdentifiers.TabsAttribute");
            TextFlowDirectionsAttribute =
                new AutomationTextAttribute(TextFlowDirectionsAttributeId,
                                            "TextPatternIdentifiers.TextFlowDirectionsAttribute");
            UnderlineColorAttribute =
                new AutomationTextAttribute(UnderlineColorAttributeId,
                                            "TextPatternIdentifiers.UnderlineColorAttribute");
            UnderlineStyleAttribute =
                new AutomationTextAttribute(UnderlineStyleAttributeId,
                                            "TextPatternIdentifiers.UnderlineStyleAttribute");
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Called by a client to remove a listener for pattern or custom events.
        /// </summary>
        /// <param name="eventId">a UIAccess or custom event identifier.</param>
        /// <param name="element">Element to remove listener for</param>
        /// <param name="eventHandler">The handler object that was passed to AddEventListener</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 RemoveAutomationEventHandler(
            AutomationEvent eventId,
            AutomationElement element,
            AutomationEventHandler eventHandler
            )
        {
            Misc.ValidateArgumentNonNull(element, "element" );
            Misc.ValidateArgumentNonNull(eventHandler, "eventHandler" );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationFocusChangedEvent, SRID.EventIdMustNotBeAutomationFocusChanged );
            Misc.ValidateArgument( eventId != AutomationElement.StructureChangedEvent, SRID.EventIdMustNotBeStructureChanged );
            Misc.ValidateArgument( eventId != AutomationElement.AutomationPropertyChangedEvent, SRID.EventIdMustNotBeAutomationPropertyChanged );

            //CASRemoval:AutomationPermission.Demand( AutomationPermissionFlag.Read );

            // Remove the client-side listener for for this event
            ClientEventManager.RemoveListener( eventId, element, eventHandler );
        }
Ejemplo n.º 36
0
        void IUIAutomationEventHandler.HandleAutomationEvent(
            IUIAutomationElement sender,
            int eventId)
        {
            AutomationElement automationElement = null;

            if (sender != null)
            {
                automationElement = new AutomationElement(autoElement: sender);
            }
            if (eventId == 20017)
            {
                this._handlingDelegate(sender: automationElement, e: new WindowClosedEventArgs(runtimeId: automationElement.GetRuntimeId()));
            }
            else
            {
                this._handlingDelegate(sender: automationElement, e: new AutomationEventArgs(eventId: AutomationEvent.LookupById(id: eventId)));
            }
        }