private void Comments_AfterSelect(object sender, TreeViewEventArgs e)
{
if (disable_afterselect) return;
if (Comments.Nodes.Count == 0) return;
XPathNavigator comment = commentToUUID[Comments.SelectedNode].Item2;
CommentAuthor.Text = comment.SelectSingleNode("author").ToString();
CommentDate.Text = comment.SelectSingleNode("date").ToString();
var commentbody = comment.SelectSingleNode("body").ToString();
var commenttype = comment.SelectSingleNode("content-type").ToString();
if (commenttype.StartsWith("text/"))
{
if (CommentBodyView.TabPages[0] != CommentBodyViewHTML)
{
CommentBodyView.TabPages.Insert(0, CommentBodyViewRaw);
CommentBodyView.TabPages.Insert(0, CommentBodyViewHTML);
CommentBodyView.SelectedIndex = 0;
CommentEdit.Enabled = true;
}
}
DraggableIcon.Items[0].Text = commenttype;
DraggableIcon.Items[0].ImageIndex = 0;
switch (commenttype)
{
case "text/plain":
// Hack the text into HTML
commentbody = fixUp(commentbody);
break;
case "text/html":
break;
default:
if (CommentBodyView.TabPages[0] == CommentBodyViewHTML)
{
CommentBodyView.TabPages.Remove(CommentBodyViewHTML);
CommentBodyView.TabPages.Remove(CommentBodyViewRaw);
CommentEdit.Enabled = false;
}
if(commenttype.StartsWith("image"))
DraggableIcon.Items[0].ImageIndex = 1;
else if(commenttype.StartsWith("application/zip"))
DraggableIcon.Items[0].ImageIndex = 2;
break;
}
CommentBody.Document.Body.InnerHtml = commentbody;
}