private void dataGridView_SelectionChanged(object sender, EventArgs e) { richTextBox.Clear(); if (dataGridView.SelectedRows.Count < 1) { return; } DataGridViewRow row = dataGridView.SelectedRows[0]; if (row.Cells.Count <= 1) { return; } Event ev = dataGridView.SelectedRows[0].Cells[4].Value as Event; string prettyXml; XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.DarkBlueScheme); XmlUtils.PrettyPrint(ev.RawData, out prettyXml, highlighter); richTextBox.Text = prettyXml; highlighter.HighlightRichTextBox(richTextBox); }
private HTTPMessage ParseNode(TransactionNode httpNode, bool isRequest) { IPPacket pkt = httpNode.Slices[0].Packet; HTTPMessage msg = new HTTPMessage(httpNode.Index, pkt.Direction, pkt.Timestamp); if (isRequest) { msg.HeadlineText = String.Format("{0} {1} {2}", httpNode["Verb"], httpNode["Argument"], httpNode["Protocol"]); } else { msg.HeadlineText = String.Format("{0} {1}", httpNode["Protocol"], httpNode["Result"]); } TransactionNode headersNode = httpNode.FindChild("Headers", false); if (headersNode != null) { foreach (string name in headersNode.FieldNames) { msg.AddHeaderField(name, headersNode.Fields[name]); } } TransactionNode bodyNode = httpNode.FindChild("Body", false); if (bodyNode != null) { if (bodyNode.Fields.ContainsKey("XML")) { string body; XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.VisualizationScheme); XmlUtils.PrettyPrint((string)bodyNode["XML"], out body, highlighter); msg.BodyText = body; highlighter.HighlightRichTextBox(msg.BodyBox); } else if (bodyNode.Fields.ContainsKey("HTML")) { msg.BodyText = (string)bodyNode["HTML"]; } else if (bodyNode.Fields.ContainsKey("Raw")) { msg.SetBodyFromPreviewData((byte[])bodyNode.Fields["Raw"], 512); } else { msg.BodyText = String.Format("{0} unhandled", bodyNode.FieldNames[0]); } } return(msg); }
public void DisplayXML(string xmlData) { string prettyXml; XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.DarkBlueScheme); XmlUtils.PrettyPrint(xmlData, out prettyXml, highlighter); richTextBox.Text = prettyXml; highlighter.HighlightRichTextBox(richTextBox); }