private void PacketListView_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (PacketListView.SelectedIndex == -1) { return; } var item = (PacketEntry)PacketListView.Items[PacketListView.SelectedIndex]; var data = item.Data; if (Properties.Settings.Default.HideHexBoxActorId) { byte[] noIdData = new byte[data.Length]; Array.Copy(data, 0, noIdData, 0, 3); Array.Copy(data, 12, noIdData, 12, data.Length - 12); data = noIdData; } _currentPacketStream = new MemoryStream(data); try { HexEditor.Stream = _currentPacketStream; } catch (Exception exception) { new ExtendedErrorView("Failed to load packet.", exception.ToString(), "Error").ShowDialog(); } StructListView.Items.Clear(); try { string structText = null; structText = item.Direction == "S" ? _db.GetServerZoneStruct(int.Parse(item.Message, NumberStyles.HexNumber)) : _db.GetClientZoneStruct(int.Parse(item.Message, NumberStyles.HexNumber)); if (structText == null) { StructListItem infoItem = new StructListItem { NameCol = "No Struct found" }; StructListView.Items.Add(infoItem); return; } var structProvider = new Struct(); var structEntries = structProvider.Parse(structText, item.Data); var colours = Struct.TypeColours; int i = 0; // Highlight the IPC header lightly grey // HexEditor.HighlightBytes(0, 0x20, System.Drawing.Color.Black, System.Drawing.Color.LightGray); HexEditor.HighLightColor = System.Windows.Media.Brushes.LightGray; HexEditor.AddHighLight(0, 0x20); foreach (var entry in structEntries.Item1) { Color colour = Struct.TypeColours.ElementAt(i).Value; StructListView.Items.Add(entry); // HexEditor.HighlightBytes(entry.offset, entry.typeLength, System.Drawing.Color.Black, colour); HexEditor.HighLightColor = new SolidColorBrush(colour); HexEditor.AddHighLight(entry.offset, entry.typeLength); ++i; if (i == colours.Count) { i = 1; } } if (_mainWindow.ShowObjectMapCheckBox.IsChecked) { new ExtendedErrorView("Object map for " + item.Name, structEntries.Item2.Print(), "FFXIVMon Reborn").ShowDialog(); } } catch (Exception exc) { #if !DEBUG if (_erroredOpcodes.Contains(item.Message)) { #endif new ExtendedErrorView($"Struct error! Could not get struct for {item.Name} - {item.Message}", exc.ToString(), "Error").ShowDialog(); #if !DEBUG _erroredOpcodes.Add(item.Message); } #endif StructListItem infoItem = new StructListItem { NameCol = "Parsing failed" } ; StructListView.Items.Add(infoItem); return; } UpdateInfoLabel(); }