/** * Añade una carpeta al menu */ private void addCarpeta() { try { Carpeta p1 = new Carpeta(this, Lista.getWrapVisible(), menuCarpetas, null); AddCarpeta newSerie = new AddCarpeta(p1, _activatedButton); newSerie.ShowDialog(); if (newSerie.createdSerie()) { Lista.addCarpeta(p1); WrapPanelPrincipal aux = Lista.getWrapVisible(); p1.actualizar(); string name = _activatedButton.Content.ToString(); p1.getClass().rutaPadre = _profile.nombre + "|C/" + name; p1.setRutaPrograma(_profile.nombre + "|C/" + name + "/" + p1.getClass().nombre); Conexion.saveFolder(p1); aux.addCarpeta(p1); p1.SetGridsOpciones(GridPrincipal, GridSecundario); Lista.orderWrap(aux); } else { p1 = null; } } catch (MySqlException exc) { MessageBox.Show("No se ha podido conectar a la base de datos"); } catch (SQLiteException exc2) { MessageBox.Show("No se ha podido conectar a la base de datos"); } }
private Carpeta addSubCarpetaCompleta(Carpeta c, string filename) { try { Carpeta p1 = new Carpeta(this, Lista.getWrapVisible(), menuCarpetas, c); CarpetaClass s = new CarpetaClass(System.IO.Path.GetFileName(filename), "", false); p1.setClass(s); s.idMenu = Lista.getMenuFromText(_activatedButton.Content.ToString()).id; s.rutaPadre = ""; p1.actualizar(); string name = _activatedButton.Content.ToString(); p1.getClass().rutaPadre = c.getClass().ruta; p1.setRutaPrograma(c.getClass().ruta + "/" + p1.getClass().nombre); bool checkIfExists = Lista.Contains(p1.getClass().ruta); if (!checkIfExists) { Lista.addCarpeta(p1); string[] files = System.IO.Directory.GetFiles(filename, "cover.*"); if (files.Length > 0) { p1.getClass().img = files[0]; } else { p1.getClass().img = c.getClass().img; } Conexion.saveFolder(p1); p1.setRutaDirectorio(filename); p1.SetGridsOpciones(GridPrincipal, GridSecundario); c.addCarpetaHijo(p1); } else { p1 = null; s = null; } return(p1); } catch (MySqlException exc) { MessageBox.Show("No se ha podido conectar a la base de datos"); } return(null); }
public static void removeFolder(Carpeta c) { string name = c.getClass().ruta; c.remove(); if (_carpetas.Contains(c)) { _carpetas.Remove(c); Console.WriteLine("Borrada carpeta " + name); } }
/** * Aáde una subcarpeta con el nombre que se la asigne */ private void addSubCarpeta() { try { Carpeta padre = menuCarpetas.getCarpeta(); Carpeta c = new Carpeta(this, Lista.getWrapVisible(), menuCarpetas, padre); NewSubCarpeta n = null; n = new NewSubCarpeta(padre.getClass().ruta); n.ShowDialog(); if (n.getNombre() != "") { CarpetaClass s = new CarpetaClass(n.getNombre(), "", true); c.setClass(s); c.getClass().idMenu = Lista.getMenuFromText(_activatedButton.Content.ToString()).id; c.getClass().img = padre.getClass().img; c.getClass().rutaPadre = padre.getClass().ruta; c.setRutaPrograma(padre.getClass().ruta + "/" + c.getClass().nombre); padre.addCarpetaHijo(c); Lista.addCarpeta(c); Conexion.saveSubFolder(c); c.actualizar(); menuCarpetas.actualizar(padre); c.Visibility = Visibility.Visible; Lista.orderWrap(menuCarpetas.getWrap()); } else { c = null; } } catch (MySqlException exc) { MessageBox.Show("No se ha podido conectar a la base de datos"); } catch (SQLiteException exc2) { MessageBox.Show("No se ha podido conectar a la base de datos"); } }
public void removeFolder(Carpeta c) { if (wrapPanel.Children.Contains(c)) { wrapPanel.Children.Remove(c); if (hijos.Contains(c)) { hijos.Remove(c); } } else { Console.WriteLine("No se ha podido borrar la carpeta " + c.getClass().ruta); } }
/** * Añade un archivo a la carpeta que se le pase por argumentos */ private void addFileCarpeta(string fileName, Carpeta c) { try { string ruta = _profile.nombre + "|F" + c.getClass().ruta.Split('|')[1].Substring(1) + "/" + System.IO.Path.GetFileName(fileName); ArchivoClass ac = new ArchivoClass(System.IO.Path.GetFileNameWithoutExtension(fileName), fileName, ruta, c.getClass().img, c.getClass().id); Archivo a = new Archivo(ac, this, null); a.setCarpetaPadre(c); Conexion.saveFile(ac); c.addFile(a); } catch (MySqlException exc) { MessageBox.Show("No se ha podido conectar a la base de datos"); } catch (SQLiteException exc2) { MessageBox.Show("No se ha podido conectar a la base de datos"); } }
public void addCarpeta(Carpeta c) { c.Width = 250; c.Height = 400; c.Margin = new Thickness(40, 40, 40, 40); if (!c.getClass().img.Equals("")) { c.setImg(); } else { c.setDefaultSource(); } //c.changeColor(System.Drawing.Color.Red); wrapPanel.Children.Add(c); hijos.Add(c); }
public void showFoldersBySearch(string search) { List <string> lista = new List <string>(); foreach (UIElement ui in hijos) { if (ui is Carpeta) { Carpeta aux = (Carpeta)ui; lista.Add(aux.getClass().nombre); } else if (ui is Archivo) { Archivo aux = (Archivo)ui; lista.Add(aux._archivoClass.nombre); }/*else if(ui is ArchivoComponent) { * ArchivoComponent aux = (ArchivoComponent)ui; * string nombre = aux.getNombre(); * if (nombre != null) { * lista.Add(nombre); * } * }else if(ui is SerieComponent) { * SerieComponent aux = (SerieComponent)ui; * lista.Add(aux.getSerie().nombre); * }else if(ui is TemporadaComponent) { * TemporadaComponent aux = (TemporadaComponent)ui; * lista.Add("Temporada "+ aux.getTemporada().numTemporada); * }*/ } if (lista.Count != 0) { List <string> resultados = Filters.filterAlgorithm(lista.ToArray(), search); foreach (UIElement ui in hijos) { if (ui is Carpeta) { Carpeta aux = (Carpeta)ui; if (resultados.Contains(aux.getClass().nombre)) { aux.Visibility = Visibility.Visible; } else { aux.Visibility = Visibility.Collapsed; } } else if (ui is Archivo) { Archivo aux = (Archivo)ui; if (resultados.Contains(aux._archivoClass.nombre)) { aux.Visibility = Visibility.Visible; } else { aux.Visibility = Visibility.Collapsed; } }/* else if (ui is ArchivoComponent) { * ArchivoComponent aux = (ArchivoComponent)ui; * string nombre = aux.getNombre(); * if (resultados.Contains(nombre)) { * aux.Visibility = Visibility.Visible; * } else { * aux.Visibility = Visibility.Collapsed; * } * } else if (ui is SerieComponent) { * SerieComponent aux = (SerieComponent)ui; * if (resultados.Contains(aux.getSerie().nombre)) { * aux.Visibility = Visibility.Visible; * } else { * aux.Visibility = Visibility.Collapsed; * } * } else if (ui is TemporadaComponent) { * TemporadaComponent aux = (TemporadaComponent)ui; * if (resultados.Contains("Temporada " + aux.getTemporada().numTemporada)) { * aux.Visibility = Visibility.Visible; * } else { * aux.Visibility = Visibility.Collapsed; * } * }*/ } } }
public void actualizar(Carpeta cp) { carpeta = cp; Title.Content = carpeta.getClass().nombre; Descripcion.Content = carpeta.getClass().desc; ICollection <string> generosAux = carpeta.getClass().generos; if (generosAux.Count != 0) { listaGeneros.Content = carpeta.getClass().getGeneros(); } else { Generos.Visibility = Visibility.Hidden; listaGeneros.Visibility = Visibility.Hidden; } if (carpeta.getClass().img != "") { try { BitmapImage bm = new BitmapImage(new Uri(@carpeta.getClass().img, UriKind.Absolute)); ImageBrush ib = new ImageBrush(bm); if (bm.Width > bm.Height) { ib.Stretch = Stretch.UniformToFill; } Img.Background = ib; Img.Visibility = Visibility.Visible; ImgBorde.Visibility = Visibility.Hidden; } catch (ArgumentException e) { setDefaultSource(); Console.WriteLine(e.Message); } } WrapSubCarpetas.removeChildrens(); List <Carpeta> carpetasHijo = carpeta.getCarpetasHijos(); if (carpetasHijo != null) { foreach (Carpeta c in carpetasHijo) { WrapSubCarpetas.addCarpeta(c); } } List <Archivo> archivos = carpeta._archivos; if (archivos != null) { foreach (Archivo a in archivos) { WrapSubCarpetas.addFile(a); } } List <UIElement> hijos = OrderClass.orderChildOfWrap(WrapSubCarpetas.hijos); WrapSubCarpetas.getWrapPanel().Children.Clear(); foreach (UIElement o in hijos) { WrapSubCarpetas.addUIElement(o); } }