Exemplo n.º 1
0
 private void BAceptar_Click(object sender, EventArgs e)
 {
     if (newName.Text.CompareTo("") != 0)
     {
         Regex containsABadCharacter = new Regex("[" + Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars())) + "]");
         if (!containsABadCharacter.IsMatch(newName.Text))
         {
             if (!Lista.Contains(rutaPadre + "/" + newName.Text))
             {
                 _nombre = newName.Text;
                 this.Close();
             }
             else
             {
                 MessageBox.Show("La subcarpeta ya existe");
             }
         }
         else
         {
             MessageBox.Show("El nombre contiene caractéres no permitidos: " + new string(System.IO.Path.GetInvalidFileNameChars()));
         }
     }
     else
     {
         MessageBox.Show("No has introducido ningún nombre para la carpeta");
     }
 }
Exemplo n.º 2
0
        private void BAceptar_Click(object sender, EventArgs e)
        {
            if (Title.Text.CompareTo("") != 0)
            {
                Regex containsABadCharacter = new Regex("[" + Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars())) + "]");
                if (!containsABadCharacter.IsMatch(Title.Text))
                {
                    if (!Lista.Contains(VIGallery._profile.nombre + "|C/" + button.Content + "/" + Title.Text))
                    {
                        ICollection <string> col = new List <string>();

                        UIElementCollection coleccion = ListGeneros.Children;
                        bool isCheked = false;
                        foreach (CheckBox cb in coleccion)
                        {
                            if (cb.IsChecked == true)
                            {
                                col.Add((string)cb.Content);
                                isCheked = true;
                            }
                        }

                        if (isCheked)
                        {
                            if (!dirImg.Equals(""))
                            {
                                carpeta        = new CarpetaClass(Title.Text, DescBox.Text, dirImg.Text, col, true);
                                carpeta.idMenu = Lista.getMenuFromText(button.Content.ToString()).id;
                            }
                        }
                        else
                        {
                            if (!dirImg.Equals(""))
                            {
                                carpeta = new CarpetaClass(Title.Text, DescBox.Text, dirImg.Text, true);
                            }
                        }
                        carpeta.idMenu = Lista.getMenuFromText(button.Content.ToString()).id;
                        carpeta.ruta   = "C/" + button.Content + "/" + padre.getTitle();
                        padre.setClass(carpeta);
                        Lista.addCarpetaClass(carpeta);
                        created = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ya existe la carpeta. Introduce otro nombre");
                    }
                }
                else
                {
                    MessageBox.Show("El nombre contiene caractéres no permitidos: " + new string(System.IO.Path.GetInvalidFileNameChars()));
                }
            }
            else
            {
                MessageBox.Show("No has introducido ningun nombre");
            }
        }
Exemplo n.º 3
0
        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);
        }