internal List<FunctionalEventHandlerContainer> GetHandlerList(FunctionalEvent functionalEvent, IFunctionalTreeElement element)
        {
            if (HandlerListInternal.ContainsKey(functionalEvent) && HandlerListInternal[functionalEvent].ContainsKey(element))
                return HandlerListInternal[functionalEvent][element];

            return null;
        }
        public static void AddFunctionalHandler(this IFunctionalTreeElement source, FunctionalEvent functionalEvent, Delegate handler)
        {
            if (source == null)
                return;

            AddFunctionalHandler(source, functionalEvent, handler, false);
        }
        public FunctionalEventArgs(FunctionalEvent functionalEvent)
        {
            if (functionalEvent == null)
                throw new ArgumentNullException("functionalEvent", "functionalEvent is null.");

            FunctionalEvent = functionalEvent;
        }
        public static void AddFunctionalHandler(this IFunctionalTreeElement source, FunctionalEvent functionalEvent, Delegate handler, bool handledEventsToo)
        {
            if (source == null)
                return;
            if (functionalEvent == null)
                throw new ArgumentNullException("functionalEvent", "functionalEvent is null.");

            FunctionalEventManager.Instance.AddHandler(functionalEvent, source, handler, handledEventsToo);
        }
Example #5
0
        static DockingBase()
        {
            //Register Dependency Properties
            IsEmptyProperty = DependencyProperty.Register("IsEmpty", typeof(bool), typeof(DockingBase), new UIPropertyMetadata(false));
            DockingWidthProperty = DependencyProperty.Register("DockingWidth", typeof(GridLength), typeof(DockingBase), new UIPropertyMetadata(new GridLengthConverter().ConvertFrom("*")));
            DockingHeightProperty = DependencyProperty.Register("DockingHeight", typeof(GridLength), typeof(DockingBase), new UIPropertyMetadata(new GridLengthConverter().ConvertFrom("*")));

            //Register Functional Properties
            DockManagerProperty = FunctionalProperty.Register("DockManager", typeof(DockManager), typeof(DockingBase),
                new FunctionalPropertyMetadata(null, FunctionalPropertyMetadataOptions.Inherits, DockManagerChangedHandler));

            //Register Events
            ClosedEvent = FunctionalEventManager.RegisterEvent("Closed", FunctionalStrategy.Bubble, typeof(FunctionalEventHandler), typeof(DockingBase));
        }
        static TestingElement()
        {
            // Functional Properties
            InfoProperty = FunctionalProperty.Register("Info", typeof(string), typeof(TestingElement),
                new FunctionalPropertyMetadata("Empty", FunctionalPropertyMetadataOptions.Inherits, InfoChangedHandler, InfoCoercingHandler), InfoValidateHandler);

            // Functional Events
            BubblingTestEvent = FunctionalEventManager.RegisterEvent("BubblingTest", FunctionalStrategy.Bubble, typeof(FunctionalEventHandler), typeof(TestingElement));
            TunnelingTestEvent = FunctionalEventManager.RegisterEvent("TunnelingTest", FunctionalStrategy.Tunnel, typeof(FunctionalEventHandler), typeof(TestingElement));
            ParentTestEvent = FunctionalEventManager.RegisterEvent("ParentTest", FunctionalStrategy.Parent, typeof(FunctionalEventHandler), typeof(TestingElement));
            SiblingsTestEvent = FunctionalEventManager.RegisterEvent("SiblingsTest", FunctionalStrategy.Siblings, typeof(FunctionalEventHandler), typeof(TestingElement));
            DescendentsTestEvent = FunctionalEventManager.RegisterEvent("DescendentsTest", FunctionalStrategy.Descendents, typeof(FunctionalEventHandler), typeof(TestingElement));
            ChildrenTestEvent = FunctionalEventManager.RegisterEvent("ChildrenTest", FunctionalStrategy.Children, typeof(FunctionalEventHandler), typeof(TestingElement));
            SpreadTestEvent = FunctionalEventManager.RegisterEvent("SpreadTest", FunctionalStrategy.Spread, typeof(FunctionalEventHandler), typeof(TestingElement));
        }
        internal void AddHandler(FunctionalEvent functionalEvent, IFunctionalTreeElement element, Delegate handler, bool handledEventsToo = false)
        {
            if (functionalEvent == null)
                throw new ArgumentNullException("functionalEvent", "functionalEvent is null.");
            if (element == null)
                throw new ArgumentNullException("element", "element is null.");
            if (handler == null)
                throw new ArgumentNullException("handler", "handler is null.");
            if (handler.GetType() != functionalEvent.HandlerType && handler.GetType() != typeof(FunctionalEventHandler))
                throw new ArgumentException("handler", "Handler type mismatched.");

            if (!HandlerListInternal.ContainsKey(functionalEvent))
            {
                HandlerListInternal[functionalEvent] = new Dictionary<IFunctionalTreeElement, List<FunctionalEventHandlerContainer>>();
            }
            if (!HandlerListInternal[functionalEvent].ContainsKey(element))
            {
                HandlerListInternal[functionalEvent][element] = new List<FunctionalEventHandlerContainer>();
            }

            GetHandlerList(functionalEvent, element).Add(new FunctionalEventHandlerContainer(handler, handledEventsToo));
        }
 public FunctionalDockingBaseEventArgs(FunctionalEvent functionalEvent, DockingBase target)
     : base(functionalEvent)
 {
     Target = target;
 }
        private void EventTracer_EventRaising(FunctionalEvent functionalEvent, FunctionalEventTracingArgs e)
        {
            TestingElement previous = e.PreviousElement as TestingElement;
            TestingElement next = e.NextElement as TestingElement;
            string previousName = previous != null ? previous.Name : "";
            string nextName = next != null ? next.Name : "";
            string currentName = (e.CurrentElement as TestingElement).Name;

            WriteEventTracingLine(string.Format("[EventRaising] Event: {0}   Previous: {1}  Current: {2}  Next: {3}", functionalEvent.Name, previousName, currentName, nextName));
        }
        /// <summary>
        /// Registers a new functional event.
        /// </summary>
        /// <param name="name">The name of the functional event. The name must be unique within the owner type and cannot be null or an empty string.</param>
        /// <param name="functionalStretegy">The functional strategy of the event as a value of the enumeration.</param>
        /// <param name="handlerType">The type of the event handler. This must be a delegate type and cannot be null.</param>
        /// <param name="ownerType">The owner class type of the routed event. This cannot be null.</param>
        private FunctionalEvent RegisterEventInternal(string name, FunctionalStrategy functionalStrategy, Type handlerType, Type ownerType)
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentNullException("name", "name is null.");
            if (handlerType == null)
                throw new ArgumentNullException("handlerType", "handlerType is null.");
            if (ownerType == null)
                throw new ArgumentNullException("ownerType", "ownerType is null.");
            if (FunctionalEventsInternal.ContainsKey(ownerType))
            {
                if (FunctionalEventsInternal[ownerType].Any(cur => cur.Name == name))
                    throw new ArgumentException(String.Format("RoutedEvent Name '{0}' for OwnerType '{1}' already used.", name, ownerType));
            }

            FunctionalEvent functionalEvent = new FunctionalEvent(name, functionalStrategy, handlerType, ownerType);
            if (!FunctionalEventsInternal.ContainsKey(ownerType))
                FunctionalEventsInternal[ownerType] = new List<FunctionalEvent>();

            FunctionalEventsInternal[ownerType].Add(functionalEvent);
            return functionalEvent;
        }
        internal void RemoveHandler(FunctionalEvent functionalEvent, IFunctionalTreeElement element, Delegate handler)
        {
            if (functionalEvent == null)
                throw new ArgumentNullException("functionalEvent", "functionalEvent is null.");
            if (element == null)
                throw new ArgumentNullException("element", "element is null.");
            if (handler == null)
                throw new ArgumentNullException("handler", "handler is null.");

            List<FunctionalEventHandlerContainer> handlerList = GetHandlerList(functionalEvent, element);
            if (handlerList != null)
                handlerList.RemoveAll(cur => cur.Handler == handler);
        }
        /// <summary>
        /// The event will be raised only on objects of type T.
        /// </summary>
        internal void RaiseEventPair(FunctionalEvent tunnelEvent, FunctionalEvent bubbleEvent, FunctionalEventArgs eventArgs, Predicate<IFunctionalTreeElement> predicate = null)
        {
            if (tunnelEvent == null)
                throw new ArgumentNullException("tunnelEvent", "tunnelEvent is null.");
            if (bubbleEvent == null)
                throw new ArgumentNullException("bubbleEvent", "bubbleEvent is null.");
            if (eventArgs == null)
                throw new ArgumentNullException("eventArgs", "eventArgs is null.");

            if (tunnelEvent.FunctionalStretegy != FunctionalStrategy.Tunnel)
                throw new ArgumentNullException("tunnelEvent", "tunnelEvent is not tunnel.");
            if (bubbleEvent.FunctionalStretegy != FunctionalStrategy.Bubble)
                throw new ArgumentNullException("bubbleEvent", "bubbleEvent is bubble.");

            if (!FunctionalEventsInternal.ContainsKey(eventArgs.FunctionalEvent.OwnerType))
                return;

            eventArgs.FunctionalEvent = tunnelEvent;
            RaiseEvent(eventArgs, predicate);

            eventArgs.FunctionalEvent = bubbleEvent;
            RaiseEvent(eventArgs, predicate);
        }
 internal void RaiseEventRaising(FunctionalEvent functionalEvent, FunctionalEventTracingArgs eventRaisingArgs)
 {
     if (EventRaising != null)
         EventRaising(functionalEvent, eventRaisingArgs);
 }
        public static void RaiseFunctionalEventPair(this IFunctionalTreeElement source, 
            FunctionalEvent tunnelEvent, 
            FunctionalEvent bubbleEvent, 
            FunctionalEventArgs e,
            Predicate<IFunctionalTreeElement> predicate)
        {
            if (source == null || tunnelEvent == null || bubbleEvent == null || e == null)
                return;

            e.Source = source;
            FunctionalEventManager.Instance.RaiseEventPair(tunnelEvent, bubbleEvent, e, predicate);
        }
 public static void RaiseFunctionalEventPair(this IFunctionalTreeElement source, 
     FunctionalEvent tunnelEvent, 
     FunctionalEvent bubbleEvent, 
     FunctionalEventArgs e)
 {
     RaiseFunctionalEventPair(source, tunnelEvent, bubbleEvent, e, null);
 }
 static DockingContentBase()
 {
     //Register Events
     ItemPromotedEvent = FunctionalEventManager.RegisterEvent("ItemPromoted", FunctionalStrategy.Bubble, typeof(FunctionalDockingBaseEventHandler), typeof(DockingContentBase));
 }