/// <summary> /// Sets up a virtual hardware device. /// This debug implementation for a real hardware device should enable you to /// develop and debug your application without the need of a real hardware device. /// It emulates a BrailleDis 7200 device from the Metec AG /// </summary> /// <param name="title">The title of the device form.</param> /// <returns>The instantiated Monitor (can be used for further debug output)</returns> IBrailleIOShowOffMonitor loadShowOffAdapter(string title) { IBrailleIOShowOffMonitor monitor = null; if (io != null) { // create a debug adapter instance (form etc. ) monitor = new ShowOff(); ((ShowOff)monitor).SetTitle(title); // get the "faked" hardware implementation of this debug monitor var showOffAdapter = monitor.GetAdapter(io.AdapterManager); // set flag, that this adapter should "mirror" all outputs to the active adapter as well. showOffAdapter.Synch = true; if (io.AdapterManager != null) { // add this debug adapter to the current available AdapterManager to make it available to the BrailleIO users io.AdapterManager.AddAdapter(showOffAdapter); // set it as the main adapter for input and output if no other is available yet if (io.AdapterManager.ActiveAdapter == null) { io.AdapterManager.ActiveAdapter = showOffAdapter; } } } return(monitor); }
BrailleIO.Interface.IBrailleIOAdapter IBrailleIOAdapterSupplier.GetAdapter(BrailleIO.Interface.IBrailleIOAdapterManager manager) { if (manager != null && monitor != null) { adapter = monitor.GetAdapter(manager); return(adapter); } return(null); }
private void getShowOff() { if (IO != null) { // if the current Adapter manager holds an debug dapter, use it if (IO.AdapterManager is ShowOffBrailleIOAdapterManager) { Monitor = ((ShowOffBrailleIOAdapterManager)IO.AdapterManager).Monitor; foreach (var adapter in IO.AdapterManager.GetAdapters()) { if (adapter is BrailleIOAdapter_ShowOff) { showOffAdapter = adapter as AbstractBrailleIOAdapterBase; break; } } } // if no debug device currently exists, create a new one if (showOffAdapter == null) { Monitor = new ShowOff(); showOffAdapter = Monitor.GetAdapter(IO.AdapterManager); if (showOffAdapter != null) { IO.AdapterManager.AddAdapter(showOffAdapter); } } // if a debug adapter could been created, register to its events if (showOffAdapter != null) { showOffAdapter.Synch = true; // activate that this device receives the pin matrix of the active device, too. #region events showOffAdapter.touchValuesChanged += new EventHandler <BrailleIO_TouchValuesChanged_EventArgs>(_bda_touchValuesChanged); showOffAdapter.keyStateChanged += new EventHandler <BrailleIO_KeyStateChanged_EventArgs>(_bda_keyStateChanged); #endregion } if (Monitor != null) { Monitor.Disposed += new EventHandler(monitor_Disposed); } } }