using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Gestor_de_Contenidos
{
    public partial class frm_nuevo_clasificador : Form
    {
        private ItemCategoria item;
        public frm_nuevo_clasificador()
        {
            InitializeComponent();
        }

        private void btn_cancelar_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void btn_buscar_imagen_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                tb_imagen.Text = openFileDialog1.FileName;
            }
        }

        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (tb_imagen.Text.Equals("") || tb_text.Text.Equals("") || tb_nombre.Text.Equals(""))
                lbl_rellena.Visible = true;
            else
            {
                item = new ItemCategoria(tb_nombre.Text, tb_text.Text, tb_imagen.Text);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }

        public ItemCategoria getItem() { return item; }

        public void setItem(ItemCategoria item_no_editado)
        {
            this.item = item_no_editado;
            tb_text.Text = item.Texto;
            tb_nombre.Text = item.Nombre;
            tb_imagen.Text = item.Imagen;

         
        }

        private void tb_imagen_TextChanged(object sender, EventArgs e)
        {
            if (tb_imagen.Text.Equals(""))
                pb_imagen.Visible = false;
            else
            {
                pb_imagen.Visible = true;
                pb_imagen.Image = Image.FromFile(tb_imagen.Text);
                pb_imagen.Image = pb_imagen.Image.GetThumbnailImage(pb_imagen.Width, pb_imagen.Height, null, new System.IntPtr());


            }
        }
    }
}
