private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { var thread = new Thread(() => AnimIcon(Luz)); thread.Start(); Luz.Text = "Comunication in progress"; try { if (yeelight.lightState == YeelightBulb.state.On) { yeelight.TurnOff(); Luz.Icon = new Icon("Icons/icon_off.ico"); Luz.Text = "Light off"; } else { yeelight.TurnOn(); Luz.Icon = new Icon("Icons/icon_on.ico"); Luz.Text = "Light on"; } } catch (Exception ex) { thread.Abort(); Luz.Icon = new Icon("Icons/sync_error.ico"); Luz.Text = "Error"; Luz.ShowBalloonTip(100, "Yeelight Not Found", ex.Message, ToolTipIcon.Error); } if (thread.IsAlive) { thread.Abort(); } }
public List <Luz> Detail(string city) { List <Luz> details = new List <Luz>(); con = new SqlConnection(conString); com = new SqlCommand(); com.Connection = con; com.CommandText = $"select * from Luz where City='{city}'"; SqlDataReader reader = null; com.Connection.Open(); reader = com.ExecuteReader(); while (reader.Read()) { Luz d = new Luz() { Num = reader["Num"].ToString(), City = reader["City"].ToString(), Date = (DateTime)reader["Date"], Text = reader["Text"].ToString(), }; details.Add(d); } return(details); }
/// <summary> /// Stop doing whatever you do. If hard is false, finish out your animation, /// but if hard is true, remove all signs of your existence from the scene. /// </summary> /// <param name="hard"></param> public override void Disable(bool hard) { if (luz != null) { luz = luz.Release(); } }
static void Main(string[] args) { ControleRemoto controle = new ControleRemoto(); Luz luzSala = new Luz(); PortaEletronica portaoGaragem = new PortaEletronica(); VentiladorTeto ventiladorSala = new VentiladorTeto(); controle.SetCommand(0, new CommandLightOn(luzSala), new CommandLightOff(luzSala)); controle.SetCommand(1, new CommandGarageLightOn(portaoGaragem), new CommandGarageLightOff(portaoGaragem)); controle.SetCommand(2, new CommandOpenDoorGarage(portaoGaragem), new CommandCloseDoorGarage(portaoGaragem)); controle.SetCommand(3, new CommandUpFan(ventiladorSala), new CommandDownFan(ventiladorSala)); controle.OnPressionado(0); controle.OnPressionado(1); controle.OnPressionado(2); controle.OffPressionado(0); controle.OffPressionado(1); controle.OffPressionado(2); controle.OnPressionado(3); controle.OnPressionado(3); controle.OnPressionado(3); controle.OffPressionado(3); controle.OnPressionado(6); controle.OffPressionado(6); Console.WriteLine(controle); Console.ReadKey(); }
public async Task <IActionResult> Edit(int id, [Bind("Intensidad,Id,Nombre,Estado")] Luz luz) { if (id != luz.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(luz); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LuzExists(luz.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(luz)); }
public void DeveDesligarALuz() { var luz = new Luz(); var command = new DesligaLuzCommand(luz); Assert.Equal("Desliga", command.Execute()); }
/// <summary> /// Get ready to go. If start is true, then actually begin animating, /// else go into paused but ready state. /// </summary> /// <param name="start"></param> public override void Enable(bool start) { if (luz == null) { luz = Luz.Acquire(Luz.LuzGroup.Obj); Debug.Assert(luz != null, "Do we have more lights than we can afford?"); UpdateLuz(); } }
public async Task <IActionResult> Create([Bind("Intensidad,Id,Nombre,Estado")] Luz luz) { if (ModelState.IsValid) { _context.Add(luz); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(luz)); }
public HttpResponseMessage Put([FromBody] Luz lampara) { try { admin.Modificar(lampara); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
void Start() { vida = GetComponent <Vida>(); AumentoVelocidad(1f); luz = GetComponentInChildren <Luz>(); jugador = GetComponent <Rigidbody2D>(); animador = GetComponent <Animator>(); puntero = PunteroRetardo.instance.GetComponent <Rigidbody2D>(); golpe = GetComponentInChildren <GolpeJugador>(); piernas = GetComponentInChildren <Piernas>(); golpe.Iniciar(); GameManager.instance.RestaurarJugador(); }
private Luz CrearLuz(string pathRecursos, TgcBox cancha, int signoX, int signoZ, float rotateY) { TgcMesh luzMesh = new TgcSceneLoader().loadSceneFromFile(pathRecursos + Settings.Default.meshFilePoste).Meshes[0]; //TODO cambiar por matrices luzMesh.AutoTransformEnable = true; luzMesh.rotateY(rotateY); luzMesh.Scale = new Vector3(3, 4, 3); luzMesh.Position = new Vector3(signoX * (cancha.Size.X / 2 + 50), cancha.Position.Y + luzMesh.BoundingBox.PMax.Y, signoZ * (cancha.Size.Z / 2 + 100)); Luz luz = new Luz(luzMesh, Color.White, luzMesh.BoundingBox.PMax); return(luz); }
private void Form1_Resize(object sender, EventArgs e) { if (FormWindowState.Minimized == this.WindowState) { Luz.Visible = true; Luz.ShowBalloonTip(100, "Yeelight tray control", $"ipAdress: {yeelight.ipAdress}", ToolTipIcon.Info); this.Hide(); } else if (FormWindowState.Normal == this.WindowState) { Luz.Visible = false; } }
/// <summary> /// Crea los 4 reflectores que posee el estadio /// </summary> /// <param name="pathRecursos"> ruta donde esta el mesh </param> /// <returns></returns> private List <Luz> CrearLuces(string pathRecursos, TgcBox cancha) { List <Luz> luces = new List <Luz>(); Luz luz1 = this.CrearLuz(pathRecursos, cancha, -1, 1, (float)Math.PI * 3 / 4); Luz luz2 = this.CrearLuz(pathRecursos, cancha, 1, 1, -(float)Math.PI * 3 / 4); Luz luz3 = this.CrearLuz(pathRecursos, cancha, -1, -1, (float)Math.PI / 4); Luz luz4 = this.CrearLuz(pathRecursos, cancha, 1, -1, -(float)Math.PI / 4); luces.Add(luz1); luces.Add(luz2); luces.Add(luz3); luces.Add(luz4); return(luces); }
public void Modificar(Luz lampara) { try { using (ServicioESP_DBEntities db = new ServicioESP_DBEntities()) { db.Entry(lampara).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } catch (Exception) { throw new Exception("Ha ocurrido un error al intentar modificar la información de la lampara"); } }
public void Agregar(Luz lampara) { try { using (ServicioESP_DBEntities db = new ServicioESP_DBEntities()) { db.Luz.Add(lampara); db.SaveChanges(); } } catch (Exception) { throw new Exception("Ha ocurrido un error al intentar agregar una nueva lampara."); } }
public void renderLight(float elapsedTime, List <Luz> luces, Vector3 cameraPosition) { //Configurar los valores de cada luz ColorValue[] lightColors = new ColorValue[luces.Count]; Vector4[] pointLightPositions = new Vector4[luces.Count]; float[] pointLightIntensity = new float[luces.Count]; float[] pointLightAttenuation = new float[luces.Count]; for (int i = 0; i < luces.Count; i++) { Luz lightMesh = luces[i]; lightColors[i] = ColorValue.FromColor(lightMesh.Color); pointLightPositions[i] = TgcParserUtils.vector3ToVector4(lightMesh.Posicion); //pointLightIntensity[i] = (float)GuiController.Instance.Modifiers["lightIntensity"]; //pointLightAttenuation[i] = (float)GuiController.Instance.Modifiers["lightAttenuation"]; pointLightIntensity[i] = 50; pointLightAttenuation[i] = 20; } //Cargar variables de shader this.lightEffect.SetValue("lightColor", lightColors); this.lightEffect.SetValue("lightPosition", pointLightPositions); this.lightEffect.SetValue("lightIntensity", pointLightIntensity); this.lightEffect.SetValue("lightAttenuation", pointLightAttenuation); this.lightEffect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(cameraPosition)); //Cargar variables de shader de Material. El Material en realidad deberia ser propio de cada mesh. Pero en este ejemplo se simplifica con uno comun para todos this.lightEffect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black)); this.lightEffect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White)); this.lightEffect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White)); this.lightEffect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White)); this.lightEffect.SetValue("materialSpecularExp", 20f); Effect originalEffect = this.sphere.Effect; string originalTechnique = this.sphere.Technique; this.sphere.Effect = this.lightEffect; //El Technique depende del tipo RenderType del mesh "VERTEX_COLOR"; "DIFFUSE_MAP"; this.sphere.Technique = "DIFFUSE_MAP"; this.render(); this.sphere.Effect = originalEffect; this.sphere.Technique = originalTechnique; }
public override string ToString() { return(base.ToString() + "\nExpertise: " + Expertise.ToString() + "\nMaxTestWeekly: " + MaxTestWeekly + "\nMaxDistance: " + MaxDistance + "\nLuz: " + Luz.ToString()); }
private void Awake() { instanciaCompartida = this; }
public static void Main() { const int OBJETOS = 10; int canObjetios = 9; Dispositivo[] d = new Dispositivo[OBJETOS]; d[0] = new Puerta(true, "Puerta de acceso"); d[1] = new PuertaGaraje(true, 0, "Puerta garaje"); d[2] = new Toldo(0, "Toldo"); d[3] = new Luz(true, "Bombilla"); d[4] = new Calefaccion(false, 20, "Cal1"); d[5] = new Calefaccion(false, 20, "Cal2"); d[6] = new Ventana(new Persiana(0, "Persiana 1"), "Ventana 1"); d[8] = new Ventana(new Persiana(0, "Persiana 2"), "Ventana 2"); d[7] = new Ventana(new Persiana(0, "Persiana 3"), "Ventana 3"); string opcion; do { System.Console.WriteLine("1. Bloquear puerta"); System.Console.WriteLine("2. Desbloquear puerta"); System.Console.WriteLine("3. Encender luz"); System.Console.WriteLine("4. Apagar luz"); System.Console.WriteLine("5. Subir puerta garaje"); System.Console.WriteLine("6. Bajar puerta garaje"); System.Console.WriteLine("7. Subir un 25 Persiana 1"); System.Console.WriteLine("8. Subir un 25 Persiana 2"); System.Console.WriteLine("9. Subir un 25 Persiana 3"); System.Console.WriteLine("10. Bajar un 25 Persiana 1"); System.Console.WriteLine("11. Bajar un 25 Persiana 2"); System.Console.WriteLine("12. Bajar un 25 Persiana 3"); System.Console.WriteLine("13. Recoger toldo"); System.Console.WriteLine("14. Extender toldo"); System.Console.WriteLine("15. Subir un grado calefaccion"); System.Console.WriteLine("16. Bajar un grado calefaccion"); System.Console.WriteLine("17. Ver estado dispositivos"); System.Console.WriteLine("0. Salir"); opcion = System.Console.ReadLine(); switch (opcion) { case "1": ((Puerta)(d[0])).Bloquear(); break; case "2": ((Puerta)(d[0])).Desbloquear(); break; case "3": ((Luz)d[3]).Encender(); break; case "4": ((Luz)d[3]).Apagar(); break; case "5": ((PuertaGaraje)(d[1])).Subir(); break; case "6": ((PuertaGaraje)(d[1])).Bajar(); break; case "7": ((Persiana)(d[6])).Subir(); break; case "8": ((Persiana)(d[7])).Subir(); break; case "9": ((Persiana)(d[8])).Subir(); break; case "10": ((Persiana)(d[6])).Bajar(); break; case "11": ((Persiana)(d[7])).Bajar(); break; case "12": ((Persiana)(d[8])).Bajar(); break; case "13": ((Toldo)d[3]).Subir(); break; case "14": ((Toldo)d[3]).Bajar(); break; case "15": ((Calefaccion)d[4]). SetTemperatura(((Calefaccion)d[4]). GetTemperatura() + 1); ((Calefaccion)d[5]). SetTemperatura(((Calefaccion)d[5]). GetTemperatura() + 1); break; case "16": ((Calefaccion)d[4]). SetTemperatura(((Calefaccion)d[4]). GetTemperatura() - 1); ((Calefaccion)d[5]). SetTemperatura(((Calefaccion)d[5]). GetTemperatura() - 1); break; case "17": for (int i = 0; i < canObjetios; i++) { System.Console.WriteLine(d[i]); } break; case "0": System.Console.WriteLine("Bye!"); break; default: System.Console.WriteLine("Wrong number!"); break; } } while (opcion != "0"); }
static void Main() { const int TAMANYO = 100; Dispositivo[] d = new Dispositivo[TAMANYO]; d[0] = new Ventana(new Persiana(10)); d[1] = new Ventana(new Persiana(25)); d[2] = new Ventana(new Persiana(45)); d[3] = new Puerta(true); d[4] = new PuertaDeGaraje(false, 10); d[5] = new Toldo(70); d[6] = new Luz(false); d[7] = new Calefaccion(25); d[8] = new Calefaccion(23); int contador = 9; int opcion; do { Console.WriteLine("Elige una opción:"); Console.WriteLine("1. Bloquear puerta de acceso"); Console.WriteLine("2. Desbloquear puerta de acceso"); Console.WriteLine("3. Encender punto de luz"); Console.WriteLine("4. Apagar punto de luz"); Console.WriteLine("5. Subir por completo puerta del garaje"); Console.WriteLine("6. Bajar por completo puerta del garaje"); Console.WriteLine("7. Subir 25% las 3 persianas"); Console.WriteLine("8. Recoger el toldo"); Console.WriteLine("9. Extender el toldo"); Console.WriteLine("10. Subir un grado cada calefacción"); Console.WriteLine("11. Bajar un grado cada calefacción"); Console.WriteLine("12. Ver estado de los dispositivos"); Console.WriteLine("0. Salir"); opcion = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); switch (opcion) { case 1: ((Puerta)(d[3])).Bloquear(); break; case 2: ((Puerta)(d[3])).Desbloquear(); break; case 3: ((Luz)(d[6])).Encender(); break; case 4: ((Luz)(d[6])).Apagar(); break; case 5: ((PuertaDeGaraje)(d[4])).Subir(); break; case 6: ((PuertaDeGaraje)(d[4])).Bajar(); break; case 7: ((Ventana)(d[0])).GetPersiana().Subir(25); ((Ventana)(d[1])).GetPersiana().Subir(25); ((Ventana)(d[2])).GetPersiana().Subir(25); break; case 8: ((Toldo)(d[5])).Subir(); break; case 9: ((Toldo)(d[5])).Bajar(); break; case 10: d[7] = new Calefaccion( ((Calefaccion)(d[7])).GetTemperatura() + 1); d[8] = new Calefaccion( ((Calefaccion)(d[8])).GetTemperatura() + 1); break; case 11: d[7] = new Calefaccion( ((Calefaccion)(d[7])).GetTemperatura() - 1); d[8] = new Calefaccion( ((Calefaccion)(d[8])).GetTemperatura() - 1); break; case 12: for (int i = 0; i < contador; i++) { Console.WriteLine(d[i]); } Console.WriteLine(); break; case 0: Console.WriteLine("Hasta otra"); break; default: Console.WriteLine("Opción incorrecta"); break; } } while (opcion != 0); }
public CommandLightOn(Luz luz) { this._luz = luz; luz._local = "Sala"; }