public EventsListener(Visual visual)
        {
            current     = this;
            this.visual = visual;

            var type = visual.GetType();

            // Cannot unregister for events once we've registered, so keep the registration simple and only do it once.
            for (var baseType = type; baseType != null; baseType = baseType.BaseType)
            {
                if (registeredTypes.ContainsKey(baseType))
                {
                    continue;
                }

                registeredTypes[baseType] = baseType;

                var routedEvents = EventManager.GetRoutedEventsForOwner(baseType);
                if (routedEvents != null)
                {
                    foreach (var routedEvent in routedEvents)
                    {
                        EventManager.RegisterClassHandler(baseType, routedEvent, new RoutedEventHandler(HandleEvent), true);
                    }
                }
            }
        }
 public static void Stop()
 {
     current = null;
 }