示例#1
0
        public int RegisterElement(EventActionGroup eag)
        {
            Console.WriteLine("Registering: " + eag.ID);
            this.RegisteredElements.Add(eag.ID, eag);

            this.event_handler.RegisterEvent(eag);
            return(1);
        }
示例#2
0
        public void RegisterEvent(EventActionGroup eag)
        {
            var hold = eag.Events.Keys.ToArray();

            foreach (string event_name in hold)
            {
                eag.Events[event_name] = (event_args) =>
                {
                    if (this.PipelineEvents.TryGetValue(event_name, out var run_event))
                    {
                        if (event_args.GetType().IsSubclassOf(typeof(EventData)))
                        {
                            run_event(null, event_args, PROPAGATING);
                        }
                        else
                        {
                            run_event(eag.ID, event_args, STARTING);
                            //start of bubble
                        }
                    }

                    var source_args = this.GetEventMoreID(eag.ID, event_args);

                    eag.FiredEvents[event_name](
                        source_args
                        );

                    if (eag.Parent != null)
                    {
                        eag.Parent.Events[event_name](source_args);
                    }
                    else
                    {
                        //end of the bubble.
                        if (run_event != null)
                        {
                            run_event(eag.ID, event_args, BUBBLE_ENDING);
                        }
                    }
                };
            }
        }
示例#3
0
 public void UnregisterElement(EventActionGroup eag)
 {
     Console.WriteLine("Unregistering: " + eag.ID);
     this.RegisteredElements.Remove(eag.ID);
 }