Beispiel #1
0
        /// <summary> Registers a class handler for a particular routed event, with the option to handle events where event data is already marked handled.</summary>
        /// <param name="classType">The type of the class that is declaring class handling.</param>
        /// <param name="routedEvent">The routed event identifier of the event to handle.</param>
        /// <param name="handler">A reference to the class handler implementation.</param>
        /// <param name="handledEventsToo">true to invoke this class handler even if arguments of the routed event have been marked as handled; false to retain the default behavior of not invoking the handler on any marked-handled event.</param>
        public static void RegisterClassHandler(Type classType, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo)
        {
            if (classType == null)
            {
                throw new ArgumentNullException("classType");
            }
            if (routedEvent == null)
            {
                throw new ArgumentNullException("routedEvent");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            if (!typeof(UIElement).IsAssignableFrom(classType))
            {
                throw new ArgumentException("Illegal class type " + classType.FullName);
            }
            if (!IsLegalHandler(routedEvent, handler))
            {
                throw new ArgumentException("Illegal Handler type for " + routedEvent.Name + " event");
            }

            ClassHandlerInfo c = AddClassHandler(routedEvent, handler);

            Noesis_EventManager_RegisterClassHandler(Extend.GetNativeType(classType),
                                                     BaseComponent.getCPtr(routedEvent).Handle, handledEventsToo,
                                                     Extend.GetInstanceHandle(c).Handle, _classHandler);
        }
Beispiel #2
0
        private static RoutedEvent AddRoutedEvent(string name, RoutingStrategy routingStrategy,
                                                  Type handlerType, Type ownerType)
        {
            IntPtr routedEventPtr = Noesis_EventManager_RegisterRoutedEvent(name,
                                                                            (int)routingStrategy, Extend.GetNativeType(ownerType));

            RoutedEvent routedEvent = (RoutedEvent)Extend.GetProxy(routedEventPtr, false);

            RegisterRoutedEvent(routedEvent, handlerType, GetInvoker(handlerType));

            return(routedEvent);
        }