public SnifferView(TreeNode Node) { this.node = Node; this.sniffer = null; InitializeComponent(); }
public void Load(XmlDocument Xml, string FileName) { XmlElement E; DateTime Timestamp; Color ForegroundColor; Color BackgroundColor; string Message; byte[] Data; bool IsData; XSL.Validate(FileName, Xml, sniffRoot, sniffNamespace, schema); this.SnifferListView.Items.Clear(); foreach (XmlNode N in Xml.DocumentElement.ChildNodes) { E = N as XmlElement; if (E is null) { continue; } if (!Enum.TryParse <SniffItemType>(E.LocalName, out SniffItemType Type)) { continue; } Timestamp = XML.Attribute(E, "timestamp", DateTime.MinValue); switch (Type) { case SniffItemType.DataReceived: ForegroundColor = Colors.White; BackgroundColor = Colors.Navy; IsData = true; break; case SniffItemType.DataTransmitted: ForegroundColor = Colors.Black; BackgroundColor = Colors.White; IsData = true; break; case SniffItemType.TextReceived: ForegroundColor = Colors.White; BackgroundColor = Colors.Navy; IsData = false; break; case SniffItemType.TextTransmitted: ForegroundColor = Colors.Black; BackgroundColor = Colors.White; IsData = false; break; case SniffItemType.Information: ForegroundColor = Colors.Yellow; BackgroundColor = Colors.DarkGreen; IsData = false; break; case SniffItemType.Warning: ForegroundColor = Colors.Black; BackgroundColor = Colors.Yellow; IsData = false; break; case SniffItemType.Error: ForegroundColor = Colors.Yellow; BackgroundColor = Colors.Red; IsData = false; break; case SniffItemType.Exception: ForegroundColor = Colors.Yellow; BackgroundColor = Colors.DarkRed; IsData = false; break; default: continue; } if (IsData) { Data = Convert.FromBase64String(E.InnerText); Message = TabSniffer.HexToString(Data); } else { Data = null; Message = E.InnerText; } this.Add(new SniffItem(Timestamp, Type, Message, Data, ForegroundColor, BackgroundColor)); } }