public Device() { com = ComFactory.MakeDefault(); com.setOnRead(onComRead); EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { onClose(); }); }
public ControllerKeyboard(Com com) : base(com) { kpPosDir = new PosDirProcessor(); kpRaw = new RawAnglesProcessor(); keysDown = new Collection <Key>(); keysToggle = new Collection <Key>(); EventBulletin.Subscribe(EventBulletin.Event.KEY_DOWN, (o, e) => { keyDown((KeyEventArgs)e); }); EventBulletin.Subscribe(EventBulletin.Event.KEY_UP, (o, e) => { keyUp((KeyEventArgs)e); }); }
private void init() { lastPacketKey = new PacketKey(0); // is time writeThread = new Thread(writeLoop); sendQ = new LinkedList <Packet>(); writeResetEvent = new AutoResetEvent(false); EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { Close(); }); Task.Delay(0).ContinueWith((t) => { connectProcedure(); running = true; beginRead(incommingRead); writeThread.Start(); }); }
private Program() { //com = ComFactory.MakeDefault(); com = ComFactory.MakeDummy(); com.setOnRead(tempOnRead); Task.Delay(0).ContinueWith((t) => { string cmd; while (true) { cmd = Console.ReadLine(); Console.WriteLine("echo: " + cmd); if (cmd.Equals("x")) { break; } if (cmd.Equals("r")) { com.Send(ComData.RequestClose()); continue; } com.Send(new ComData(cmd)); } Console.WriteLine("close"); EventBulletin.GetInstance().Notify(EventBulletin.Event.CLOSE, null, null); }); controllerDefault = ControllerFactory.MakeDefault(com); mainWindow = new MainWindow(controllerDefault); mainWindow.Show(); EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { tempOnClose(); }); app = new Application(); app.Run(mainWindow); }