Пример #1
0
        public void crearPanel()
        {
            var proxy = new ProxyInstagram();
            var res   = proxy.GetUser(user);

            panel.SetBounds(x, y, BusquedaPanel.Width - 20, 44);

            nombre.Text = "" + user;
            nombre.Font = new Font("Calibri", 10, FontStyle.Bold);
            nombre.SetBounds(panel.Width / 2 - 20, panel.Height / 2 - (int)nombre.Font.Size - 8, panel.Width / 2, 14);
            panel.Controls.Add(nombre);

            nombrec.Text = "" + res.nombre;
            nombrec.Font = new Font("Calibri", 8, FontStyle.Regular);
            nombrec.SetBounds(panel.Width / 2 - 20, panel.Height / 2 - (int)nombre.Font.Size + 8, panel.Width / 2, 14);
            panel.Controls.Add(nombrec);

            var   urlimage = newURL + res.foto;
            Image image    = Image.FromFile(urlimage);

            imagen.Image    = image;
            imagen.SizeMode = PictureBoxSizeMode.StretchImage;
            imagen.SetBounds(25, 0, panel.Height - 8, panel.Height - 8);
            panel.Controls.Add(imagen);

            panel.Click  += (s, ev) => { PerfilUsuario(nombre.Text); };
            imagen.Click += (s, ev) => { PerfilUsuario(nombre.Text); };
            nombre.Click += (s, ev) => { PerfilUsuario(nombre.Text); };
            panel.Cursor  = Cursors.Hand;
            imagen.Cursor = Cursors.Hand;
            nombre.Cursor = Cursors.Hand;
        }
Пример #2
0
        public void crearPanel()
        {
            var proxy = new ProxyInstagram();
            var user  = proxy.GetUser(perfil);

            panel.SetBounds(x, y, SeguidoPanel.Width - 20, 46);

            var   urlimage = newURL + user.foto;
            Image image    = Image.FromFile(urlimage);

            imagen.Image    = image;
            imagen.SizeMode = PictureBoxSizeMode.StretchImage;
            imagen.SetBounds(26, 0, panel.Height - 8, panel.Height - 8);
            panel.Controls.Add(imagen);

            nombre.Text = "" + perfil;
            nombre.SetBounds(imagen.Location.X + 50, panel.Height / 2 - (int)nombre.Font.Size, (perfil.Length + 1) * 7 - 2, panel.Height / 3);
            panel.Controls.Add(nombre);

            panel.Controls.Add(estado);
            estado.SetBounds(nombre.Location.X + nombre.Width + (12 / perfil.Length), panel.Height / 2 - 16, 100, 26);
            estado.ForeColor = Color.LightSkyBlue;
            estado.FlatStyle = FlatStyle.Flat;
            bool res = proxy.SeguirEstado(usuario, perfil);

            if (!res)
            {
                estado.Text = "Seguir";
            }
            else
            {
                estado.Text = "Siguiendo";
            }
            estado.Width = estado.Text.Length * 9;
            ColorBoton();

            if (usuario == perfil)
            {
                estado.Visible = false;
            }

            nombre.Click += (s, ev) => { PerfilUsuario(nombre.Text); };
            estado.Click += (s, ev) => {
                proxy.SeguirCambiar(usuario, perfil);
                if (estado.Text == "Seguir")
                {
                    estado.Text = "Siguiendo";
                }
                else
                {
                    estado.Text = "Seguir";
                }
                estado.Width = estado.Text.Length * 9;
                ColorBoton();
                Update();
            };
            nombre.Cursor = Cursors.Hand;
            estado.Cursor = Cursors.Hand;
        }
