Beispiel #1
0
 public virtual void RaiseActiveTextPositionChangedEvent(TextPointer rangeStart, TextPointer rangeEnd)
 {
     if (EventMap.HasRegisteredEvent(AutomationEvents.ActiveTextPositionChanged))
     {
         IRawElementProviderSimple provider = ProviderFromPeer(this);
         if (provider != null)
         {
             ActiveTextPositionChangedEventArgs args = new ActiveTextPositionChangedEventArgs(TextRangeFromTextPointers(rangeStart, rangeEnd));
             AutomationInteropProvider.RaiseAutomationEvent(
                 AutomationElementIdentifiers.ActiveTextPositionChangedEvent,
                 provider,
                 args);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Called to notify listeners of a pattern or custom event.  This could could be called by a server implementation or by a proxy's event
        /// translator.
        /// </summary>
        /// <param name="eventId">An AutomationEvent representing this event.</param>
        /// <param name="provider">The actual server-side element associated with this event.</param>
        /// <param name="e">Contains information about the event (may be null).</param>
        public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e)
        {
            ValidateArgumentNonNull(eventId, "eventId");
            ValidateArgumentNonNull(provider, "provider");
            ValidateArgumentNonNull(e, "e");

            // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here.
            // False positive, e is checked, see above
#pragma warning suppress 6506
            if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent)
            {
                AsyncContentLoadedEventArgs asyncArgs = e as AsyncContentLoadedEventArgs;
                if (asyncArgs == null)
                {
                    ThrowInvalidArgument("e");
                }

                UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, asyncArgs.AsyncContentLoadedState, asyncArgs.PercentComplete);
                return;
            }

            // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here.
            // False positive, e is checked, see above
#pragma warning suppress 6506
            if (e.EventId == AutomationElementIdentifiers.NotificationEvent)
            {
                NotificationEventArgs notificationArgs = e as NotificationEventArgs;
                if (notificationArgs == null)
                {
                    ThrowInvalidArgument("e");
                }

                UiaCoreProviderApi.UiaRaiseNotificationEvent(provider,
                                                             notificationArgs.NotificationKind,
                                                             notificationArgs.NotificationProcessing,
                                                             notificationArgs.DisplayString,
                                                             notificationArgs.ActivityId);
                return;
            }

            // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here.
            // False positive, e is checked, see above
#pragma warning suppress 6506
            if (e.EventId == AutomationElementIdentifiers.ActiveTextPositionChangedEvent)
            {
                ActiveTextPositionChangedEventArgs activeTextPositionChangedArgs = e as ActiveTextPositionChangedEventArgs;
                if (activeTextPositionChangedArgs == null)
                {
                    ThrowInvalidArgument("e");
                }

                UiaCoreProviderApi.UiaRaiseActiveTextPositionChangedEvent(provider, activeTextPositionChangedArgs.TextRange);
                return;
            }

            // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here.
            // False positive, e is checked, see above
#pragma warning suppress 6506
            if (e.EventId == WindowPatternIdentifiers.WindowClosedEvent && !(e is WindowClosedEventArgs))
            {
                ThrowInvalidArgument("e");
            }

            // fire to all clients
            // PRESHARP will flag this as warning 56506/6506:Parameter 'eventId' to this public method must be validated: A null-dereference can occur here.
            // False positive, eventId is checked, see above
#pragma warning suppress 6506
            UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id);
        }