/// <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"); } // Create a new RoutedEventHandler RoutedEventHandlerInfo routedEventHandlerInfo = new RoutedEventHandlerInfo(handler, handledEventsToo); // Get the entry corresponding to the given RoutedEvent ArrayList handlers = this[routedEvent]; if (handlers == null) { _keys.Add(routedEvent); _values.Add(handlers = new ArrayList()); } // Add the RoutedEventHandlerInfo to the list handlers.Add(routedEventHandlerInfo); }
/// <summary> /// Is the given object equivalent to the current one /// </summary> public override bool Equals(object obj) { RoutedEventHandlerInfo tmp = obj as RoutedEventHandlerInfo; if (tmp == null) { return(false); } return(Equals(tmp)); }
/// <summary> /// Invokes the handler associated with the specified RouteItem /// </summary> /// <param name="routeItem"> /// RouteItem containing handler and target /// </param> internal void InvokeHandler(RouteItem routeItem) { RoutedEventHandlerInfo routedEventHandlerInfo = routeItem._routedEventHandlerInfo; if (this.Handled == false || routedEventHandlerInfo._handledEventsToo == true) { Delegate handler = routedEventHandlerInfo._handler; _flags |= Flags.InvokingHandler; try { handler.Method.Invoke(handler.Target, new object[] { routeItem._target, this }); } finally { _flags &= ~Flags.InvokingHandler; } } }
/// <summary> /// Invokes the handler associated with the specified RouteItem /// </summary> /// <param name="routeItem"> /// RouteItem containing handler and target /// </param> internal void InvokeHandler(RouteItem routeItem) { RoutedEventHandlerInfo routedEventHandlerInfo = routeItem._routedEventHandlerInfo; if (this.Handled == false || routedEventHandlerInfo._handledEventsToo == true) { RoutedEventHandler handler = routedEventHandlerInfo._handler; _flags |= Flags.InvokingHandler; try { handler(routeItem._target, this); } finally { _flags &= ~Flags.InvokingHandler; } } }
/// <summary> /// Is the given RoutedEventHandlerInfo equals the current /// </summary> public bool Equals(RoutedEventHandlerInfo handlerInfo) { return(_handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo); }
/// <summary> /// Is the given RoutedEventHandlerInfo equals the current /// </summary> public bool Equals(RoutedEventHandlerInfo handlerInfo) { return _handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo; }
private static void AddRoutedEventHandler( Hashtable table, RoutedEvent routedEvent, RoutedEventHandler handler, bool handledEventsToo) { if (routedEvent == null || handler == null) { throw new ArgumentNullException(); } // Create a new RoutedEventHandler RoutedEventHandlerInfo routedEventHandlerInfo = new RoutedEventHandlerInfo(handler, handledEventsToo); // Get the entry corresponding to the given RoutedEvent ArrayList handlers = (ArrayList)table[routedEvent]; if (handlers == null) { table[routedEvent] = (handlers = new ArrayList()); } // Add the RoutedEventHandlerInfo to the list handlers.Add(routedEventHandlerInfo); }
// Constructor for RouteItem internal RouteItem(object target, RoutedEventHandlerInfo routedEventHandlerInfo) { _target = target; _routedEventHandlerInfo = routedEventHandlerInfo; }