Exemplo n.º 1
0
 /// <summary>
 /// Constructs a new EntityView
 /// </summary>
 /// <param name="model">The entity that view is meant to show</param>
 /// <param name="position">The position of the entity</param>
 /// <param name="tman">The ThreadSafeEventManager that is controlled the XmasView</param>
 public EntityView(XmasEntity model, XmasPosition position, ThreadSafeEventManager tman)
 {
     this.model = model;
     this.Position = position;
     eventqueue = model.ConstructEventQueue();
     tman.AddEventQueue(eventqueue);
 }
Exemplo n.º 2
0
 public LoggerView(XmasModel model, Logger log)
     : base(new ThreadSafeEventManager())
 {
     this.log = log;
     this.evtq = model.EventManager.ConstructEventQueue();
     this.ThreadSafeEventManager.AddEventQueue(evtq);
     this.evtq.Register(new Trigger<ActionFailedEvent>(engine_ActionFailed));
 }
Exemplo n.º 3
0
        public VacuumWorldView(XmasModel model,Logger log)
            : base(model,log)
        {
            //Construct an ThreadSafe Event queue which triggers can be registered to while keeping the code thread safe
            this.evtq = model.EventManager.ConstructEventQueue();
            this.ThreadSafeEventManager.AddEventQueue(evtq);

            //Register the triggers that track the vacuum cleaners actions
            this.evtq.Register(new Trigger<VacuumMovedEvent>(vacuum_Moved));
            this.evtq.Register(new Trigger<VacuumSuckedEvent>(vacuum_Sucked));
        }
Exemplo n.º 4
0
 public ConsoleView(XmasModel model, Point drawPos, ConsoleWorldView viewWorld, ConsoleViewFactory entityFactory, ThreadSafeEventManager evtmanager)
     : base(evtmanager)
 {
     this.viewWorld = viewWorld;
     this.entityFactory = entityFactory;
     this.drawPos = drawPos;
     eventqueue = model.EventManager.ConstructEventQueue();
     evtmanager.AddEventQueue(eventqueue);
     eventqueue.Register(new Trigger<EntityAddedEvent>(Model_EntityAdded));
     eventqueue.Register(new Trigger<EntityRemovedEvent>(model_EntityRemoved));
 }
Exemplo n.º 5
0
        public ConsoleLoggerView( XmasModel model
		                         , LoggerViewFactory entityFactory
		                         , ThreadSafeEventManager evtman
		                         , Logger log
		                         )
            : base(evtman)
        {
            this.entityFactory = entityFactory;
            this.log = log;

            evtqueue = model.EventManager.ConstructEventQueue();
            ThreadSafeEventManager.AddEventQueue(evtqueue);

            evtqueue.Register (new Trigger<EntityAddedEvent> (model_EntityAdded));
            evtqueue.Register (new Trigger<ActionFailedEvent> (engine_ActionFailed));
            evtqueue.Register(new Trigger<EisAgentDisconnectedEvent>(controller_AgentDisconnected));
            evtqueue.Register(new Trigger<EntityRemovedEvent>(model_EntityRemoved));
            evtqueue.Register(new Trigger<EisAgentTimingEvent>(entity_TimerElapsedEvent));
        }
 /// <summary>
 /// Adds an EventQueue to the manager, all events picked up by that queue can be fired through the manager
 /// </summary>
 /// <param name="queue"></param>
 public void AddEventQueue(ThreadSafeEventQueue queue)
 {
     queue.EventRecieved += queue_EventRecieved;
 }