Пример #1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (bufferedPackets.Count == 0)
            {
                return;
            }

            timer.Enabled = false;

            List <MaplePacket> copy = bufferedPackets;

            bufferedPackets = new List <MaplePacket>(copy.Count);

            ListView.BeginUpdate();
            foreach (MaplePacket packet in copy)
            {
                ListView.AddPacket(packet);
            }
            ListView.EndUpdate();

            // This should be called after EndUpdate so VirtualListSize is set properly
            if (ListView.SelectedIndices.Count == 0 && FilteredPackets.Count > 0)
            {
                ListView.Items[FilteredPackets.Count - 1]?.EnsureVisible();
            }

            timer.Enabled = true;
        }
Пример #2
0
        public void RefreshPackets()
        {
            ListView.BeginUpdate();

            MaplePacket previous = ListView.SelectedIndices.Count > 0
                ? FilteredPackets[ListView.SelectedIndices[0]]
                : null;

            Opcodes.Clear();
            ListView.Clear();

            MainForm.DataForm.ClearHexBox();
            MainForm.StructureForm.Tree.Nodes.Clear();
            MainForm.PropertyForm.Properties.SelectedObject = null;

            if (!mViewOutboundMenu.Checked && !mViewInboundMenu.Checked)
            {
                return;
            }
            int previousIndex = -1;

            foreach (MaplePacket packet in mPackets)
            {
                if (packet.Outbound && !mViewOutboundMenu.Checked)
                {
                    continue;
                }
                if (!packet.Outbound && !mViewInboundMenu.Checked)
                {
                    continue;
                }
                if (!Opcodes.Exists(op => op.Outbound == packet.Outbound && op.Header == packet.Opcode))
                {
                    Opcodes.Add(new Opcode(packet.Outbound, packet.Opcode));
                }

                Definition definition = Config.Instance.GetDefinition(packet);
                if (definition != null && !mViewIgnoredMenu.Checked && definition.Ignore)
                {
                    continue;
                }

                int index = ListView.AddPacket(packet);
                if (packet == previous)
                {
                    previousIndex = index;
                }
            }

            MainForm.SearchForm.RefreshOpcodes(true);

            ListView.EndUpdate();

            // This should be called after EndUpdate so VirtualListSize is set properly
            if (previous != null && previousIndex >= 0)
            {
                ListView.Items[previousIndex].Selected = true;
                ListView.Items[previousIndex].EnsureVisible();
            }
        }
Пример #3
0
        private void AddPacket(MaplePacket packet, bool buffered = true, bool forceAdd = false)
        {
            mPackets.Add(packet);

            Definition definition =
                Config.Instance.GetDefinition(Build, Locale, packet.Outbound, packet.Opcode);

            if (!Opcodes.Exists(op => op.Outbound == packet.Outbound && op.Header == packet.Opcode))
            {
                Opcodes.Add(new Opcode(packet.Outbound, packet.Opcode));
            }

            if (!forceAdd)
            {
                if (definition != null && !mViewIgnoredMenu.Checked && definition.Ignore)
                {
                    return;
                }
                if (packet.Outbound && !mViewOutboundMenu.Checked)
                {
                    return;
                }
                if (!packet.Outbound && !mViewInboundMenu.Checked)
                {
                    return;
                }
            }

            if (buffered)
            {
                bufferedPackets.Add(packet);
            }
            else
            {
                ListView.AddPacket(packet);
            }
        }