Пример #3
0
        public void crearPanel()
        {
            principalPanel.SetBounds(x + 2, y + 2, PostsPanel.Width - 22, PostsPanel.Height - 4);


            topPanel.Dock      = DockStyle.Top;
            topPanel.BackColor = Color.White;
            topPanel.Height    = 46;
            imagen.SetBounds(14, 7, topPanel.Height - 14, topPanel.Height - 14);
            var   urlimage = newURL + post.foto;
            Image image    = Image.FromFile(urlimage);

            imagen.Image    = image;
            imagen.SizeMode = PictureBoxSizeMode.StretchImage;
            topPanel.Controls.Add(imagen);

            principalPanel.Controls.Add(topPanel);

            nombre.Cursor = Cursors.Hand;
            nombre.Click += (s, ev) => { PerfilUsuario(nombre.Text); };

            nombre.Text = "" + post.usuario;
            nombre.Font = new Font("Calibri", 10, FontStyle.Bold);
            nombre.SetBounds(topPanel.Width / 5, topPanel.Height / 2 - (int)nombre.Font.Size - 5, (topPanel.Width / 4) * 3, (int)nombre.Font.Size + 5);
            topPanel.Controls.Add(nombre);

            titulo.Text = "" + post.titulo;
            titulo.Font = new Font("Calibri", 8);
            titulo.SetBounds(topPanel.Width / 5, topPanel.Height / 2 + 2, (topPanel.Width / 4) * 3, (int)titulo.Font.Size + 5);
            topPanel.Controls.Add(titulo);

            Label likes      = new Label();
            int   likesCount = post.likes;

            likes.Text = likesCount + " Me gusta"; // Contar Likes
            likes.Font = new Font("Calibri", 8);
            likes.SetBounds(60, 14, (topPanel.Width / 4) * 2, (int)likes.Font.Size + 5);
            dataPanel.Controls.Add(likes);

            PictureBox like = new PictureBox();
            Image      newImagen2;
            bool       meGusta = proxy.LikeEstado(user, post.usuario, post.id);

            if (!meGusta)
            {
                newImagen2 = Image.FromFile(newURL + "Imagenes/like.png");
            }
            else
            {
                newImagen2 = Image.FromFile(newURL + "Imagenes/liked.png");
            }
            like.Image    = newImagen2;
            like.SizeMode = PictureBoxSizeMode.Zoom;
            dataPanel.Controls.Add(like);
            like.SetBounds(comment.Location.X + 26, 10, 25, 25);
            like.Cursor = Cursors.Hand;
            like.Click += (s, ev) => {
                proxy.LikeCambiar(user, post.usuario, post.id);
                if (meGusta)
                {
                    newImagen2  = Image.FromFile(newURL + "Imagenes/like.png");
                    likesCount -= 1;
                    meGusta     = false;
                }
                else
                {
                    newImagen2  = Image.FromFile(newURL + "Imagenes/liked.png");
                    likesCount += 1;
                    meGusta     = true;
                }
                like.Image = newImagen2;
                likes.Text = likesCount + " Me gusta";
            }; //like

            PictureBox save = new PictureBox();

            dataPanel.Controls.Add(save);
            save.SetBounds(comment.Location.X + 278, 10, 25, 25);
            Image newImagen3;
            bool  guardado = proxy.GuardarEstado(user, post.usuario, post.id);;

            if (!guardado)
            {
                newImagen3 = Image.FromFile(newURL + "Imagenes/GuardadoUnactive.png");
            }
            else
            {
                newImagen3 = Image.FromFile(newURL + "Imagenes/Guardado.png");
            }
            save.Image    = newImagen3;
            save.SizeMode = PictureBoxSizeMode.Zoom;
            save.Cursor   = Cursors.Hand;
            save.Click   += (s, ev) => {
                proxy.GuardarCambiar(user, post.usuario, post.id);
                if (guardado)
                {
                    guardado   = false;
                    newImagen3 = Image.FromFile(newURL + "Imagenes/GuardadoUnactive.png");
                }
                else
                {
                    guardado   = true;
                    newImagen3 = Image.FromFile(newURL + "Imagenes/Guardado.png");
                }
                save.Image = newImagen3;
            }; //save

            var newComentario = new ConstructorComentario(post.usuario, post.descripcion, PerfilUsuario).CrearObjeto();

            newComentario.crearPanel();
            Panel descripcion = newComentario.obtenerPanel();

            descripcion.Location = new Point(24, 48);
            dataPanel.Controls.Add(descripcion);

            var Offset = 50 + descripcion.Height + 2;

            if (post.comentarios.Count > 3)
            {
                var cargarTodos = new Label();
                dataPanel.Controls.Add(cargarTodos);
                cargarTodos.Text      = $"Ver los {post.comentarios.Count} comentarios";
                cargarTodos.ForeColor = Color.Gray;
                cargarTodos.SetBounds(28, Offset, cargarTodos.Text.Length * 7, 12);
                cargarTodos.Cursor = Cursors.Hand;
                Offset            += 18;
                cargarTodos.Click += (s, ev) => {
                    // Mostrar panel
                    var ventana = new VentanaPost(PerfilUsuario, post, user, UpdatePosts, Principal, PostsPanel, likesCount);
                };
            }
            //Ultimos 3 comentarios
            int aux = post.comentarios.Count - 3;

            if (aux < 0)
            {
                aux = 0;
            }
            for (int i = aux; i < post.comentarios.Count; i++)
            {
                var com            = post.comentarios[i];
                var newComentario2 = new ConstructorComentario(com.name, com.data, PerfilUsuario).CrearObjeto();
                newComentario2.crearPanel();
                Panel descripciones = newComentario2.obtenerPanel();
                descripciones.Location = new Point(24, Offset);
                dataPanel.Controls.Add(descripciones);
                if (com.name == user)
                {
                    PictureBox opciones = new PictureBox();
                    Image      imagen   = Image.FromFile(newURL + "Imagenes/config.png");
                    opciones.Image    = imagen;
                    opciones.Cursor   = Cursors.Hand;
                    opciones.SizeMode = PictureBoxSizeMode.Zoom;
                    dataPanel.Controls.Add(opciones);
                    opciones.SetBounds(descripciones.Location.X + descripciones.Width + 4, descripciones.Location.Y, 28, 10);
                    var    activo = false;
                    Button borrar = new Button();
                    opciones.Click += (s, ev) => {
                        if (!activo)
                        {
                            borrar.Visible   = true;
                            borrar.Text      = "Eliminar";
                            borrar.FlatStyle = FlatStyle.Flat;
                            dataPanel.Controls.Add(borrar);
                            borrar.BringToFront();
                            borrar.Focus();
                            borrar.Location = new Point(opciones.Location.X - 70, opciones.Location.Y - 8);
                            borrar.Click   += (se, eve) =>
                            {
                                proxy.BorrarComentario(post.usuario, post.id, com.id);
                                UpdatePosts();
                                borrar.Visible = false;
                            };
                            borrar.LostFocus += (se, eve) =>
                            {
                                borrar.Visible = false;
                                activo         = false;
                            };
                            activo = true;
                        }
                        else
                        {
                            borrar.Visible = false;
                            activo         = false;
                        }
                    };
                }

                Offset += descripciones.Height + 2;
            }

            dataPanel.Click += (s, ev) => { dataPanel.Focus(); };
            dataPanel.Controls.Add(comment);
            comment.SetBounds(26, Offset + 10, dataPanel.Width + 20, 12);
            comment.BackColor   = Color.WhiteSmoke;
            comment.ForeColor   = Color.DarkGray;
            comment.BorderStyle = BorderStyle.None;
            comment.Font        = new Font("Calibri", 9);
            comment.Text        = "Agregar un comentario...";
            comment.Enter      += (s, ev) => { if (comment.Text == "Agregar un comentario...")
                                               {
                                                   comment.Text = ""; comment.ForeColor = Color.Black;
                                               }
            };
            comment.Leave += (s, ev) => { if (comment.Text == "")
                                          {
                                              comment.Text = "Agregar un comentario..."; comment.ForeColor = Color.DarkGray;
                                          }
            };

            PictureBox enviar    = new PictureBox();
            Image      newImagen = Image.FromFile(newURL + "Imagenes/send.png");

            enviar.Image    = newImagen;
            enviar.SizeMode = PictureBoxSizeMode.Zoom;
            enviar.SetBounds(comment.Location.X + 230, comment.Location.Y - 5, 25, 25);
            dataPanel.Controls.Add(enviar);
            enviar.Cursor = Cursors.Hand;
            enviar.Click += (s, ev) => {
                if (comment.Text != "" && comment.Text != "Agregar un comentario...")
                {
                    proxy.GuardarComentario(user, post.usuario, post.id, comment.Text);
                }
                UpdatePosts();
                comment.Text = "Agregar un comentario...";
            };

            Offset += 28;

            PictureBox imagenPrincipal = new PictureBox();

            urlimage = newURL + post.url;
            image    = Image.FromFile(urlimage);
            imagenPrincipal.Image     = image;
            imagenPrincipal.SizeMode  = PictureBoxSizeMode.Zoom;
            imagenPrincipal.BackColor = Color.Black;
            imagenPrincipal.SetBounds(0, 46, principalPanel.Width, principalPanel.Height - 66);
            principalPanel.Controls.Add(imagenPrincipal);

            dataPanel.Dock         = DockStyle.Bottom;
            dataPanel.Height       = Offset + 20;
            principalPanel.Height += dataPanel.Height - 20;
            dataPanel.BackColor    = Color.White;
            principalPanel.Controls.Add(dataPanel);

            PostsPanel.Controls.Add(principalPanel);
        }
