private void insertarImagen_Click(object sender, EventArgs e) { PictureBox imagen = new PictureBox(); OpenFileDialog dialogoBuscarArchivo = new OpenFileDialog(); //Se crean las opciones de busqueda dialogoBuscarArchivo.InitialDirectory = "c:\\"; dialogoBuscarArchivo.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.png; *.bmp)|*.jpg; *.jpeg; *.gif; *.png; *.bmp"; //el ShowDialog() muestra el explorador de archivos para que elijas tu archivo. Si se hace click en Aceptar , se abre el archivo if (dialogoBuscarArchivo.ShowDialog() == DialogResult.OK) { Bitmap img = new Bitmap(dialogoBuscarArchivo.FileName); var imageHeight = img.Height; var imageWidth = img.Width; //propiedades de la imagen imagen.Size = new Size(imageWidth, imageHeight); //Guardar imagen en la carpeta ImagenesBD if (!File.Exists(@"..\..\ImagenesBD\\" + dialogoBuscarArchivo.SafeFileName)) { imagen.Image.Save(@"..\..\ImagenesBD\\" + dialogoBuscarArchivo.SafeFileName); } //Añadir elemento a la base de datos ClaseElemento oelemento = new ClaseElemento("img", dialogoBuscarArchivo.SafeFileName, Convert.ToInt16(columna_id.Text), imagen.Width, 0, 0, imagen.Height); BDElementos.insertarElemento(oelemento); } }
private void insertarVideo_Click(object sender, EventArgs e) { string url = Interaction.InputBox("Introduce la url del video que quieres insertar", "Video", ""); if (String.IsNullOrEmpty(url) || String.IsNullOrWhiteSpace(url)) { MessageBox.Show("Introduce una url valida"); } else { //Añadir elemento a la base de datos ClaseElemento oelemento = new ClaseElemento("video", url, Convert.ToInt16(columna_id.Text), 240, 0, 0, 120); BDElementos.insertarElemento(oelemento); } }
private void insertarParrafo_Click(object sender, EventArgs e) { string textoParrafo = Interaction.InputBox("Introduce el parrafo que quieres insertar", "Parrafo", ""); if (String.IsNullOrEmpty(textoParrafo) || String.IsNullOrWhiteSpace(textoParrafo)) { MessageBox.Show("Introduce un nombre valido"); } else { Label parrafo = new Label(); //Añadir elemento a la base de datos ClaseElemento oelemento = new ClaseElemento("p", textoParrafo, Convert.ToInt16(columna_id.Text), 300, 0, 0, 300); BDElementos.insertarElemento(oelemento); } }
private void insertarTitulo_Click(object sender, EventArgs e) { string textoTitulo = Interaction.InputBox("Introduce el titulo que quieres insertar", "Titulo", ""); if (String.IsNullOrEmpty(textoTitulo) || String.IsNullOrWhiteSpace(textoTitulo)) { MessageBox.Show("Introduce un nombre valido"); } else { //propiedades del titulo Label titulo = new Label(); titulo.Text = textoTitulo; titulo.AutoSize = true; //Añadir elemento a la base de datos ClaseElemento oelemento = new ClaseElemento("title", textoTitulo, Convert.ToInt16(columna_id.Text), titulo.Width, 0, 0, 26); BDElementos.insertarElemento(oelemento); } }