private async void LoadXmlBtn_OnClick(object sender, RoutedEventArgs e)
        {
            UnpackMrnBtn.IsEnabled = false;
            XmlTreeView.Items.Clear();

            var openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }

            FileLocationTxt1.Text = openFileDialog.FileName;
            if (FileLocationTxt1.Text.Trim() == string.Empty)
            {
                return;
            }
            Title = $"{_defaultTitle}::Loading XML file from \"{FileLocationTxt1.Text}\"";

            LoadXmlBtn.IsEnabled = false;

            _fragmentCollection.Clear();
            XmlFragments = await BuildXMLFragments(FileLocationTxt1.Text, _useRdmStrictMode)
                           .ConfigureAwait(false);

            if (XmlFragments == null)
            {
                Title = $"{_defaultTitle}";
                LoadXmlBtn.IsEnabled = true;
                return;
            }

            //try
            {
                _messageList = await DecodeMrn(XmlFragments);
            }
            //catch (Exception ex)
            // {
            //     MessageBox.Show(ex.Message);
            // }


            Application.Current.Dispatcher.Invoke(() =>
            {
                XmlFragmentGrid1.ItemsSource = _fragmentCollection;
                Title = $"{_defaultTitle} Found {_fragmentCollection.Count} XML Fragments";
                LoadXmlBtn.IsEnabled = true;
                UpdateDataGridFilterComboboxItems();
            });
        }
        private async Task <MrnMsgList> DecodeMrn(XmlFragmentList xmlFragments)
        {
            var messageList = new MrnMsgList();
            await Task.Run(async() =>
            {
                var decodeMrnResult = await MrnFragmentDecoder.DecodeMrnDataAsync(xmlFragments)
                                      .ConfigureAwait(false);
                if (!decodeMrnResult.Item1)
                {
                    MessageBox.Show(decodeMrnResult.Item3);
                    return(null);
                }

                messageList = decodeMrnResult.Item2;

                foreach (var data in xmlFragments.Fragments)
                {
                    var xmlFragment = new XMLFragmentsData
                    {
                        Index          = data.FragmentNumber,
                        RdmMessageType = data.RdmMessageType,
                        TimeStamp      = data.TimeStamp,
                        DomainType     = messageList.Get(data.FragmentNumber).DomainType,
                        MsgDirection   = data.MsgTypeRawXmlData != string.Empty
                            ? data.IsIncomingMsg ? "Incoming" : "Outgoing"
                            : string.Empty,
                        XmlRawData     = data.RawXmlData,
                        GUID           = string.Empty,
                        RequestKeyName = messageList.Get(data.FragmentNumber).RequestKeyName ?? string.Empty,
                        StreamId       = int.Parse(messageList.Get(data.FragmentNumber).GetFragmentAttribs()["streamId"])
                    };

                    if (messageList.Get(data.FragmentNumber).ContainsFieldList)
                    {
                        if (messageList.Get(data.FragmentNumber).GetFieldList().ContainsKey(4271))
                        {
                            if (!string.IsNullOrEmpty(messageList.Get(data.FragmentNumber).GetFieldList()[4271].Trim()))
                            {
                                var pBuffer =
                                    TraceStringToString(
                                        messageList.Get(data.FragmentNumber).GetFieldList()[4271].Trim());
                                xmlFragment.GUID = pBuffer;
                            }
                        }

                        if (messageList.Get(data.FragmentNumber).GetFieldList().ContainsKey(32479))
                        {
                            if (!string.IsNullOrEmpty(messageList.Get(data.FragmentNumber).GetFieldList()[32479].Trim())
                                )
                            {
                                var mrnFragmentNumber =
                                    HexStringToInt(messageList.Get(data.FragmentNumber).GetFieldList()[32479].Trim()) ??
                                    0;
                                xmlFragment.MrnFragmentNumber = mrnFragmentNumber;
                            }
                        }
                    }

                    Dispatcher.Invoke(() => { _fragmentCollection.Add(xmlFragment); });
                }

                return(messageList);
            });

            return(messageList);
        }