Пример #4
0
        public EditarPerfil(string perfil, Form Perfil, Action UpdatePerfil)
        {
            string url = Directory.GetCurrentDirectory();

            newURL = "";
            for (int i = 0; i < url.Length - 9; i++)
            {
                newURL += url[i];
            }

            var proxy = new ProxyInstagram();
            var user  = proxy.GetUser(perfil);

            Perfil.Controls.Add(principalPanel);
            principalPanel.BorderStyle = BorderStyle.FixedSingle;
            principalPanel.SetBounds(Perfil.Width / 3 - 25, 70, Perfil.Width / 3 + 50, 400);
            principalPanel.BringToFront();


            salir.Text   = "X";
            salir.Cursor = Cursors.Hand;
            principalPanel.Controls.Add(salir);
            salir.SetBounds(principalPanel.Width - 50, 8, 40, 30);
            salir.FlatStyle = FlatStyle.Flat;
            salir.FlatAppearance.BorderSize = 0;
            salir.Click += (s, ev) => { Perfil.Controls.Remove(principalPanel); };


            PictureBox imagenPrincipal = new ImagenCircular();
            var        urlimage        = newURL + user.foto;
            var        image           = Image.FromFile(urlimage);

            imagenPrincipal.Image       = image;
            imagenPrincipal.BorderStyle = BorderStyle.FixedSingle;
            imagenPrincipal.SizeMode    = PictureBoxSizeMode.StretchImage;
            imagenPrincipal.SetBounds(principalPanel.Width / 4, 40, (principalPanel.Width / 4) * 2, (principalPanel.Width / 4) * 2);
            principalPanel.Controls.Add(imagenPrincipal);

            var label       = new Label();
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            principalPanel.Controls.Add(add);
            add.Text = "+";
            add.Font = new Font("Calibri", 8);
            add.SetBounds(imagenPrincipal.Location.X + imagenPrincipal.Width, imagenPrincipal.Location.Y + imagenPrincipal.Height - 20, 20, 20);
            add.FlatStyle = FlatStyle.Flat;
            add.Click    += (s, ev) => {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = " Image files|*.bmp;*.jpg;*.png;";
                openFileDialog.RestoreDirectory = true;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    principalPanel.Controls.Remove(label);
                    filePath = openFileDialog.FileName;
                    var data = filePath.Split('.');
                    filetype = data[data.Length - 1];
                    urlimage = filePath;
                    image    = Image.FromFile(urlimage);
                    imagenPrincipal.Image = image;
                }
            };

            Label biografia = new Label();

            biografia.Text = "Biografía: ";
            principalPanel.Controls.Add(biografia);
            biografia.SetBounds(32, imagenPrincipal.Location.Y + imagenPrincipal.Height + 50, biografia.Text.Length * 6, 14);

            TextBox Tbiografia = new TextBox();

            principalPanel.Controls.Add(Tbiografia);
            Tbiografia.Text = user.biografia;
            Tbiografia.SetBounds(biografia.Location.X + 4, biografia.Location.Y + 20, 220, 50);
            Tbiografia.BackColor   = Color.WhiteSmoke;
            Tbiografia.Multiline   = true;
            Tbiografia.BorderStyle = BorderStyle.None;
            Tbiografia.MaxLength   = 160;

            principalPanel.Controls.Add(aceptar);
            aceptar.Text = "Guardar";
            aceptar.Font = new Font("Calibri", 8);
            aceptar.SetBounds(Tbiografia.Location.X + Tbiografia.Width - aceptar.Text.Length * 8, Tbiografia.Location.Y + Tbiografia.Height + 30, aceptar.Text.Length * 8, 26);
            aceptar.FlatStyle = FlatStyle.Flat;
            aceptar.Click    += (s, ev) => {
                var data      = filePath.Split('\\');
                var imagedata = "Imagenes\\" + data[data.Length - 1];
                if (imagedata.Length >= 40)
                {
                    label.Text      = "Nombre de Imagen supera 30 caracteres";
                    label.ForeColor = Color.Red;
                    principalPanel.Controls.Add(label);
                    label.SetBounds(40, imagenPrincipal.Location.Y + imagenPrincipal.Height + 10, principalPanel.Width - 40, 24);
                    return;
                }
                //var imagedata = "Imagenes\\" + perfil + "." + filetype;
                image = Image.FromFile(urlimage);
                image.Save(newURL + imagedata);
                proxy.EditarPerfil(perfil, "\\" + imagedata, Tbiografia.Text);
                UpdatePerfil();
                Perfil.Controls.Remove(principalPanel);
            };
        }
