public void toggleInfrared(InfraredController controller) { if (CheckifInfraredAreOn(controller)) { controller.infraredOff(); } else { controller.infraredOn(); } }
public bool CheckifInfraredAreOn(InfraredController infraredController) { if (infraredController.isOn() == true) { return(true); } else { return(false); } }
private void CreateButtons(System.Type type) { // position of starting button float x = 47.65f; float a = 30.64f; if (type == typeof(string)) { // Create buttons in the main menu panel with domotica List <string> tempDomotica = domoticaController.GetListDomotica(); for (int i = 0; i < tempDomotica.Count; i++) { int z = i; GameObject butn = Instantiate(buttonPrefab) as GameObject; butn.transform.SetParent(mainMenuPanel.transform, false); butn.transform.localPosition = new Vector3(0, (x - (a * z)), 0); butn.GetComponentInChildren <Text>().text = tempDomotica[i]; butn.GetComponent <Button>().onClick.AddListener(() => SwitchPanel(tempDomotica[z])); buttonListMainMenu.Add(butn); } } if (type == typeof(LightController)) { // Create buttons of all lightcontrollers with the check "show controller in mobile" lightControllers = new LightController[domoticaController.GetListLights().Length]; lightControllers = domoticaController.GetListLights(); int z = 0; for (int i = 0; i < lightControllers.Length; i++) { int p = i; if (lightControllers[i].ShowControllerInMobile == true) { GameObject butn = Instantiate(toggleButtonPrefab) as GameObject; butn.transform.SetParent(lightMenuPanel.transform, false); butn.transform.localPosition = new Vector3(0, (x - (a * z)), 0); butn.GetComponentInChildren <Text>().text = lightControllers[i].controllerName; if (butn != null) { on = butn.transform.Find("Toggle/ON"); off = butn.transform.Find("Toggle/OFF"); } on.GetComponent <Text>().text = "Aan"; off.GetComponent <Text>().text = "Uit"; ButtonOnOff = butn.transform.Find("Toggle/Button"); ButtonOnOff.GetComponent <Button>().onClick.AddListener(() => SwitchLights(lightControllers[p])); buttonDictLightsMenu.Add(butn, lightControllers[p]); z += 1; } } } if (type == typeof(CurtainController)) { // Create buttons of all curtaincontrollers with the check "show controller in mobile" CurtainController[] curtainControllers = new CurtainController[domoticaController.GetListCurtains().Length]; curtainControllers = domoticaController.GetListCurtains(); for (int i = 0; i < curtainControllers.Length; i++) { int z = i; GameObject butn = Instantiate(toggleButtonPrefab) as GameObject; butn.transform.SetParent(curtainMenuPanel.transform, false); butn.transform.localPosition = new Vector3(0, (x - (a * i)), 0); butn.GetComponentInChildren <Text>().text = curtainControllers[i].controllerName; if (butn != null) { on = butn.transform.Find("Toggle/ON"); off = butn.transform.Find("Toggle/OFF"); } on.GetComponent <Text>().text = "Open"; off.GetComponent <Text>().text = "Dicht"; ButtonOnOff = butn.transform.Find("Toggle/Button"); ButtonOnOff.GetComponent <Button>().onClick.AddListener(() => SwitchCurtains(curtainControllers[z])); buttonDictCurtainMenu.Add(butn, curtainControllers[z]); } } if (type == typeof(InfraredController)) { // Create buttons of all infraredcontrollers with the check "show controller in mobile" InfraredController[] infraredControllers = new InfraredController[domoticaController.GetListInfrared().Length]; infraredControllers = domoticaController.GetListInfrared(); for (int i = 0; i < infraredControllers.Length; i++) { int z = i; GameObject butn = Instantiate(toggleButtonPrefab) as GameObject; butn.transform.SetParent(infraredMenuPanel.transform, false); butn.transform.localPosition = new Vector3(0, (x - (a * i)), 0); butn.GetComponentInChildren <Text>().text = infraredControllers[i].controllerName; if (butn != null) { on = butn.transform.Find("Toggle/ON"); off = butn.transform.Find("Toggle/OFF"); } on.GetComponent <Text>().text = "Aan"; off.GetComponent <Text>().text = "Uit"; ButtonOnOff = butn.transform.Find("Toggle/Button"); ButtonOnOff.GetComponent <Button>().onClick.AddListener(() => SwitchInfrared(infraredControllers[z])); buttonDictInfraredMenu.Add(butn, infraredControllers[z]); } } }
private void SwitchInfrared(InfraredController infraredController) { domoticaController.toggleInfrared(infraredController); }