public void agregarJuegoJuegos(Juego agregarJuego) { List <String> manipularJuegos; foreach (String numeroJugadores in agregarJuego.numeroJugadores) { if (juegos.TryGetValue(Int32.Parse(numeroJugadores), out manipularJuegos)) { manipularJuegos.Add(agregarJuego.idBgg); juegos[Int32.Parse(numeroJugadores)] = manipularJuegos; } else { manipularJuegos = new List <String>(); manipularJuegos.Add(agregarJuego.idBgg); juegos.Add(Int32.Parse(numeroJugadores), manipularJuegos); } } }
private void agregarJuegoListViewAdversario(Juego juego, String tag, NodoRaiz nodoRaiz) { ListViewItem item = new ListViewItem(juego.nombre, imglIconos.Images.Count); imglIconos.Images.Add(juego.cargarImagenMiniatura(directorioCacheJuegos, juego.idBgg)); imglGrandes.Images.Add(juego.cargarImagenMiniatura(directorioCacheJuegos, juego.idBgg)); if (nodoRaiz == NodoRaiz.Nombre) { item.SubItems.Add(tag); item.Tag = juego.idBgg; } else { item.SubItems.Add("-1"); item.Tag = tag; } lvContenido.Items.Add(item); }
private void LvContenido_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e.Item.SubItems[1].Text.Equals("0")) { if (coleccion.autores.ContainsKey(e.Item.Text)) { mostrarJuegosAutorListView(coleccion.autores, e.Item.Text); } else if (e.Item.Text.Equals("# Jugadores")) { clickNumJugadores(); } else if (e.Item.Text.Equals("Mecanicas")) { clickMecanicas(); } else if (e.Item.Text.Equals("Familia")) { clickFamilia(); } else if (e.Item.Text.Equals("Categoria")) { clickCategoria(); } else if (e.Item.Text.Equals("Juego")) { clickJuego(); } else if (e.Item.Text.Equals("Nombre")) { clickNombre(); } else if (coleccion.mecanicas.ContainsKey(e.Item.Text)) { mostrarJuegosAutorListView(coleccion.mecanicas, e.Item.Text); } else if (coleccion.familia.ContainsKey(e.Item.Text)) { mostrarJuegosAutorListView(coleccion.familia, e.Item.Text); } else if (coleccion.categoria.ContainsKey(e.Item.Text)) { mostrarJuegosAutorListView(coleccion.categoria, e.Item.Text); } else if (jugadas.jugadorJuegoResultado.ContainsKey(e.Item.Text)) { SortedDictionary <String, int[]> juegoResultado; if (jugadas.jugadorJuegoResultado.TryGetValue(e.Item.Text, out juegoResultado)) { reiniciarComponentes(); foreach (var item in juegoResultado) { Juego juego = coleccion.idJuego[item.Key]; agregarJuegoListViewAdversario(juego, e.Item.Text, NodoRaiz.Nombre); } } } else if (coleccion.juegos.ContainsKey(Int32.Parse(e.Item.Text))) { mostrarJuegosJuegosListView(coleccion.juegos, Int32.Parse(e.Item.Text)); } } else if (e.Item.SubItems[1].Text.StartsWith("A1")) { //jugadas.juegoJugadorResultado; mostarDatosJuego(e.Item.SubItems[1].Text.Substring(2)); mostrarDatosAdversario(e.Item.SubItems[1].Text.Substring(2), e.Item.Text, jugadas.juegoJugadorResultado, NodoRaiz.Juego); } else if (jugadas.jugadorJuegoResultado.ContainsKey(e.Item.SubItems[1].Text)) { mostarDatosJuego(e.Item.Tag.ToString()); mostrarDatosAdversario(e.Item.SubItems[1].Text, e.Item.Tag.ToString(), jugadas.jugadorJuegoResultado, NodoRaiz.Nombre); } else if (e.Item.Tag != null) { if (!e.Item.SubItems[1].Text.Equals("-2")) { if (jugadas.juegoJugadorResultado.ContainsKey(e.Item.Tag.ToString())) { SortedDictionary <String, int[]> juegoResultado; if (jugadas.juegoJugadorResultado.TryGetValue(e.Item.Tag.ToString(), out juegoResultado)) { reiniciarComponentes(); foreach (var item in juegoResultado) { if (coleccion.idJuego.ContainsKey(item.Key)) { Juego juego = coleccion.idJuego[item.Key]; agregarJuegoListViewAdversario(juego, "A1" + juego.idBgg, NodoRaiz.Nombre); } else { agregarAdversarioListView(item.Key, e.Item.Tag.ToString(), 6); } } } } } else { //SortedDictionary<String, SortedDictionary<String, int[]>> jugadorJuegoResultado SortedDictionary <String, int[]> juegoResultado; if (jugadas.jugadorJuegoResultado.TryGetValue(e.Item.Tag.ToString(), out juegoResultado)) { reiniciarComponentes(); Juego juego = coleccion.idJuego[e.Item.Tag.ToString()]; agregarJuegoListViewAdversario(juego, e.Item.Tag.ToString(), NodoRaiz.Nombre); } } } else { mostarDatosJuego(e.Item.SubItems[1].Text); mostrarDatosJugadaJuego(e.Item.SubItems[1].Text); } }
private void TvArbol_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag.Equals("Juego")) { clickJuego(); } else if (e.Node.Tag.Equals("J")) { if (e.Node.GetNodeCount(true) > 1) { clickNumJugadores(); } mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("Ju")) { reiniciarComponentes(); agregarAutorListView("# Jugadores", 3); agregarAutorListView("Categoria", 4); agregarAutorListView("Familia", 5); agregarAutorListView("Mecanicas", 2); mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("AD")) { reiniciarComponentes(); agregarAutorListView("Juego", 1); agregarAutorListView("Nombre", 6); } else if (e.Node.Tag.Equals("Nombre")) { clickNombre(); } else if (e.Node.Tag.ToString().StartsWith("N")) { if (e.Node.Tag.ToString().StartsWith("NR")) { String idBgg = ""; //nr los que son personas nrj los que son juego String key; if (e.Node.Tag.ToString().StartsWith("NRJ")) { key = e.Node.Tag.ToString().Substring(3); idBgg = e.Node.Tag.ToString().Substring(3); } else { key = e.Node.Parent.Text; idBgg = e.Node.Tag.ToString().Substring(2); } mostarDatosJuego(idBgg); mostrarDatosAdversario(key, idBgg, jugadas.jugadorJuegoResultado, NodoRaiz.Nombre); } else { String key; if (e.Node.Tag.ToString().Length > 1) { key = e.Node.Tag.ToString().Substring(1); } else { key = e.Node.Text; } reiniciarComponentes(); SortedDictionary <String, int[]> juegoResultado; if (jugadas.jugadorJuegoResultado.TryGetValue(key, out juegoResultado)) { reiniciarComponentes(); foreach (var item in juegoResultado) { Juego juego = coleccion.idJuego[item.Key]; agregarJuegoListViewAdversario(juego, key, NodoRaiz.Nombre); } } } } else if (e.Node.Tag.ToString().StartsWith("J")) { if (e.Node.Tag.ToString().StartsWith("JR")) { String idBgg = ""; //jr los que son personas jr14564 los que son juego String key; if (e.Node.Tag.ToString().StartsWith("JRJ")) { key = e.Node.Tag.ToString().Substring(3); idBgg = e.Node.Tag.ToString().Substring(3); } else { key = e.Node.Text; idBgg = e.Node.Tag.ToString().Substring(2); } mostarDatosJuego(idBgg); mostrarDatosAdversario(idBgg, key, jugadas.juegoJugadorResultado, NodoRaiz.Nombre); } else { String key = ""; if (e.Node.Tag.ToString().Length > 1) { key = e.Node.Tag.ToString().Substring(1); } if (jugadas.juegoJugadorResultado.ContainsKey(key)) { SortedDictionary <String, int[]> juegoResultado; if (jugadas.juegoJugadorResultado.TryGetValue(key, out juegoResultado)) { reiniciarComponentes(); foreach (var item in juegoResultado) { if (coleccion.idJuego.ContainsKey(item.Key)) { Juego juego = coleccion.idJuego[item.Key]; agregarJuegoListViewAdversario(juego, "A1" + juego.idBgg, NodoRaiz.Nombre); } else { agregarAdversarioListView(item.Key, key, 6); } } } } } } else if (e.Node.Tag.Equals("A")) { if (e.Node.GetNodeCount(true) > 1) { reiniciarComponentes(); foreach (var item in coleccion.autores) { agregarAutorListView(item.Key, 0); } } mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("M")) { clickMecanicas(); mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("F")) { clickFamilia(); mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("C")) { clickCategoria(); mostrarCantidadElementos(e); } else if (e.Node.Tag.Equals("Resumen")) { if (coleccion != null) { if (coleccion.idJuego.ContainsKey(jugadas.idJuegoMasJugado.ToString())) { Juego juego = coleccion.idJuego[jugadas.idJuegoMasJugado.ToString()]; MessageBox.Show("Tienes mas juegos de " + coleccion.masJuegosAutor + "\nEl juego que mas juegas " + juego.nombre + "\nLe has ganado mas veces a " + jugadas.MayorPerdedor + "\nTe ha ganado mas veces " + jugadas.MayorGanador); } } else { MessageBox.Show("Tienes que consultar un jugador"); } } else { mostrarListViewTag(e.Node.Tag.ToString(), e.Node.Text); mostrarCantidadElementos(e); } int valorTag; try { valorTag = Int32.Parse(e.Node.Tag.ToString()); } catch (Exception excep) { valorTag = -1; } if (valorTag > 0) { mostrarListViewTag(e.Node.Parent.Tag.ToString(), e.Node.Parent.Text); mostarDatosJuego(e.Node.Tag.ToString()); mostrarDatosJugadaJuego(e.Node.Tag.ToString()); mostrarCantidadElementos(e); } }
public void agregarNodosArbol(SortedDictionary <String, List <String> > colecciones, NodoRaiz nodoRaiz) { TreeNode nodoAgregar = new TreeNode(); if (nodoRaiz == NodoRaiz.Autor) { nodoAgregar = tvArbol.GetNodeAt(0, 0); } else if (nodoRaiz == NodoRaiz.Mecanicas) { nodoAgregar = tvArbol.GetNodeAt(0, 0).NextVisibleNode.FirstNode.NextNode.NextNode.NextNode; } else if (nodoRaiz == NodoRaiz.Familia) { nodoAgregar = tvArbol.GetNodeAt(0, 0).NextVisibleNode.FirstNode.NextNode.NextNode; } else if (nodoRaiz == NodoRaiz.Categoria) { nodoAgregar = tvArbol.GetNodeAt(0, 0).NextVisibleNode.FirstNode.NextNode; } foreach (var item in colecciones) { TreeNode agregarNodo = new TreeNode(item.Key); if (nodoRaiz == NodoRaiz.Autor) { agregarNodo.Tag = "0"; agregarNodo.ImageIndex = 0; agregarNodo.SelectedImageIndex = 0; } else if (nodoRaiz == NodoRaiz.Mecanicas) { agregarNodo.Tag = "000"; agregarNodo.ImageIndex = 2; agregarNodo.SelectedImageIndex = 2; } else if (nodoRaiz == NodoRaiz.Familia) { agregarNodo.Tag = "0000"; agregarNodo.ImageIndex = 5; agregarNodo.SelectedImageIndex = 5; } else if (nodoRaiz == NodoRaiz.Categoria) { agregarNodo.Tag = "00000"; agregarNodo.ImageIndex = 4; agregarNodo.SelectedImageIndex = 4; } foreach (var iJjuego in item.Value) { Juego juego = coleccion.idJuego[iJjuego]; TreeNode nodoJuego = new TreeNode(juego.nombre, 0, 0); nodoJuego.Tag = juego.idBgg; if (indiceImagenArbol.ContainsKey(juego.idBgg)) { nodoJuego.ImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); nodoJuego.SelectedImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); } else { nodoJuego.ImageIndex = imglArbol.Images.Count; nodoJuego.SelectedImageIndex = imglArbol.Images.Count; indiceImagenArbol.Add(juego.idBgg, imglArbol.Images.Count.ToString()); imglArbol.Images.Add(juego.cargarImagenMiniatura(directorioCacheJuegos, juego.idBgg)); } agregarNodo.Nodes.Add(nodoJuego); } nodoAgregar.Nodes.Add(agregarNodo); } }
public void agregarNodosArbolAdversarios(SortedDictionary <String, SortedDictionary <String, int[]> > colecciones, NodoRaiz nodoRaiz) { TreeNode nodoAgregar = new TreeNode(); if (nodoRaiz == NodoRaiz.Juego) { nodoAgregar = tvArbol.GetNodeAt(0, 0).NextVisibleNode.NextVisibleNode.FirstNode; } else if (nodoRaiz == NodoRaiz.Nombre) { nodoAgregar = tvArbol.GetNodeAt(0, 0).NextVisibleNode.NextVisibleNode.FirstNode.NextNode; } ///SortedDictionary<String, SortedDictionary<String, int[]>> foreach (var item in colecciones) { TreeNode agregarNodo = new TreeNode(item.Key); if (nodoRaiz == NodoRaiz.Juego) { Juego juego = coleccion.idJuego[item.Key]; agregarNodo = new TreeNode(juego.nombre); agregarNodo.Tag = "J" + juego.idBgg; agregarNodo.ImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); agregarNodo.SelectedImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); } else if (nodoRaiz == NodoRaiz.Nombre) { Juego juego; if (coleccion.idJuego.TryGetValue(item.Key, out juego)) { agregarNodo = new TreeNode(juego.nombre); agregarNodo.Tag = "N" + juego.idBgg; agregarNodo.ImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); agregarNodo.SelectedImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); } else { agregarNodo.Tag = "N"; agregarNodo.ImageIndex = 6; agregarNodo.SelectedImageIndex = 6; //agregarNodo.Tag = "0000000"; } } foreach (var jugadorResultado in item.Value) { TreeNode nodoJugador = new TreeNode(jugadorResultado.Key, 0, 0); if (nodoRaiz == NodoRaiz.Nombre) { Juego juego = coleccion.idJuego[jugadorResultado.Key]; nodoJugador = new TreeNode(juego.nombre); if (agregarNodo.Tag.ToString().Length == 1) { nodoJugador.Tag = "NR" + juego.idBgg; } else { nodoJugador.Tag = "NRJ" + juego.idBgg; } nodoJugador.ImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); nodoJugador.SelectedImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); } else { Juego juego; if (coleccion.idJuego.TryGetValue(jugadorResultado.Key, out juego)) { nodoJugador = new TreeNode(juego.nombre); nodoJugador.Tag = "JRJ" + juego.idBgg; nodoJugador.ImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); nodoJugador.SelectedImageIndex = Int32.Parse(indiceImagenArbol[juego.idBgg]); } else { nodoJugador.Tag = "JR" + item.Key; nodoJugador.ImageIndex = 6; nodoJugador.SelectedImageIndex = 6; } } agregarNodo.Nodes.Add(nodoJugador); } nodoAgregar.Nodes.Add(agregarNodo); } }