Exemple #1
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");
            }
        }