Пример #5
0
        private void Update()
        {
            aTimer.Stop();
            if (index > stories.Count - 1)
            {
                Principal.Controls.Remove(principalPanel);
                Principal.ActiveControl = top;
                return;
            }
            else
            {
                aTimer           = new System.Timers.Timer(2500);
                aTimer.AutoReset = true;
                aTimer.Start();
                aTimer.Elapsed += async(sender, e) => principalPanel.Invoke(new MethodInvoker(() => { Update(); }));
            }

            var res = proxy.GetUser(usuario);

            principalPanel.Controls.Clear();

            principalPanel.SetBounds(202, 62, 328, 418);
            principalPanel.BorderStyle = BorderStyle.FixedSingle;
            principalPanel.BringToFront();

            imagen.SetBounds(14, 10, 34, 34);
            var   urlimage = res.foto;
            Image image    = Image.FromFile(newURL + urlimage);

            imagen.Image    = image;
            imagen.SizeMode = PictureBoxSizeMode.StretchImage;
            principalPanel.Controls.Add(imagen);

            nombre.Text      = usuario;
            nombre.ForeColor = Color.White;
            nombre.Font      = new Font("Calibri", 10, FontStyle.Bold);
            principalPanel.Controls.Add(nombre);
            nombre.Cursor = Cursors.Hand;
            nombre.SetBounds(54, 20, nombre.Text.Length * 9 + 2, 24);
            nombre.BackColor = Color.Transparent;
            nombre.Click    += (s, ev) => { PerfilUsuario(usuario); };

            salir.Text   = "X";
            salir.Cursor = Cursors.Hand;
            principalPanel.Controls.Add(salir);
            salir.SetBounds(principalPanel.Width - 40, 8, 30, 20);
            salir.FlatStyle = FlatStyle.Flat;
            salir.FlatAppearance.BorderSize = 0;
            salir.BackColor = Color.White;
            salir.Click    += (s, ev) => { Principal.Controls.Remove(principalPanel); Principal.ActiveControl = top; };

            principalPanel.Controls.Add(imagenPrincipal);
            imagenPrincipal.SetBounds(0, 0, principalPanel.Width, principalPanel.Height);
            imagenPrincipal.SizeMode = PictureBoxSizeMode.Zoom;
            urlimage = newURL + stories[index].url;
            var image2 = Image.FromFile(urlimage);

            imagenPrincipal.Image = image2;

            var horas    = Math.Truncate((DateTime.Now - stories[index].date).TotalHours);
            var minutos  = Math.Truncate((DateTime.Now - stories[index].date).TotalMinutes);
            var segundos = Math.Truncate((DateTime.Now - stories[index].date).TotalSeconds);

            if (horas > 0)
            {
                tiempo.Text = horas.ToString() + "h";
            }
            else if (minutos > 0)
            {
                tiempo.Text = minutos.ToString() + "m";
            }
            else if (segundos > 0)
            {
                tiempo.Text = segundos.ToString() + "s";
            }
            tiempo.ForeColor = Color.White;
            tiempo.Font      = new Font("Calibri", 10);
            principalPanel.Controls.Add(tiempo);
            tiempo.SetBounds(nombre.Location.X + nombre.Width + 6, 20, tiempo.Text.Length * 9 + 8, 24);
            tiempo.BackColor = Color.Transparent;
            tiempo.BringToFront();

            index++;
        }
