public Object parse(string str, Accion action) { LanguageData lenguaje = new LanguageData(gramatica); Parser p = new Parser(lenguaje); ParseTree s_tree = p.Parse(str); if (s_tree.Root != null) { ActionMaker act = new ActionMaker(s_tree.Root); act.escribir_arbol(); return act.getEval(action); } return null; }
public Object parse(string str, Accion action) { LanguageData lenguaje = new LanguageData(gramatica); Parser p = new Parser(lenguaje); ParseTree s_tree = p.Parse(str); if (s_tree.Root != null) { ActionMaker act = new ActionMaker(s_tree.Root); return act.getEval(action); } else { MessageBox.Show("fail, go home!"); } return null; }
public void setAccAct(Accion aa) { MostrarOcultar(panel); AccionActual = aa; if (!esRegla) panelEscribir.GetComponentInChildren<Text>().text = UIController.Lista.PropiedadesToString(AccionActual); else if (esRegla) { if (esAntecedente) { reglasManager.GetComponent<Reglas>().agregarAntec(aa); } else { reglasManager.GetComponent<Reglas>().agregarConsec(aa); } } }
private void btnModificacion_Click(object sender, EventArgs e) { try { HabilitarControles(false); if (this.gridServicios.CurrentRow != null) { this.Operacion = Accion.Modificacion; this.gbDatosServicio.Enabled = true; Servicio servicio = (Servicio)this.gridServicios.CurrentRow.DataBoundItem; servicioSeleccionado = servicio; this.txtDescripcion.Text = servicio.Descripcion; this.txtPrecio.Text = servicio.Precio.ToString("N2"); } } catch (Exception ex) { ErrorManager.ObtenerInstancia().LoguearErrorBD(ex); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAlta_Click(object sender, EventArgs e) { this.Operacion = Accion.Alta; this.gbDatosServicio.Enabled = true; HabilitarControles(false); }
private void btnModificacion_Click(object sender, EventArgs e) { try { HabilitarControles(false); if (this.gridEventos.CurrentRow != null) { this.Operacion = Accion.Modificacion; this.gbDatosEvento.Enabled = true; Evento evento = (Evento)this.gridEventos.CurrentRow.DataBoundItem; eventoSeleccionado = evento; this.txtDescripcion.Text = evento.Descripcion; this.txtPrecio.Text = evento.Precio.ToString("N2"); this.txtPrecioBloque.Text = evento.PrecioBloqueExtra.ToString("N2"); this.txtPrecioDecena.Text = evento.PrecioDecenaExtra.ToString("N2"); this.numCantidadAdultos.Value = evento.CantidadAdultos; this.numCantidadNiños.Value = evento.CantidadNiños; } } catch (Exception ex) { ErrorManager.ObtenerInstancia().LoguearErrorBD(ex); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnBaja_Click(object sender, EventArgs e) { try { if (this.gridEventos.CurrentRow != null) { this.Operacion = Accion.Modificacion; Evento evento = (Evento)this.gridEventos.CurrentRow.DataBoundItem; DialogResult dialogo = MessageBox.Show("¿Desea eliminar definitivamente al evento " + evento.Descripcion + "?", "Baja de Evento", MessageBoxButtons.YesNo); if (dialogo == DialogResult.Yes) { if (GestorReserva.ObtenerInstancia().EliminarEvento(evento)) { if (GestorBD.ObtenerInstancia().ActualizarDVV("EVENTO")) { MessageBox.Show("El evento se ha eliminado correctamente.", "Baja de Evento", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarEventos(); } } } } } catch (Exception ex) { string mensajeError = ErrorManager.ObtenerInstancia().LoguearGenerarMensajeError(ex, MensajeError.BajaEventoFallida, FormHelper.ObtenerInstancia().TraerUltimoIdioma()); MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnModificacion_Click(object sender, EventArgs e) { try { HabilitarControles(false); if (this.gridEmpleados.CurrentRow != null) { this.Operacion = Accion.Modificacion; this.gbDatosEmpleado.Enabled = true; this.txtDU.Enabled = false; Empleado empleado = (Empleado)this.gridEmpleados.CurrentRow.DataBoundItem; this.txtDU.Text = empleado.DU.ToString(); this.txtApellido.Text = empleado.Apellido; this.txtNombre.Text = empleado.Nombre; this.txtTelefono.Text = empleado.Telefono; this.cboCargo.SelectedValue = empleado.Cargo.Descripcion; this.chkActivo.Checked = empleado.Activo; if (empleado.Direccion != null) { this.txtCalle.Text = empleado.Direccion.Calle; this.txtAltura.Text = empleado.Direccion.Altura.ToString(); this.txtLocalidad.Text = empleado.Direccion.Localidad; this.txtPiso.Text = empleado.Direccion.Piso == 0 ? "" : empleado.Direccion.Piso.ToString(); this.txtDepto.Text = empleado.Direccion.Departamento == "N/A" ? "" : empleado.Direccion.Departamento; } } } catch (Exception ex) { ErrorManager.ObtenerInstancia().LoguearErrorBD(ex); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGuardar_Click(object sender, EventArgs e) { using (Server.RequestStart(Database)) { MongoCollection Contactos = Database.GetCollection<Contact>("contacts"); if (AccionFormulario == Accion.Guardar) Contactos.Insert(new Contact() { Apellidos = txtApellidos.Text, Nombres = txtNombres.Text, Telefono = txtTelefono.Text, CorreoElectronico = txtCorreoElectronico.Text }); else { Contact item = Contactos.FindOneByIdAs<Contact>(IdContacto); item.Apellidos = txtApellidos.Text; item.Nombres = txtNombres.Text; item.Telefono = txtTelefono.Text; item.CorreoElectronico = txtCorreoElectronico.Text; Contactos.Save(item, SafeMode.True); AccionFormulario = Accion.Guardar; } } LlenarGrilla(); LimpiarControles(); }
public Object getEval(Accion action) { //evaluar el árbol return action.do_action(root); }
private void btnModificacion_Click(object sender, EventArgs e) { try { if (gridUsuarios.SelectedRows.Count != 0) { this.Operacion = FABMUsuario.Accion.Modificacion; this.gbDatosUsuario.Enabled = true; HabilitarControles(false); this.txtUsuario.Enabled = false; DataGridViewRow row = this.gridUsuarios.SelectedRows[0]; this.txtUsuario.Text = row.Cells["Nombre"].Value.ToString(); this.cboIdioma.SelectedValue = row.Cells["Idioma"].Value.ToString(); this.cboPerfil.SelectedValue = row.Cells["Perfil"].Value.ToString(); } } catch (Exception ex) { ErrorManager.ObtenerInstancia().LoguearErrorBD(ex); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void leerXML(string xml) { XmlDocument xmlDoc = new XmlDocument(); // xmlDoc is the new xml document. xmlDoc.LoadXml(BaseDeDatosXML.text); // load the file. string nombre = ""; string ID = ""; Dictionary<string, string> propiedades; XmlNodeList personajes = xmlDoc.GetElementsByTagName("Personaje"); // Personajes foreach (XmlNode personaje in personajes) { Personaje aux; nombre = ""; ID = ""; propiedades = new Dictionary<string, string>(); XmlNodeList elementos = personaje.ChildNodes; foreach (XmlNode elemento in elementos) { if (elemento.Name == "Nombre") { nombre = elemento.InnerText.ToLower(); } if (elemento.Name == "ID") { ID = elemento.InnerText; } if (elemento.Name == "Propiedades") { foreach (XmlNode propiedad in elemento) { propiedades[propiedad.Name] = propiedad.InnerText.ToLower(); } } } aux = new Personaje(nombre, int.Parse(ID), propiedades); Controller.Personajes.Add(aux); } // /Personajes XmlNodeList npcs = xmlDoc.GetElementsByTagName("NPC"); // NPCs foreach (XmlNode npc in npcs) { NPC aux; nombre = ""; ID = ""; propiedades = new Dictionary<string, string>(); XmlNodeList elementos = npc.ChildNodes; foreach (XmlNode elemento in elementos) { if (elemento.Name == "Nombre") { nombre = elemento.InnerText.ToLower(); } if (elemento.Name == "ID") { ID = elemento.InnerText; } if (elemento.Name == "Propiedades") { foreach (XmlNode propiedad in elemento) { propiedades[propiedad.Name] = propiedad.InnerText.ToLower(); } } } aux = new NPC(nombre, int.Parse(ID), propiedades); Controller.NPCs.Add(aux); } // /NPCs XmlNodeList objetos = xmlDoc.GetElementsByTagName("Objeto"); // Objetos foreach (XmlNode objeto in objetos) { Objeto aux; nombre = ""; ID = ""; propiedades = new Dictionary<string, string>(); XmlNodeList elementos = objeto.ChildNodes; foreach (XmlNode elemento in elementos) { if (elemento.Name == "Nombre") { nombre = elemento.InnerText.ToLower(); } if (elemento.Name == "ID") { ID = elemento.InnerText; } if (elemento.Name == "Propiedades") { foreach (XmlNode propiedad in elemento) { if (propiedad.Name != "texto") propiedades[propiedad.Name] = propiedad.InnerText.ToLower(); else propiedades[propiedad.Name] = propiedad.InnerText; } } } aux = new Objeto(nombre, int.Parse(ID), propiedades); Controller.Objetos.Add(aux); } // /Objetos XmlNodeList acciones = xmlDoc.GetElementsByTagName("Accion"); // Acciones foreach (XmlNode accion in acciones) { Accion aux; nombre = ""; ID = ""; propiedades = new Dictionary<string, string>(); XmlNodeList elementos = accion.ChildNodes; foreach (XmlNode elemento in elementos) { if (elemento.Name == "Nombre") { nombre = elemento.InnerText.ToLower(); } if (elemento.Name == "ID") { ID = elemento.InnerText; } if (elemento.Name == "Propiedades") { foreach (XmlNode propiedad in elemento) { propiedades[propiedad.Name] = propiedad.InnerText.ToLower(); } } } aux = new Accion(nombre, int.Parse(ID), propiedades); Controller.Acciones.Add(aux); } // /Acciones List<List<Elemento>> antecedentes; List<Elemento> antecedente; List<Elemento> consecuente; string IDElem = ""; string tipo = ""; XmlNodeList reglas = xmlDoc.GetElementsByTagName("Regla"); // Reglas foreach (XmlNode regla in reglas) { Regla aux; antecedentes = new List<List<Elemento>>(); consecuente = new List<Elemento>(); XmlNodeList elementos = regla.ChildNodes; foreach (XmlNode elemento in elementos) { if (elemento.Name == "Antecedentes") { foreach (XmlNode antec in elemento) { antecedente = new List<Elemento>(); foreach (XmlNode elem in antec) { foreach (XmlNode propElem in elem) { if (propElem.Name == "ID") { IDElem = propElem.InnerText; } if (propElem.Name == "Tipo") { tipo = propElem.InnerText; } } antecedente.Add(buscarElemento(int.Parse(IDElem), tipo)); } antecedentes.Add(antecedente); } } if (elemento.Name == "Consecuente") { foreach (XmlNode elem in elemento) { foreach (XmlNode propElem in elem) { if (propElem.Name == "ID") { IDElem = propElem.InnerText; } if (propElem.Name == "Tipo") { tipo = propElem.InnerText; } } consecuente.Add(buscarElemento(int.Parse(IDElem), tipo)); } } } aux = new Regla(antecedentes, consecuente); Controller.Reglas.Add(aux); } // /Reglas }
private void btnNuevo_Click(object sender, EventArgs e) { LimpiarControles(); AccionFormulario = Accion.Guardar; }
void Start() { user = (ClaseJugador)Entrenador.CreateTrainer("ClaseJugador","PEPE"); opoN = PlayerPrefs.GetString("Entrenador"); oponent = (Entrenador)Entrenador.CreateTrainer(opoN,opoN); PlayerPrefs.DeleteKey("Entrenador"); battleStageOp = battleStage = (int)Stage.elegir; userMon = user.equipo[user.activo]; opoMon = oponent.equipo[oponent.activo]; act1 = user.accionEntrenador(); act2 = Accion.CreateAccion("Elegir"); GameObject.Find("OponentIm").GetComponent<Image>().sprite = Resources.Load(opoMon.imgDir, typeof(Sprite)) as Sprite; GameObject.Find("UserIm").GetComponent<Image>().sprite = Resources.Load(userMon.imgDir, typeof(Sprite)) as Sprite; actionPanel.SetActive(true); if(oponent.catchRate <= 0){ GameObject.Find("ItemBtn").SetActive(false); } }
private void btnBaja_Click(object sender, EventArgs e) { try { if (this.gridEmpleados.CurrentRow != null) { this.Operacion = Accion.Modificacion; Empleado empleado = (Empleado)this.gridEmpleados.CurrentRow.DataBoundItem; DialogResult dialogo = MessageBox.Show("¿Desea eliminar definitivamente al Empleado " + empleado.ToString() + "?", "Gestión de Empleados", MessageBoxButtons.YesNo); if (dialogo == DialogResult.Yes) { if (GestorReserva.ObtenerInstancia().EliminarEmpleado(empleado)) { MessageBox.Show("El empleado se ha eliminado correctamente", "Gestión de Empleados", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarEmpleados(); } } } } catch (Exception ex) { string mensajeError = ErrorManager.ObtenerInstancia().LoguearGenerarMensajeError(ex, MensajeError.BajaEmpleadoFallida, FormHelper.ObtenerInstancia().TraerUltimoIdioma()); MessageBox.Show(mensajeError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void Update() { if(userMon.estado.statActual.vida == 0){ SaveMonster.AddMonster(userMon,false); act1.stg = act2.stg = Stage.elegir; user.clicks = accionesEntrenador.nula; user.menuActivo = menus.capa1; if( user.Change() < 0){ battleStage = (int) Stage.derrota; } } if(opoMon.estado.statActual.vida == 0){ userMon.AddExp(opoMon.exp*(opoMon.lv/userMon.lv)); act1.stg = act2.stg = Stage.elegir; if( oponent.Change() < 0){ battleStage = (int) Stage.victoria; } } if((battleStage == (int)Stage.resultado) || (battleStage == (int)Stage.derrota) || (battleStage == (int)Stage.victoria)){ Salir(battleStage); } InitPanels(); if(act1.stg == Stage.elegir){ battleStage = (int)Stage.elegir; act1 = user.accionEntrenador(); } if(userMon.estado.statActual.vida == 0){ if( user.Change() < 0){ battleStage = (int) Stage.resultado; } } if(act2.stg == Stage.elegir){ battleStageOp = (int)Stage.elegir; act2 = oponent.accionEntrenador(); } if(opoMon.estado.statActual.vida == 0){ } if(act1.stg != Stage.elegir){ if(battleStage == (int)act1.stg){ act1.ac(); act1.stg = Stage.elegir; }else{ if(!waiting){ waiting = true; StartCoroutine(Wait(0)); } } } if(act2.stg != Stage.elegir){ if(battleStageOp == (int)act2.stg){ act2.ac(); act2.stg = Stage.elegir; }else{ if(!waiting){ waiting = true; StartCoroutine(Wait(1)); } } } }
private void tsmiActualizar_Click(object sender, EventArgs e) { BsonObjectId Id = (BsonObjectId)dgvEmpleados.CurrentRow.Cells["Id"].Value; using (Server.RequestStart(Database)) { MongoCollection Contactos = Database.GetCollection<Contact>("contacts"); Contact item = Contactos.FindOneByIdAs<Contact>(Id); IdContacto = item.Id; txtApellidos.Text = item.Apellidos; txtNombres.Text = item.Nombres; txtTelefono.Text = item.Telefono; txtCorreoElectronico.Text = item.CorreoElectronico; AccionFormulario = Accion.Actualizar; } }