public void addComment(Comment comment) { CommentAndReplyPanel commentPanel = new CommentAndReplyPanel(comment); commentPanel.addFormToRefresh(this); commentPanels.Insert(0, commentPanel); // Insert at beginning postPanel.Controls.Add(commentPanel.Panel); }
public void addReply(Comment reply) { CommentAndReplyPanel replyPanel = new CommentAndReplyPanel(reply); replyPanel.addFormToRefresh(this); postPanel.Controls.Add(replyPanel.Panel); for (int i = 0; i < commentPanels.Count; ++i) { if (commentPanels[i].comment.ID == reply.ParentID) { commentPanels.Insert(i + 1, replyPanel); } } }
private void displayComments() { int offset = displayPost.PostPanel.Height; foreach (Comment comment in post) { CommentAndReplyPanel commentPanel = new CommentAndReplyPanel(comment); commentPanel.addFormToRefresh(this); commentPanels.Add(commentPanel); commentPanel.Panel.Location = new Point(0, offset); offset += commentPanel.Panel.Height; postPanel.Controls.Add(commentPanel.Panel); foreach (Comment reply in comment) { CommentAndReplyPanel replyPanel = new CommentAndReplyPanel(reply); replyPanel.addFormToRefresh(this); commentPanels.Add(replyPanel); replyPanel.Panel.Location = new Point(0, offset); offset += replyPanel.Panel.Height; postPanel.Controls.Add(replyPanel.Panel); } } }