private void ClearCommentsPanel() { List <Control> controls = new List <Control>(); foreach (Control control in CommentsPanel.Controls) { if (control.Name.StartsWith("CommentPanel")) { controls.Add(control); } } foreach (Control cont in controls) { CommentsPanel.Controls.Remove(cont); } CommentsPanel.Refresh(); }
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++; } }
void UpdateCommentsPanel() { CommentsPanel.DataSource = CommentsPanel_GetData(); CommentsPanel.DataBind(); }