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"); } }
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); }
/** * Borra un menu y todos los elementos que contiene */ private void removeMenu(object sender, EventArgs e) { try { if (_activatedButton != null) { long id = Lista.getMenuFromText(_activatedButton.Content.ToString()).id; WrapPanelPrincipal wp = Lista.getWrapFromMenu(Lista.getMenuFromText(_activatedButton.Content.ToString())); if (id != 0) { Conexion.deleteMenu(id); Lista.removeMenu(_activatedButton.Content.ToString()); if (_botonesMenu.Contains(_activatedButton)) { _botonesMenu.Remove(_activatedButton); } if (_botones.Contains(_activatedButton)) { _botones.Remove(_activatedButton); } if (gridPrincipal.Children.Contains(wp)) { gridPrincipal.Children.Remove(wp); } if (_botonesMenu.Count != 0) { foreach (ComboBoxItem b in _botonesMenu) { onClickButtonMenu(b, e); break; } } else { _activatedButton = null; } ReturnVisibility(false); } } clearTextBox(); } catch (MySqlException exc) { MessageBox.Show("No se ha podido conectar a la base de datos"); } }
/** * Evento que se añadira a un menu cargado */ public void onClickButtonMenuEspecial(object sender) { ComboBoxItem b = (ComboBoxItem)sender; MenuClass mc = Lista.getMenuFromText(b.Content.ToString()); if (Lista.buttonInButtons(mc)) { Lista.hideAll(); GridSecundario.SetValue(Grid.RowProperty, 1); GridPrincipal.SetValue(Grid.RowProperty, 0); Lista.showWrapFromMenu(mc); } menu.SelectedItem = b; _activatedButton = b; b.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF595959")); Return.Visibility = Visibility.Hidden; }
/** * Evento que se lanza al pulsar alguno de los botones del menu * Oculta los paneles de cada menu y muestra el seleccionado */ public void onClickButtonMenu(object sender, EventArgs e) { ComboBox b = (ComboBox)sender; ComboBoxItem selected = (ComboBoxItem)b.SelectedItem; MenuClass mc = Lista.getMenuFromText(selected.Content.ToString()); WrapPanelPrincipal wp = Lista.getWrapVisible(); clearTextBox(); if (Lista.buttonInButtons(mc)) { Lista.hideAll(); menuCarpetas.Visibility = Visibility.Hidden; GridSecundario.SetValue(Grid.RowProperty, 1); GridPrincipal.SetValue(Grid.RowProperty, 0); Lista.showWrapFromMenu(mc); } _activatedButton = selected; Return.Visibility = Visibility.Hidden; borderEnter.Visibility = Visibility.Hidden; }
/** * 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"); } }