Пример #6
0
        public void crearPanel()
        {
            var res = proxy.GetUser(storie.nombre);

            panel.SetBounds(x, y, StoryPanel.Width - 20, StoryPanel.Height / 7);

            nombre.Text = "" + storie.nombre;
            nombre.SetBounds(panel.Width / 2 - 25, panel.Height / 2 - (int)nombre.Font.Size, panel.Width / 2, panel.Height / 3);
            panel.Controls.Add(nombre);

            var   urlimage = newURL + res.foto;
            Image image    = Image.FromFile(urlimage);

            imagen.Image    = image;
            imagen.SizeMode = PictureBoxSizeMode.StretchImage;
            imagen.SetBounds(25, 0, panel.Height, panel.Height);
            panel.Controls.Add(imagen);

            panel.Click  += (s, ev) => { StoriesUsuario(storie.stories, storie.nombre); };
            imagen.Click += (s, ev) => { StoriesUsuario(storie.stories, storie.nombre); };
            nombre.Click += (s, ev) => { StoriesUsuario(storie.stories, storie.nombre); };
            panel.Cursor  = Cursors.Hand;
            imagen.Cursor = Cursors.Hand;
            nombre.Cursor = Cursors.Hand;

            if (name == storie.nombre)
            {
                PictureBox opciones = new PictureBox();
                Image      imagen2  = Image.FromFile(newURL + "Imagenes/config.png");
                opciones.Image    = imagen2;
                opciones.Cursor   = Cursors.Hand;
                opciones.SizeMode = PictureBoxSizeMode.Zoom;
                panel.Controls.Add(opciones);
                opciones.SetBounds(panel.Width - 24, 8, 18, 14);
                var    activo = false;
                Button borrar = new Button();
                opciones.Click += (s, ev) =>
                {
                    if (!activo)
                    {
                        borrar.Visible   = true;
                        borrar.Text      = "Eliminar Stories";
                        borrar.FlatStyle = FlatStyle.Flat;
                        panel.Controls.Add(borrar);
                        borrar.BringToFront();
                        borrar.Focus();
                        borrar.Width    = 124;
                        borrar.Location = new Point(opciones.Location.X - 120, opciones.Location.Y - 4);
                        borrar.Click   += (se, eve) =>
                        {
                            // Update Story Panel
                            proxy.BorrarStories(name);
                            Update();
                        };
                        borrar.LostFocus += (se, eve) =>
                        {
                            borrar.Visible = false;
                            activo         = false;
                        };
                        activo = true;
                    }
                    else
                    {
                        borrar.Visible = false;
                        activo         = false;
                    }
                };
            }
        }