private void InitComments() { foreach (Panel innerPanel in comments) { innerPanel.Dispose(); lastComment = null; } foreach (Comment comment in playList.Comments) { if (lastComment == null) { lastComment = ControlExtensions.Clone(CommentExemple); lastComment.Visible = true; lastComment.Name = "CommentPanel" + count; lastComment.BackColor = Color.FromArgb(89, 147, 180); PictureBox pb = new PictureBox(); InitUserPictureBox(pb, comment.Author); IconPictureBox icon2 = new IconPictureBox(); InitLikeIcon(icon2); IconPictureBox icon3 = new IconPictureBox(); InitReplyIcon(icon3); Label commentername = ControlExtensions.Clone(CommenterName); commentername.Text = comment.Author.Username + ":"; commentername.Visible = true; Label content = ControlExtensions.Clone(CommentContent); content.Text = comment.Content; content.Visible = true; Label date = ControlExtensions.Clone(CommentDate); date.Text = comment.Date; date.Visible = true; Label likes = ControlExtensions.Clone(CommentLikes); likes.Text = comment.Likes + ""; likes.Visible = true; lastComment.Controls.Add(pb); lastComment.Controls.Add(icon2); lastComment.Controls.Add(icon3); lastComment.Controls.Add(date); lastComment.Controls.Add(likes); lastComment.Controls.Add(content); lastComment.Controls.Add(commentername); CommentsPanel.Controls.Add(lastComment); comments.Add(lastComment); lastComment.Show(); CommentsPanel.Refresh(); } else { Panel panel = ControlExtensions.Clone(lastComment); panel.Name = "CommentPanel" + count; panel.Visible = true; panel.Location = new Point(panel.Location.X, panel.Location.Y + 70); panel.BackColor = Color.FromArgb(89, 147, 180); PictureBox pb = new PictureBox(); InitUserPictureBox(pb, comment.Author); IconPictureBox icon2 = new IconPictureBox(); InitLikeIcon(icon2); IconPictureBox icon3 = new IconPictureBox(); InitReplyIcon(icon3); Label commentername = ControlExtensions.Clone(CommenterName); commentername.Text = comment.Author.Name + ":"; commentername.Visible = true; Label content = ControlExtensions.Clone(CommentContent); content.Text = comment.Content; content.Visible = true; Label date = ControlExtensions.Clone(CommentDate); date.Text = comment.Date; date.Visible = true; Label likes = ControlExtensions.Clone(CommentLikes); likes.Text = comment.Likes + ""; likes.Visible = true; panel.Controls.Add(pb); panel.Controls.Add(icon2); panel.Controls.Add(icon3); panel.Controls.Add(date); panel.Controls.Add(likes); panel.Controls.Add(content); panel.Controls.Add(commentername); CommentsPanel.Controls.Add(lastComment); panel.Show(); CommentsPanel.Refresh(); comments.Add(lastComment); lastComment = panel; } count++; } }
private void PublishBtn_Click(object sender, EventArgs e) { if (lastActivity == null) { lastActivity = ControlExtensions.Clone(PanelPublication); lastActivity.Visible = true; lastActivity.Name = "New Publication"; PictureBox pb = ControlExtensions.Clone(Friend1Picture); pb.Image = app.User.Picture; pb.Visible = true; pb.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; pb.Cursor = Cursors.Hand; Label name = ControlExtensions.Clone(Friend1); name.Text = app.User.email; name.Visible = true; name.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; name.Cursor = Cursors.Hand; Label data = ControlExtensions.Clone(Date); data.Text = DateTime.Now.ToString("MM/dd/yyyy h:mm tt"); data.Visible = true; data.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; data.Cursor = Cursors.Hand; TextBox text = ControlExtensions.Clone(PubText); text.Text = ActivityTextBox.Text; text.Visible = true; ActivityTextBox.Text = ""; Panel newPanel6 = ControlExtensions.Clone(panel6); newPanel6.Visible = true; newPanel6.Name = app.User.email; newPanel6.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; newPanel6.Cursor = Cursors.Hand; Label likes = ControlExtensions.Clone(LikeBox); likes.Text = "0"; likes.Visible = true; Label redirect = ControlExtensions.Clone(RedirectBox); redirect.Text = "0"; redirect.Visible = true; Label replay = ControlExtensions.Clone(LikeBox); replay.Text = "0"; replay.Visible = true; IconPictureBox icon1 = new IconPictureBox(); InitLikeIcon(icon1); IconPictureBox icon2 = new IconPictureBox(); InitRedirectIcon(icon2); newPanel6.Controls.Add(pb); newPanel6.Controls.Add(name); lastActivity.Controls.Add(text); lastActivity.Controls.Add(icon1); lastActivity.Controls.Add(icon2); newPanel6.Controls.Add(data); lastActivity.Controls.Add(likes); lastActivity.Controls.Add(redirect); lastActivity.Controls.Add(replay); lastActivity.Controls.Add(newPanel6); lastActivity.Show(); activities.Add(lastActivity); ActivityPanel.Controls.Add(lastActivity); ActivityPanel.Refresh(); } else { Panel newPanel6 = ControlExtensions.Clone(panel6); newPanel6.Visible = true; newPanel6.Name = app.User.email; newPanel6.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; newPanel6.Cursor = Cursors.Hand; Panel newPub = ControlExtensions.Clone(PanelPublication); newPub.Visible = true; newPub.Name = "New Publication"; newPub.Location = new Point(lastActivity.Location.X, lastActivity.Location.Y + 160); PictureBox pb = ControlExtensions.Clone(Friend1Picture); pb.Image = app.User.Picture; pb.Visible = true; pb.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; pb.Cursor = Cursors.Hand; Label name = ControlExtensions.Clone(Friend1); name.Text = app.User.email; name.Visible = true; name.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; name.Cursor = Cursors.Hand; Label data = ControlExtensions.Clone(Date); data.Text = DateTime.Now.ToString("MM/dd/yyyy h:mm tt"); data.Visible = true; data.Click += delegate(object sender2, EventArgs e2) { Click(sender2, e2, app.User.email); }; data.Cursor = Cursors.Hand; TextBox text = ControlExtensions.Clone(PubText); text.Text = ActivityTextBox.Text; text.Visible = true; ActivityTextBox.Text = ""; Label likes = ControlExtensions.Clone(LikeBox); likes.Text = "0"; likes.Visible = true; Label redirect = ControlExtensions.Clone(LikeBox); redirect.Text = "0"; redirect.Visible = true; Label replay = ControlExtensions.Clone(LikeBox); replay.Text = "0"; replay.Visible = true; IconPictureBox icon1 = new IconPictureBox(); InitLikeIcon(icon1); IconPictureBox icon2 = new IconPictureBox(); InitRedirectIcon(icon2); newPanel6.Controls.Add(pb); newPanel6.Controls.Add(name); newPub.Controls.Add(text); newPub.Controls.Add(icon1); newPub.Controls.Add(icon2); newPanel6.Controls.Add(data); newPub.Controls.Add(likes); newPub.Controls.Add(redirect); newPub.Controls.Add(replay); newPub.Controls.Add(newPanel6); newPub.Show(); ActivityPanel.Controls.Add(newPub); ActivityPanel.Refresh(); lastActivity = newPub; } NoActivity.Visible = false; ActivityTextBox.Text = ""; }