示例#1
0
        public OtherProfile(int otherUserID)
        {
            InitializeComponent();
            user                      = MainView.user;
            proxy                     = MainView.proxy;
            otherUser                 = proxy.GetUserById(otherUserID);
            user                      = proxy.GetUserById(user.ID);
            otherUser.friends         = proxy.GetFriends(otherUser.ID);
            checkFriendship           = proxy.CheckFriendship(user.ID, otherUser.ID);
            checkRequest              = proxy.CheckRequest(user.ID, otherUser.ID);
            checkInversedRequest      = proxy.CheckRequest(otherUser.ID, user.ID);
            completeNameLabel.Text    = otherUser.firstName + " " + otherUser.lastName;
            dateJoinedLabel.Text      = otherUser.dateJoined.ToString("MMMM") + " " + otherUser.dateJoined.Year.ToString();
            birthdayDateLabel.Text    = otherUser.birthday.Day.ToString() + " de " + otherUser.birthday.ToString("MMMM");
            profilePictureImage.Image = Image.FromFile(otherUser.profilePicture);
            nameBtn.Text              = user.firstName;
            countFriendsLabel.Text    = otherUser.friends.Count.ToString();
            if (checkRequest)
            {
                friendsBtn.Text = "Aceptar solicitud";
            }
            else if (checkInversedRequest)
            {
                friendsBtn.Text = "Cancelar solicitud";
            }
            else if (!checkFriendship)
            {
                friendsBtn.Text = "Añadir amigo";
            }
            else
            {
                friendsBtn.Text = "Eliminar amigo";
            }
            var feedCooker = new FeedCooker(new BuilderProfileFeed(this.refresh, this, postPanel, user.ID, otherUser.ID, proxy));

            feedCooker.ObtenerFeed();
            if (postPanel.Controls.Count < 2)
            {
                noPostLbl.Text = "Sin actividad en su perfil.";
            }
        }
示例#2
0
        private Panel CreateItem(User user, int x, int y)
        {
            Panel temp = new Panel();

            temp.Location    = new Point(x, y);
            temp.BorderStyle = BorderStyle.None;
            temp.ClientSize  = new Size(1365 / 2, 187 / 2 - 10);

            PictureBox pic = new PictureBox();

            pic.SizeMode    = PictureBoxSizeMode.Zoom;
            pic.Location    = new Point(5, 0);
            pic.Size        = new Size(100, temp.Height);
            pic.BorderStyle = BorderStyle.None;
            pic.Image       = Image.FromFile(user.profilePicture.ToString());

            Label nameLbl = new Label();

            nameLbl.Location = new Point(pic.Width + 15, pic.Location.Y);
            nameLbl.Font     = new Font(nameLbl.Font.FontFamily, 12, FontStyle.Bold);
            nameLbl.AutoSize = true;
            nameLbl.Text     = $"{user.firstName} {user.lastName}";

            Label fixedLbl = new Label();

            fixedLbl.Location = new Point(pic.Width + 15, pic.Location.Y + 50);
            fixedLbl.Font     = new Font(fixedLbl.Font.FontFamily, 10);
            fixedLbl.Text     = "Amigos ";
            bool checkFriendship      = _proxy.CheckFriendship(this._userID, user.ID);
            bool checkInversedRequest = _proxy.CheckRequest(user.ID, this._userID);

            if (checkFriendship)
            {
                fixedLbl.Text += this._checkMark;
            }
            else
            {
                fixedLbl.Text += this._crossMark;
            }

            Button profileBtn = new Button();

            profileBtn.Text      = "Ver perfil";
            profileBtn.ForeColor = Color.White;
            profileBtn.BackColor = Color.FromArgb(1, 52, 107);
            profileBtn.Location  = new Point(fixedLbl.Location.X + 300, fixedLbl.Location.Y);
            profileBtn.FlatAppearance.BorderSize = 0;
            profileBtn.FlatStyle = FlatStyle.Flat;
            profileBtn.Name      = user.ID.ToString();
            profileBtn.Click    += new EventHandler(profileBtnClick);

            Button friendBtn = new Button();

            if (checkInversedRequest)
            {
                friendBtn.Text = "Cancelar solicitud";
            }
            else if (checkFriendship)
            {
                friendBtn.Text = "Eliminar amigo";
            }
            else
            {
                friendBtn.Text = "Añadir amigo";
            }
            friendBtn.ForeColor = Color.White;
            friendBtn.BackColor = Color.FromArgb(1, 52, 107);
            friendBtn.Location  = new Point(profileBtn.Location.X + profileBtn.Width + 50, profileBtn.Location.Y);
            friendBtn.FlatAppearance.BorderSize = 0;
            friendBtn.FlatStyle    = FlatStyle.Flat;
            friendBtn.AutoSizeMode = AutoSizeMode.GrowOnly;
            friendBtn.AutoSize     = true;
            friendBtn.Name         = user.ID.ToString();
            friendBtn.Click       += new EventHandler(friendBtnClick);

            temp.Controls.Add(pic);
            temp.Controls.Add(nameLbl);
            temp.Controls.Add(fixedLbl);
            temp.Controls.Add(profileBtn);
            temp.Controls.Add(friendBtn);

            return(temp);
        }