/// <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 == 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);
        }
Ejemplo n.º 2
0
        public void AsyncContentLoadedStateTest()
        {
            AsyncContentLoadedEventArgs args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, 0.0);

            Assert.AreEqual(AsyncContentLoadedState.Beginning, args.AsyncContentLoadedState, "Beginning");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Progress, 0.0);
            Assert.AreEqual(AsyncContentLoadedState.Progress, args.AsyncContentLoadedState, "Progress");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Completed, 0.0);
            Assert.AreEqual(AsyncContentLoadedState.Completed, args.AsyncContentLoadedState, "Completed");
        }
Ejemplo n.º 3
0
        public void PercentCompleteTest()
        {
            AsyncContentLoadedEventArgs args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, 0.0);

            Assert.AreEqual(0.0, args.PercentComplete, "0.0");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, 50.0);
            Assert.AreEqual(50.0, args.PercentComplete, "50.0");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, 100.0);
            Assert.AreEqual(100.0, args.PercentComplete, "100.0");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, 101.0);
            Assert.AreEqual(101.0, args.PercentComplete, "101.0");
            args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Beginning, -1.0);
            Assert.AreEqual(-1.0, args.PercentComplete, "-1.0");
        }
Ejemplo n.º 4
0
 public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e)
 {
     AutomationInteropProvider.ValidateArgumentNonNull(eventId, "eventId");
     AutomationInteropProvider.ValidateArgumentNonNull(provider, "provider");
     AutomationInteropProvider.ValidateArgumentNonNull(e, "e");
     if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent)
     {
         AsyncContentLoadedEventArgs asyncContentLoadedEventArgs = e as AsyncContentLoadedEventArgs;
         if (asyncContentLoadedEventArgs == null)
         {
             AutomationInteropProvider.ThrowInvalidArgument("e");
         }
         UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, asyncContentLoadedEventArgs.AsyncContentLoadedState, asyncContentLoadedEventArgs.PercentComplete);
         return;
     }
     if (e.EventId == WindowPatternIdentifiers.WindowClosedEvent && !(e is WindowClosedEventArgs))
     {
         AutomationInteropProvider.ThrowInvalidArgument("e");
     }
     UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id);
 }
Ejemplo n.º 5
0
 public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e)
 {
     Utility.ValidateArgumentNonNull(eventId, "eventId");
     Utility.ValidateArgumentNonNull(provider, "provider");
     Utility.ValidateArgumentNonNull(e, "e");
     if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent)
     {
         AsyncContentLoadedEventArgs args = e as AsyncContentLoadedEventArgs;
         if (args == null)
         {
             throw new ArgumentException("e");
         }
         UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, args.AsyncContentLoadedState, args.PercentComplete);
     }
     else
     {
         if ((e.EventId == WindowPatternIdentifiers.WindowClosedEvent) && !(e is WindowClosedEventArgs))
         {
             throw new ArgumentException("e");
         }
         UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id);
     }
 }
Ejemplo n.º 6
0
        public void EventIdTest()
        {
            AsyncContentLoadedEventArgs args = new AsyncContentLoadedEventArgs(AsyncContentLoadedState.Progress, 0.0);

            Assert.AreEqual(AutomationElementIdentifiers.AsyncContentLoadedEvent, args.EventId, "EventId");
        }
Ejemplo n.º 7
0
        public void RaiseAsyncContentLoadedEvent(AsyncContentLoadedEventArgs args)
        {
            if(args == null)
                throw new ArgumentNullException("args");

            if (EventMap.HasRegisteredEvent(AutomationEvents.AsyncContentLoaded))
            {
                IRawElementProviderSimple provider = ProviderFromPeer(this);
                if(provider != null)
                {
                    AutomationInteropProvider.RaiseAutomationEvent(
                        AutomationElementIdentifiers.AsyncContentLoadedEvent,
                        provider,
                        args);
                }
            }
        }