예제 #1
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var opcode = SearchBox.Text.Trim();

            if (string.IsNullOrEmpty(opcode) || opcode.Length <= 0 || opcode == "0")
            {
                _backupIndex = (PacketListView)PacketsListView.SelectedItem;
                LogReadFinished(_backupPackets);
                _packets = _backupPackets.ToList();
                _backupPackets.Clear();
                if (_backupIndex != null)
                {
                    PacketsListView.ScrollIntoView(_backupIndex);
                    PacketsListView.SelectedIndex = (int)_backupIndex.Index;
                    _backupIndex = null;
                }

                return;
            }

            if (opcode.Contains("0x"))
            {
                opcode = Parser.ParseLong(opcode).ToString();
            }

            if (_backupPackets.Count <= 0)
            {
                _backupPackets = _packets.ToList();
            }

            _packets.Clear();
            PacketsListView.Items.Clear();

            var list = new List <ListViewModel>();

            foreach (var packet in _backupPackets)
            {
                if (packet.PacketListView.Opcode == opcode)
                {
                    list.Add(packet);
                }
            }

            LogReadFinished(list);
        }
예제 #2
0
        private void _ApplyFilter(string filter)
        {
            _filterString = filter;

            if (_filterString == "")
            {
                _ResetFilter();
                return;
            }

            FilterSet[] filters = null;
            try
            {
                filters = Filter.Parse(_filterString);
            }
            catch (Exception exc)
            {
                new ExtendedErrorView("[XivMonTab] Filter Parse error!", exc.ToString(), "Error").ShowDialog();
                return;
            }

            _filters = filters;

            PacketListView.Items.Filter = new Predicate <object>((object item) =>
            {
                bool predResult = false;
                foreach (var filterEntry in _filters)
                {
                    predResult = filterEntry.IsApplicableForFilterSet((PacketEntry)item);

                    if (predResult)
                    {
                        return(predResult);
                    }
                }

                return(predResult);
            });

            PacketListView.Refresh();
            PacketListView.Items.Refresh();
        }
예제 #3
0
        private void _ApplyFilter(string filter)
        {
            filterString = filter;

            if (filterString == "")
            {
                _ResetFilter();
                return;
            }

            FilterSet[] filters = null;
            try
            {
                filters = Filter.Parse(filterString);
            }
            catch (Exception exc)
            {
                MessageBox.Show(
                    $"[Main] Filter Parse error!\n\n{exc}",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            PacketListView.Items.Filter = new Predicate <object>((object item) =>
            {
                bool predResult = false;
                foreach (var filterEntry in filters)
                {
                    predResult = filterEntry.IsApplicableForFilterSet((PacketListItem)item);

                    if (predResult)
                    {
                        return(predResult);
                    }
                }

                return(predResult);
            });

            PacketListView.Refresh();
            PacketListView.Items.Refresh();
        }
예제 #4
0
        private static ListViewModel FormatData(byte[] data, PacketOrigin origin, ushort port, uint index)
        {
            var packet = new ListViewModel();

            using (var ms = new MemoryStream(data))
            {
                using (var stream = new BinaryReader(ms))
                {
                    var size = stream.ReadUInt16();
                    stream.ReadInt32();
                    var opcode = stream.ReadUInt16();
                    // TODO - Remove later
                    if (opcode == 0x3006 || opcode == 0x30c2 || opcode == 0x30bf)
                    {
                        return(null);
                    }

                    var time     = stream.ReadUInt32();
                    var template = new PacketListView
                    {
                        Lenght = size,
                        Index  = index,
                        Time   = time.ToString(),
                        Opcode = $"{opcode:x2}",
                        Origin = origin,
                        Data   = data,
                        Port   = port,
                        Name   = ""
                    };
                    var parser     = new Parser(data, origin, port, opcode);
                    var packetName = "";
                    packet.PacketParseListView = parser.ParseData(ref packetName);
                    template.Name         = packetName;
                    packet.PacketListView = template;
                }
            }

            return(packet);
        }