예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("IdRelacion,IdPersonaFk,IdPersonaRelacionFk,IdTipoRelacionFk")] Relaciones relaciones)
        {
            if (id != relaciones.IdRelacion)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(relaciones);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RelacionesExists(relaciones.IdRelacion))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdPersonaFk"]         = new SelectList(_context.Personas, "IdPersona", "ApellidoPersonas", relaciones.IdPersonaFk);
            ViewData["IdPersonaRelacionFk"] = new SelectList(_context.Personas, "IdPersona", "ApellidoPersonas", relaciones.IdPersonaRelacionFk);
            ViewData["IdTipoRelacionFk"]    = new SelectList(_context.Tiposrelaciones, "IdTipoRelacion", "DescripcionTipoRelacion", relaciones.IdTipoRelacionFk);
            return(View(relaciones));
        }
예제 #2
0
 public void fillRelacion()
 {
     if (Relaciones == null)
     {
         Relaciones = new Dictionary <int, string>();
     }
     Relaciones.Clear();
     Relaciones.Add(1, "Padre");
     Relaciones.Add(2, "Madre");
     Relaciones.Add(3, "Apoderado");
 }
예제 #3
0
        public async Task <IActionResult> Create([Bind("IdRelacion,IdPersonaFk,IdPersonaRelacionFk,IdTipoRelacionFk")] Relaciones relaciones)
        {
            if (ModelState.IsValid)
            {
                _context.Add(relaciones);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdPersonaFk"]         = new SelectList(_context.Personas, "IdPersona", "ApellidoPersonas", relaciones.IdPersonaFk);
            ViewData["IdPersonaRelacionFk"] = new SelectList(_context.Personas, "IdPersona", "ApellidoPersonas", relaciones.IdPersonaRelacionFk);
            ViewData["IdTipoRelacionFk"]    = new SelectList(_context.Tiposrelaciones, "IdTipoRelacion", "DescripcionTipoRelacion", relaciones.IdTipoRelacionFk);
            return(View(relaciones));
        }
예제 #4
0
        public Form3(Grafo gra, int tip)
        {
            tipo  = tip;
            grafo = new Grafo();
            bool enco = false;

            InitializeComponent();
            g = CreateGraphics();
            Relaciones.Select();
            band   = false;
            accion = 0;
            // label2.Visible = Componentes.Visible = false;
            grafo         = gra;
            AutoScroll    = true;
            Vertices.Text = grafo.Count().ToString();
            Aristas.Text  = grafo.Aristas.Count().ToString();
            if (grafo.Aristas.Count > 0)
            {
                if (grafo.Aristas.ToArray()[0].Tipo == 2)
                {
                    Grado.Text = ((grafo.Aristas.Count()) * 2).ToString();
                }
                else
                {
                    Grado.Text = ((grafo.Aristas.Count())).ToString();
                }
            }


            List <List <NodoP> > componentes = new List <List <NodoP> >();
            List <NodoP>         nue         = new List <NodoP>();

            if (tipo == 2)
            {
                Text = "Grafo - Propiedades (No Dirigido)";
                foreach (NodoP nod in grafo)
                {
                    foreach (List <NodoP> n in componentes)
                    {
                        if (enco == false)
                        {
                            if (n.Find(delegate(NodoP f) { if (f.NOMBRE == nod.NOMBRE)
                                                           {
                                                               return(true);
                                                           }
                                                           else
                                                           {
                                                               return(false);
                                                           } }) != null)
                            {
                                enco = true;
                            }
                        }
                    }
                    if (enco == false)
                    {
                        nue = new List <NodoP>();
                        grafo.Componentes2(nod, nue);
                        componentes.Add(nue);
                    }
                    enco = false;
                }
                Componentes.Visible = true;
                //label2.Visible = true;
            }

            label6.Visible  = true;
            label7.Visible  = true;
            Interno.Visible = true;
            Externo.Visible = true;
            Interno.Items.Clear();
            Externo.Items.Clear();
            foreach (NodoP nodo in grafo)
            {
                Interno.Items.Add(nodo.NOMBRE.ToString());
                Externo.Items.Add(nodo.NOMBRE.ToString());
            }

            foreach (NodoP re in grafo)
            {
                foreach (NodoRel rela in re.relaciones)
                {
                    rela.VISITADA = false;
                }
            }
            Componentes.Text          = componentes.Count.ToString();
            dataGridView1.ColumnCount = grafo.Count + 1;
            dataGridView1.RowCount    = grafo.Count + 1;

            grafo.CreaMatriz();
            //MessageBox.Show(grafo.Aristas[1].PESO.ToString());
            for (int i = 0; i <= grafo.Count; i++)
            {
                for (int j = 0; j <= grafo.Count; j++)
                {
                    if (i == 0 && j > 0)
                    {
                        dataGridView1.Rows[i].Cells[j].Value = grafo[j - 1].NOMBRE.ToString();
                    }
                    else
                    if (j == 0 && i > 0)
                    {
                        dataGridView1.Rows[i].Cells[j].Value = grafo[i - 1].NOMBRE.ToString();
                    }
                    else
                    if (i != 0 && j != 0)
                    {
                        dataGridView1.Rows[i].Cells[j].Value = grafo.MATRIZ[i - 1][j - 1].ToString();
                    }
                }
            }
        }
예제 #5
0
        public GraphProperties(Graph grafo, int tip)
        {
            tipo = tip;

            bool enco = false;

            InitializeComponent();
            g = CreateGraphics();
            Relaciones.Select();
            band           = false;
            accion         = 0;
            label2.Visible = Componentes.Visible = false;
            AutoScroll     = true;
            Vertices.Text  = grafo.Count().ToString();
            Aristas.Text   = grafo.EdgesList.Count().ToString();
            if (grafo.EdgesList.Count > 0)
            {
                //if (grafo.EdgesList.ToArray()[0].Type == 2) {
                //    Grado.Text = ((grafo.EdgesList.Count()) * 2).ToString();
                //}
            }
            else
            {
                Grado.Text = ((grafo.EdgesList.Count())).ToString();
            }

            List <List <NodeP> > componentes = new List <List <NodeP> >();
            List <NodeP>         nue         = new List <NodeP>();

            if (tipo == 2)
            {
                Text = "Grafo - Propiedades (No Dirigido)";
                foreach (NodeP nod in grafo)
                {
                    foreach (List <NodeP> n in componentes)
                    {
                        if (enco == false)
                        {
                            if (n.Find(delegate(NodeP f) { if (f.Name == nod.Name)
                                                           {
                                                               return(true);
                                                           }
                                                           else
                                                           {
                                                               return(false);
                                                           } }) != null)
                            {
                                enco = true;
                            }
                        }
                    }
                    if (enco == false)
                    {
                        nue = new List <NodeP>();
                        //grafo.Componentes2(nod, nue);
                        componentes.Add(nue);
                    }
                    enco = false;
                }
                Componentes.Visible = true;
                label2.Visible      = true;
            }

            label6.Visible  = true;
            label7.Visible  = true;
            Interno.Visible = true;
            Externo.Visible = true;
            Interno.Items.Clear();
            Externo.Items.Clear();
            foreach (NodeP nodo in grafo)
            {
                Interno.Items.Add(nodo.Name.ToString());
                Externo.Items.Add(nodo.Name.ToString());
            }

            foreach (NodeP re in grafo)
            {
                foreach (NodeR rela in re.relations)
                {
                    rela.Visited = false;
                }
            }
            Componentes.Text          = componentes.Count.ToString();
            dataGridView1.ColumnCount = grafo.Count + 1;
            dataGridView1.RowCount    = grafo.Count + 1;

            //grafo.CreateMatrix();
            for (int i = 0; i <= grafo.Count; i++)
            {
                for (int j = 0; j <= grafo.Count; j++)
                {
                    if (i == 0 && j > 0)
                    {
                        dataGridView1.Rows[i].Cells[j].Value = grafo[j - 1].Name.ToString();
                    }
                    else
                    {
                        if (j == 0 && i > 0)
                        {
                            dataGridView1.Rows[i].Cells[j].Value = grafo[i - 1].Name.ToString();
                        }
                        else
                        {
                            if (i != 0 && j != 0)
                            {
                                //dataGridView1.Rows[i].Cells[j].Value = grafo.Matriz[i-1][j-1].ToString();
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
    void Start()
    {
        game       = new Relaciones(archivoConf);
        preguntas  = game.preguntas;
        respuestas = game.respuestas;
        bool[] sols = new bool[respuestas.Length];
        for (int a = 0; a < sols.Length; a++)
        {
            sols [a] = false;
        }
        preg = new GameObject[preguntas.Length];
        resp = new GameObject[respuestas.Length];
        //spawn object
        for (int i = 0; i < preguntas.Length; i++)
        {
            preg [i] = new GameObject("Pregunta" + i.ToString());
            preg [i].AddComponent <TextMesh> ();

            if (preguntas[i].Length > 30)
            {
                preguntas [i] = preguntas [i].Substring(0, 30) + "\n" + preguntas [i].Substring(30);
            }
            preg [i].GetComponent <TextMesh> ().text = preguntas [i];
            preg [i].AddComponent <BoxCollider2D>();
            preg [i].GetComponent <BoxCollider2D> ().isTrigger = true;
            preg [i].transform.position = new Vector3(-13, (-5 * i) + 9, 0);
            preg [i].AddComponent <Solucion> ();
            preg [i].GetComponent <Solucion> ().SetSolucion(i);
        }


        for (int i = 0; i < respuestas.Length; i++)
        {
            bool respondida = true;
            int  k          = 0;
            while (respondida)
            {
                k          = Random.Range(0, 4);
                respondida = sols [k];
            }
            sols [k] = true;
            resp [i] = new GameObject("Respuesta" + i.ToString());
            resp [i].AddComponent <TextMesh> ();
            resp [i].GetComponent <TextMesh> ().text = respuestas [k];
            resp [i].transform.position = new Vector3(11, (-5 * i) + 9, 0);
            resp [i].AddComponent <Rigidbody2D> ();
            resp [i].GetComponent <Rigidbody2D> ().gravityScale = 0;
            resp [i].AddComponent <BoxCollider2D> ();
            resp [i].GetComponent <BoxCollider2D> ().isTrigger = true;
            resp [i].AddComponent <Solucion> ();
            resp [i].GetComponent <Solucion> ().SetSolucion(k);
            resp [i].AddComponent <TodoPoderoso> ();
        }

        //Crea el panel de victoria
        victoria = new GameObject("PanelVictoria");
        victoria.AddComponent <TextMesh> ();
        victoria.GetComponent <TextMesh>().text      = "VICTORIA";
        victoria.GetComponent <TextMesh> ().fontSize = 80;
        victoria.transform.position = new Vector3(-19, 5, 0);
        victoria.SetActive(false);
    }
예제 #7
0
 void Start()
 {
     game       = new Relaciones("./Assets/PartidaGuardad.json");
     preguntas  = game.preguntas;
     respuestas = game.respuestas;
 }