/// <summary> /// Determines whether a display strategy is available /// </summary> /// <param name="displayStrategy">the display strategy object</param> /// <returns><c>true</c> if the strategy available, otherwise <c>false</c></returns> public bool isDisplayStrategyAvailable(AOutputManager displayStrategy) { if (displayStrategy.GetType().Namespace != null && displayStrategy.GetType().Namespace.Equals("StrategyMVBD")) { return(displayStrategy.isDisplayStrategyAvailable()); } else { return(true); } }
/// <summary> /// Returns ALL possible devices (for all implemented Adapters) /// </summary> /// <returns>a list of ALL possible devices</returns> public List <Device> getAllPosibleDevices() { // the list of devices are only requested if no list exist if (allDevices == null || allDevices.Equals(new List <Device>())) { allDevices = new List <Device>(); Settings settings = new Settings(); // gets all implementations of this abstract class List <Strategy> allDisplayStrategys = settings.getPosibleDisplayStrategies(); foreach (Strategy st in allDisplayStrategys) { try { Type type = Type.GetType(st.className); if (type == null) { break; } if (this.GetType().Equals(type)) { List <Device> devices = this.getPosibleDevices(); if (devices != null) { allDevices.AddRange(devices); } } else { using (AOutputManager ads = (AOutputManager)Activator.CreateInstance(type, strategyMgr)) { List <Device> devices = ads.getPosibleDevices(); if (devices != null) { allDevices.AddRange(devices); } } } } catch (InvalidCastException ic) { throw new InvalidCastException("Exception in GRANTManager.AbstractClasses.getAllPosibleDevices(): " + ic.Message); } catch (ArgumentNullException e) { throw new ArgumentNullException("Exception in GRANTManager.AbstractClasses.getAllPosibleDevices(): " + e.Message); } } } return(allDevices); }
public void setSpecifiedDisplayStrategy(String displayStrategyClassName) { try { Type type = Type.GetType(displayStrategyClassName); if (specifiedDisplayStrategy != null) { specifiedDisplayStrategy.Dispose(); //sorgt dafür, dass ggf. die alte TCP-Verbindung beendet wird // specifiedDisplayStrategy = null; } //falls MVBD als DisplayStrstegy gesetzt werden soll, muss geprüft werden, ob MVBD aktiv ist AOutputManager om = (AOutputManager)Activator.CreateInstance(type, this); if (getSpecifiedDisplayStrategy() == null || getSpecifiedDisplayStrategy().isDisplayStrategyAvailable(om)) { if (this.getSpecifiedBrailleDisplay() != null) { this.getSpecifiedBrailleDisplay().removeAllViews(); } specifiedDisplayStrategy = om; } else { Console.WriteLine("Die DisplayStrategy ist nicht verfügbar."); System.Windows.Forms.MessageBox.Show("The chosen display strategy is not available!", "GRANT exception"); om.Dispose(); } } catch (InvalidCastException ic) { throw new InvalidCastException("Fehler bei StrategyManager_setSpecifieddisplayStrategy: " + ic.Message); } catch (ArgumentException ae) { throw new ArgumentException("Fehler bei StrategyManager_setSpecifieddisplayStrategy: " + ae.Message); } catch (Exception e) { throw new Exception("Fehler bei StrategyManager_setSpecifieddisplayStrategy: " + e.Message); } }