private void LogPacket(byte[] packet, string from, string to) { if (LogPackets) { uxPacketList.Invoke(new EventHandler(delegate { CapturedPacket cp = new CapturedPacket(packet, from, packet.Length, to); packetList.Add(cp); string name = ""; if (cp.Source == "SERVER") { name = incomingPacketTypeNames.ContainsKey(cp.Type) ? incomingPacketTypeNames[cp.Type] : "UNKNOWN"; } if (cp.Source == "CLIENT") { name = outgoingPacketTypeNames.ContainsKey(cp.Type) ? outgoingPacketTypeNames[cp.Type] : "UNKNOWN"; } uxPacketList.Items.Add(new ListViewItem(new string[] { cp.Time, cp.Source, cp.Destination, cp.Length.ToString(), Convert.ToString(cp.Type, 16).PadLeft(2, '0').ToUpper(), name })); uxPacketList.EnsureVisible(uxPacketList.Items.Count - 1); })); } }
private void uxPacketList_SelectedIndexChanged(object sender, EventArgs e) { if (uxPacketList.SelectedIndices.Count > 0) { CapturedPacket cp = packetList[uxPacketList.SelectedIndices[0]]; displayedPacket = cp.Data; } else { displayedPacket = null; } DisplayPacket(); }
private void LogPacket(byte[] packet, string from, string to) { if (LogPackets) { uxPacketList.Invoke(new EventHandler(delegate { CapturedPacket cp = new CapturedPacket(packet, from, packet.Length, to); packetList.Add(cp); string name = ""; if (cp.Source == "SERVER") name = incomingPacketTypeNames.ContainsKey(cp.Type) ? incomingPacketTypeNames[cp.Type] : "UNKNOWN"; if (cp.Source == "CLIENT") name = outgoingPacketTypeNames.ContainsKey(cp.Type) ? outgoingPacketTypeNames[cp.Type] : "UNKNOWN"; uxPacketList.Items.Add(new ListViewItem(new string[]{ cp.Time, cp.Source, cp.Destination, cp.Length.ToString(), Convert.ToString(cp.Type, 16).PadLeft(2, '0').ToUpper(), name })); uxPacketList.EnsureVisible(uxPacketList.Items.Count - 1); })); } }