Exemple #1
0
        private void cargarNoticia(NoticiaBD n)
        {
            var template = new TableLayoutPanel();

            template.RowCount    = 2;
            template.ColumnCount = 1;
            template.Width       = 200;
            template.Height      = 200;
            template.Margin      = new Padding(30, 3, 3, 3);
            template.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90F));
            template.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
            //TODO  template.BackColor = Color.AntiqueWhite;

            var picture = new PictureBox();

            picture.Image = n.image;
            picture.BackgroundImageLayout = ImageLayout.Stretch;
            picture.SizeMode = PictureBoxSizeMode.StretchImage;
            picture.Width    = 200;
            picture.Height   = 180;
            picture.Cursor   = Cursors.Hand;


            picture.Click += (object sender, EventArgs e) =>
            {
                template.BackColor = Color.AliceBlue;
                if (selected != null)
                {
                    selected.BackColor = Color.Transparent;
                }
                selected     = template;
                seleccionada = n;
            };

            picture.DoubleClick += (object sender, EventArgs e) =>
            {
                Noticia ventana = new Noticia(n);
                this.Visible = false;
                ventana.ShowDialog();
                this.Close();
            };

            var lable = new Label();

            lable.Text  = n.titulo;
            lable.Width = 200;

            template.Controls.Add(picture);
            template.Controls.Add(lable);
            template.SetCellPosition(picture, new TableLayoutPanelCellPosition(0, 0));
            template.SetCellPosition(lable, new TableLayoutPanelCellPosition(0, 1));
            fNoticias.Controls.Add(template);
        }
Exemple #2
0
        private void bBorrar_Click(object sender, EventArgs e)
        {
            if (seleccionada != null)
            {
                BD.Delete("Noticia", seleccionada.id);

                cargarNoticias();
            }

            seleccionada = null;
            selected     = null;
        }
Exemple #3
0
        public CrearNoticia(NoticiaBD n)
        {
            InitializeComponent();

            noticia = n;

            if (noticia != null)
            {
                tCuerpo.Text  = noticia.cuerpo;
                tTitular.Text = noticia.titulo;
                pImagen.Image = n.image;
            }
        }
Exemple #4
0
        private void bEditar_Click(object sender, EventArgs e)
        {
            if (seleccionada != null)
            {
                CrearNoticia ventana = new CrearNoticia(seleccionada);
                this.Visible = false;
                ventana.ShowDialog();
                this.Visible = true;


                cargarNoticias();
            }

            seleccionada = null;
            selected     = null;
        }
Exemple #5
0
        public Noticia(NoticiaBD noticia)
        {
            InitializeComponent();
            this.noticia = noticia;

            this.lAutor.Text    = String.Format("Noticia redactada por {0} el dia {1}", noticia.autor, noticia.fecha);
            this.lTitular.Text  = noticia.titulo;
            this.tCuerpo.Text   = noticia.cuerpo;
            this.pbImagen.Image = noticia.image;

            if (Usuario.hasInstance())
            {
                this.lUsuario.Text = Usuario.getInstance().usuario;

                bCerrarSesion.Visible = true;
                lUsuario.Visible      = true;
                pImagen.Visible       = true;
                bPerfil.Visible       = true;
                var i = BD.Select("SELECT imagen FROM ImagenPerfil WHERE nombreUsuario = '" + Usuario.getInstance().usuario + "';");

                if (i.Count > 0)
                {
                    pImagen.Image = Noticias.GetImageFromByteArray((byte[])(i[0][0]));
                }
            }
            else
            {
                bIniciarSesion.Visible = true;
                bRegistrarse.Visible   = true;
            }

            foreach (var a in Usuario.get_eventos())
            {
                mCalendario.AddBoldedDate(a.dia);
            }
        }