示例#1
0
        public ImageTracker(string name)
            : base()
        {
            Console.WriteLine("MyImage created");
            this.name = name;
            pushDetector = new PushDetector();
            circleDetector = new CircleDetector();
            circleDetector.MinimumPoints = 50;
            steadyDetector = new SteadyDetector();

            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(circleDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            circleDetector.OnCircle += new EventHandler<CircleEventArgs>(circleDetector_OnCircle);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyBox_PrimaryPointDestroy);
            PrimaryPointUpdate += new EventHandler<HandEventArgs>(MyBox_PrimaryPointUpdate);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
        public void TestBroadcaster()
        {
            var test      = new Broadcaster();
            var listener  = new TestListener();
            var listener2 = new TestListener();

            test.AddListener(listener);
            Assert.AreEqual(1, test.listeners.Count);
            test.RemoveListener(listener);
            Assert.AreEqual(0, test.listeners.Count);

            test.AddListener(listener);
            test.AddListener(listener2);
            test.Broadcast(new Event("hello"));
            Assert.AreEqual("hello", listener.lastMessage);
            Assert.AreEqual("hello", listener2.lastMessage);

            test.RemoveListener(listener);
            test.Broadcast(new Event("goodbye"));
            Assert.AreEqual("hello", listener.lastMessage);
            Assert.AreEqual("goodbye", listener2.lastMessage);

            test.Clear();
            Assert.AreEqual(0, test.listeners.Count);
        }
 public void AddListener(MessageListener listener)
 {
     if (null == broadcaster)
     {
         broadcaster = new Broadcaster();
     }
     broadcaster.AddListener(listener);
 }
 protected void AddListener(MessageListener listener)
 {
     if (null == internalBroadcaster)
     {
         internalBroadcaster = new Broadcaster();
     }
     internalBroadcaster.AddListener(listener);
 }
示例#5
0
        public HandData()
            : base()
        {
            Console.WriteLine("Constructing MyCanvas");
            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyCanvas_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyCanvas_PrimaryPointDestroy);
            PrimaryPointUpdate += new EventHandler<HandEventArgs>(MyCanvas_PrimaryPointUpdate);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyCanvas_OnUpdate);
        }
示例#6
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push +=new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
示例#7
0
文件: MyBox.cs 项目: martindale/nestk
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady      += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate            += new UpdateHandler(MyBox_OnUpdate);
        }
示例#8
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new EventHandler <VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady      += new EventHandler <SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler <DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new EventHandler <HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler <IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate            += new EventHandler <UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
 public void AddListener(MessageListener listener)
 {
     broadcaster.AddListener(listener);
 }
 protected void AddListener(MessageListener listener)
 {
     internalBroadcaster.AddListener(listener);
 }
示例#11
0
 public void addMessageListener(IListener <Message> listener)
 {
     mBroadcaster.AddListener(listener);
 }
示例#12
0
 public void AddListener(IListener <C4FMSymbol> listener)
 {
     mBroadcaster.AddListener(listener);
 }
示例#13
0
 /// <summary>
 /// Setup builds an XN Context, Session Manager and all the detectors. 
 /// It also adds the callbacks for the SessionManager and adds the listeners on the Broadcaster. 
 /// </summary>
 private void Setup()
 {
     //build the context
     Context = new Context(CONFIG);
     //build session manager
     SeshManager = new SessionManager(Context,"RaiseHand","RaiseHand");
     SeshManager.SetQuickRefocusTimeout(15000);
     //build the FlowRouter
     Flowy  = new FlowRouter();
     //build the Broadcaster
     BCaster = new Broadcaster();
     //build the detectors
     Pushy = new PushDetector();
     Swipy = new SwipeDetector();
     //setup all the callbacks
     SetupCallbacks();
     Flowy.SetActive(BCaster);
     //add the flow router to the session
     SeshManager.AddListener(Flowy);
     SeshManager.SessionStart += SessionStarted;
     //add the listeners to BCaster
     BCaster.AddListener(Pushy);
     BCaster.AddListener(Swipy);
 }
示例#14
0
        public MyBox(System.Windows.Forms.Panel box, string name)
            : base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate += new UpdateHandler(MyBox_OnUpdate);
        }