/// <summary>
        ///     Adds a routed event handler for the given
        ///     RoutedEvent to the store
        /// </summary>
        public void AddRoutedEventHandler(
            RoutedEvent routedEvent,
            Delegate handler,
            bool handledEventsToo)
        {
            if (routedEvent == null)
            {
                throw new ArgumentNullException("routedEvent");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            if (!routedEvent.IsLegalHandler(handler))
            {
                throw new ArgumentException(SR.Get(SRID.HandlerTypeIllegal));
            }

            // Create a new RoutedEventHandler
            RoutedEventHandlerInfo routedEventHandlerInfo =
                new RoutedEventHandlerInfo(handler, handledEventsToo);

            // Get the entry corresponding to the given RoutedEvent
            FrugalObjectList <RoutedEventHandlerInfo> handlers = (FrugalObjectList <RoutedEventHandlerInfo>) this[routedEvent];

            if (handlers == null)
            {
                _entries[routedEvent.GlobalIndex] = handlers = new FrugalObjectList <RoutedEventHandlerInfo>(1);
            }

            // Add the RoutedEventHandlerInfo to the list
            handlers.Add(routedEventHandlerInfo);
        }
        // Adds a routed event handler at the given index of the store
        // Returns updated set of handlers
        // NOTE: index must be valid, i.e. not -1
        internal RoutedEventHandlerInfoList AddToExistingHandlers(
            int index,
            Delegate handler,
            bool handledEventsToo)
        {
            Debug.Assert(index != -1, "There should exist a set of handlers for the given routedEvent");

            // Create a new RoutedEventHandler
            RoutedEventHandlerInfo routedEventHandlerInfo =
                new RoutedEventHandlerInfo(handler, handledEventsToo);

            // Check if we need to create a new node in the linked list
            RoutedEventHandlerInfoList handlers = _eventHandlersList.List[index].Handlers;

            if (handlers == null || _eventHandlersList.List[index].HasSelfHandlers == false)
            {
                // Create a new node in the linked list of class
                // handlers for this type and routed event.
                handlers             = new RoutedEventHandlerInfoList();
                handlers.Handlers    = new RoutedEventHandlerInfo[1];
                handlers.Handlers[0] = routedEventHandlerInfo;
                handlers.Next        = _eventHandlersList.List[index].Handlers;
                _eventHandlersList.List[index].Handlers        = handlers;
                _eventHandlersList.List[index].HasSelfHandlers = true;
            }
            else
            {
                // Add this handler to the existing node in the linked list
                // of class handlers for this type and routed event.
                int length = handlers.Handlers.Length;
                RoutedEventHandlerInfo[] mergedHandlers = new RoutedEventHandlerInfo[length + 1];
                Array.Copy(handlers.Handlers, 0, mergedHandlers, 0, length);
                mergedHandlers[length] = routedEventHandlerInfo;
                handlers.Handlers      = mergedHandlers;
            }

            return(handlers);
        }
예제 #3
0
        // Adds a routed event handler at the given index of the store
        // Returns updated set of handlers
        // NOTE: index must be valid, i.e. not -1
        internal RoutedEventHandlerInfoList AddToExistingHandlers(
            int index,
            Delegate handler,
            bool handledEventsToo)
        {
            Debug.Assert(index != -1, "There should exist a set of handlers for the given routedEvent");

            // Create a new RoutedEventHandler
            RoutedEventHandlerInfo routedEventHandlerInfo = 
                new RoutedEventHandlerInfo(handler, handledEventsToo);            

            // Check if we need to create a new node in the linked list
            RoutedEventHandlerInfoList handlers =  _eventHandlersList.List[index].Handlers;
            if (handlers == null || _eventHandlersList.List[index].HasSelfHandlers == false)
            {
                // Create a new node in the linked list of class 
                // handlers for this type and routed event.
                handlers = new RoutedEventHandlerInfoList();
                handlers.Handlers = new RoutedEventHandlerInfo[1];
                handlers.Handlers[0] = routedEventHandlerInfo;
                handlers.Next = _eventHandlersList.List[index].Handlers;
                _eventHandlersList.List[index].Handlers = handlers;
                _eventHandlersList.List[index].HasSelfHandlers = true;
            }
            else
            {
                // Add this handler to the existing node in the linked list 
                // of class handlers for this type and routed event.
                int length = handlers.Handlers.Length;
                RoutedEventHandlerInfo[] mergedHandlers = new RoutedEventHandlerInfo[length + 1];
                Array.Copy(handlers.Handlers, 0, mergedHandlers,  0, length);
                mergedHandlers[length] = routedEventHandlerInfo;
                handlers.Handlers = mergedHandlers;
            }            

            return handlers;
         }
예제 #4
0
 // Constructor for RouteItem
 internal RouteItem(object target, RoutedEventHandlerInfo routedEventHandlerInfo) 
 { 
     _target = target;
     _routedEventHandlerInfo = routedEventHandlerInfo; 
 }
예제 #5
0
 /// <summary>
 ///     Is the given RoutedEventHandlerInfo equals the current
 /// </summary>
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
     return _handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo;
 }
