Пример #1
0
        private void FindByName(object sender, RoutedEventArgs e)
        {
            if (Packets == null)
            {
                return;
            }

            string name = PacketNamesList.SelectedItem.ToString();

            for (int i = PacketsList.SelectedIndex + 1; i < Packets.Count; i++)
            {
                if (Packets[i].Name == name)
                {
                    PacketsList.SelectedIndex = i;
                    PacketsList.ScrollIntoView(PacketsList.SelectedItem);
                    return;
                }
            }

            if (MessageBox.Show("Find from start?", "Not found", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }

            for (int i = 0; i < PacketsList.SelectedIndex; i++)
            {
                if (Packets[i].Name == name)
                {
                    PacketsList.SelectedIndex = i;
                    PacketsList.ScrollIntoView(PacketsList.SelectedItem);
                    return;
                }
            }
        }
Пример #2
0
        private void FindByOpCode(object sender, RoutedEventArgs e)
        {
            if (Packets == null)
            {
                return;
            }

            string hex = OpCodeBox.Text.Replace(" ", "");

            for (int i = PacketsList.SelectedIndex + 1; i < Packets.Count; i++)
            {
                if (Packets[i].Hex.IndexOf(hex, 0, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    PacketsList.SelectedIndex = i;
                    PacketsList.ScrollIntoView(PacketsList.SelectedItem);
                    return;
                }
            }

            if (MessageBox.Show("Find from start?", "Not found", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }

            for (int i = 0; i < PacketsList.SelectedIndex; i++)
            {
                if (Packets[i].Hex.IndexOf(hex, 0, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    PacketsList.SelectedIndex = i;
                    PacketsList.ScrollIntoView(PacketsList.SelectedItem);
                    return;
                }
            }
        }
Пример #3
0
        public void AppendPacket(Color col, string itemText, Packet_old tmpPacket)
        {
            Dispatcher.BeginInvoke(
                new Action(
                    delegate
            {
                ListBoxItem item = new ListBoxItem
                {
                    Content    = itemText,
                    Background = new SolidColorBrush(col)
                };

                if (PacketsList.Items.Count == MaxPackets)
                {
                    PacketsList.Items.RemoveAt(0);
                    pp.Packets.RemoveAt(0);
                }

                if (boxCapture.IsChecked.Value)
                {
                    PacketsList.Items.Add(item);

                    if (boxAutoScroll.IsChecked.Value)
                    {
                        PacketsList.ScrollIntoView(item);
                    }

                    pp.Packets.Add(tmpPacket);
                }
            }));
        }