private void Form1_Load(object sender, EventArgs e) { names = new BindingListInvoked <Name>(dataGridView1); dataGridView1.DataSource = names; new Thread(() => names.Add(new Name() { FirstName = "Larry", LastName = "Lan" })).Start(); new Thread(() => names.Add(new Name() { FirstName = "Jessie", LastName = "Feng" })).Start(); }
public void AddIssues(params IssueItem[] items) { for (int i = 0; i < items.Length; i++) { IssueList.Add(items[i]); items[i].Checking += Item_Checking; items[i].Checked += Item_Checked; items[i].Fixing += Item_Fixing; items[i].Fixed += Item_Fixed; } }
public void AddIssues(params IssueItem[] items) { for (int i = 0; i < items.Length; i++) { IssueList.Add(items[i]); // Assign run order of the issue. items[i].OrderId = i; items[i].Checking += Item_Checking; items[i].Checked += Item_Checked; items[i].Fixing += Item_Fixing; items[i].Fixed += Item_Fixed; } }
public void PacketCaptured(object sender, GameEventArgs ev) { Packet p = ev.Packet; if (p.FailedMagic) { //if(p.RawDecompressedData != null) UpdateHeaderLog(p.IsSent + ": Failed Magic: " + ByteUtils.ByteArrayToString(p.RawDecompressedData)); heads.Add(p.Header); return; } if (p.Subpackets.Count == 0) { return; } if (p.Subpackets[0].SubpacketHeader.ZoneId > 0) { this.currentZone = p.Subpackets[0].SubpacketHeader.ZoneId; } if (p.isChatPacket) { chatSocket = p.Socket; } else if (p.Socket != chatSocket) { gameSocket = p.Socket; } if (p.Subpackets[0].SubpacketHeader.SourceId > 0 && p.IsSent) { this.characterId = p.Subpackets[0].SubpacketHeader.SourceId; } toolStripStatusLabel1.Text = "Zone: " + this.currentZone; toolStripStatusLabel2.Text = "Game Socket: " + gameSocket; toolStripStatusLabel3.Text = "Chat Socket: " + chatSocket; toolStripStatusLabel4.Text = "Char Id: " + characterId; /* * if(p.Subpackets.First().SubpacketId == 261) * { * if (p.Subpackets.First().PacketData is IEnumerable) * { * foreach(Object o in (List<Object>)p.Subpackets.First().PacketData){ * if(((Packet261.packet_subpacket_content_261)o).retainerId > 0) * UpdateHeaderLog(ByteUtils.StructToString(o)); * } * } * //UpdateHeaderLog()); * } */ Dictionary <Type, BindingList <Object> > activeDictionary = p.IsSent ? sentPackets : receivedPackets; TreeNode activeNode = p.IsSent ? sentNode : receivedNode; StringBuilder stringBuilder = new StringBuilder(""); if (p.IsSent) { stringBuilder.Append("SENT:"); } else { stringBuilder.Append("RECV:"); } foreach (Subpacket subPacket in p.Subpackets) { if (subPacket.SubpacketId == 0) { UpdateHeaderLog("Unkpacket" + subPacket.SubpacketHeader.Id + ": " + ByteUtils.ByteArrayToString(subPacket.RawPacketData)); } if (p.Subpackets.Count() == 1) { if (subPacket.SubpacketId == 320 || subPacket.SubpacketId == 321 || subPacket.SubpacketId == 322 || subPacket.SubpacketId == 323 || subPacket.SubpacketId == 324 || subPacket.SubpacketId == 325 || subPacket.SubpacketId == 101 || subPacket.SubpacketId == 402) { return; } } stringBuilder.Append(" Id: " + subPacket.SubpacketId.ToString() + " Token: " + subPacket.SubpacketHeader.Token.ToString() + " Size: " + subPacket.SubpacketHeader.Size.ToString() + ", "); if (subPacket.SubpacketId == 475 || subPacket.SubpacketId == 476) { UpdateHeaderLog("Examine " + subPacket.SubpacketHeader.Id + "(" + subPacket.RawPacketData.Length + ":" + subPacket.GetStructureSize() + ") : " + ByteUtils.ByteArrayToString(subPacket.RawPacketData)); } subheads.Add(subPacket.SubpacketHeader); if (p.IsSent) { //UpdateHeaderLog(subPacket.SubpacketId.ToString() + ": " + ByteUtils.ByteArrayToString(subPacket.RawPacketData)); } if (subPacket.SubpacketId == 0) { unknownPackets.Add(subPacket.PacketData); continue; } if (!activeDictionary.ContainsKey(subPacket.GetType())) { activeDictionary[subPacket.GetType()] = new BindingListInvoked <Object>(dataGridView1); treeView1.Invoke((MethodInvoker)(() => activeNode.Nodes.Add(subPacket.SubpacketId.ToString(), subPacket.GetType().Name).Tag = subPacket.GetType())); foreach (FieldInfo fi in subPacket.PacketData.GetType().GetFields()) { if (fi.FieldType.IsArray) { activeDictionary[fi.FieldType.GetElementType()] = new BindingListInvoked <Object>(dataGridView1); treeView1.Invoke((MethodInvoker)(() => activeNode.Nodes.Add(subPacket.SubpacketId.ToString() + " List", fi.FieldType.GetElementType().Name).Tag = fi.FieldType.GetElementType())); } } } if (subPacket.PacketData is IEnumerable) { foreach (Object o in (IEnumerable)subPacket.PacketData) { activeDictionary[subPacket.GetType()].Add(o); } } else { activeDictionary[subPacket.GetType()].Add(subPacket.PacketData); foreach (FieldInfo fi in subPacket.PacketData.GetType().GetFields()) { if (fi.FieldType.IsArray) { foreach (var g in (Array)fi.GetValue(subPacket.PacketData)) { activeDictionary[fi.FieldType.GetElementType()].Add(g); } } } } } if (p.IsSent) { //UpdateHeaderLog(stringBuilder.ToString()); } UpdateHeaderLog(stringBuilder.ToString()); }