예제 #6
0
 // This is a helper that will facilitate adding a given array of handlers to the route
 private static void AddStyleHandlersToEventRoute(
     EventRoute route, 
     DependencyObject source,
     RoutedEventHandlerInfo[] handlers) 
 { 
     if (handlers != null)
     { 
         for (int i=0; i<handlers.Length; i++)
         {
             route.Add(source, handlers[i].Handler, handlers[i].InvokeHandledEventsToo);
         } 
     }
 } 
예제 #7
0
 private static void AddStyleHandlersToEventRoute(EventRoute route, DependencyObject source, RoutedEventHandlerInfo[] handlers)
 {
     if (handlers == null)
     return;
       for (int index = 0; index < handlers.Length; ++index)
     route.Add((object) source, handlers[index].Handler, handlers[index].InvokeHandledEventsToo);
 }
예제 #8
0
 // Constructor for RouteItem
 internal RouteItem(object target, RoutedEventHandlerInfo routedEventHandlerInfo)
 {
     _target = target;
     _routedEventHandlerInfo = routedEventHandlerInfo;
 }
 /// <summary>
 ///     Is the given RoutedEventHandlerInfo equals the current
 /// </summary>
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
     return(_handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo);
 }
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
   return default(bool);
 }
예제 #11
0
        /// <summary>
        ///     Adds a routed event handler for the given 
        ///     RoutedEvent to the store
        /// </summary> 
        public void AddRoutedEventHandler( 
            RoutedEvent routedEvent,
            Delegate handler, 
            bool handledEventsToo)
        {
            if (routedEvent == null)
            { 
                throw new ArgumentNullException("routedEvent");
            } 
            if (handler == null) 
            {
                throw new ArgumentNullException("handler"); 
            }
            if (!routedEvent.IsLegalHandler(handler))
            {
                throw new ArgumentException(SR.Get(SRID.HandlerTypeIllegal)); 
            }
 
            // Create a new RoutedEventHandler 
            RoutedEventHandlerInfo routedEventHandlerInfo =
                new RoutedEventHandlerInfo(handler, handledEventsToo); 

            // Get the entry corresponding to the given RoutedEvent
            FrugalObjectList<RoutedEventHandlerInfo> handlers = (FrugalObjectList<RoutedEventHandlerInfo>)this[routedEvent];
            if (handlers == null) 
            {
                _entries[routedEvent.GlobalIndex] = handlers = new FrugalObjectList<RoutedEventHandlerInfo>(1); 
            } 

            // Add the RoutedEventHandlerInfo to the list 
            handlers.Add(routedEventHandlerInfo);
        }
예제 #12
0
        public void AddRoutedEventHandler(RoutedEvent routedEvent, Delegate handler, bool handledEventsToo)
        {
            EventManager.CheckParameters(routedEvent, handler);

            RoutedEventHandlerInfo info = new RoutedEventHandlerInfo(handler, handledEventsToo);
            List<RoutedEventHandlerInfo> list = this[routedEvent];
            if (list == null)
            {
                this.entries[routedEvent.GlobalIndex] = list = new List<RoutedEventHandlerInfo>();
            }
            list.Add(info);
        }
예제 #13
0
 internal RouteItem(object target, RoutedEventHandlerInfo routedEventHandlerInfo)
     : this()
 {
     this.Target = target;
     this.routedEventHandlerInfo = routedEventHandlerInfo;
 }
예제 #14
0
 public bool Equals(RoutedEventHandlerInfo handlerInfo)
 {
     return(default(bool));
 }