public void setRecord(int number, NtNfcLib.NdefRecord record, int totalNumber) { PivotItemTitle.Text = "Record " + number + "/" + totalNumber; AppendToSharingTextAsTitle("-- " + PivotItemTitle.Text + " --"); // NDEF header in binary var ndefHeaderSection = CreateNdefHeaderSection(AppResources.NDEFHeader, Convert.ToString(record.ndefHeader, 2).PadLeft(8, '0')); LayoutRoot.Children.Add(ndefHeaderSection); // id (if exist) var idSection = CreateSection(AppResources.ID, record.id); LayoutRoot.Children.Add(idSection); // Type name format string tnf = ""; switch (record.typeNameFormat) { case 0x0: tnf = "Empty"; break; case 0x1: tnf = "NFC Forum well-known type"; break; case 0x2: tnf = "MIME, Media-type (RFC 2046)"; break; case 0x3: tnf = "Absolute URI (RFC 3986)"; break; case 0x4: tnf = "NFC Forum external type"; break; case 0x5: tnf = "Unknown"; break; case 0x6: tnf = "Unchanged"; break; case 0x7: tnf = "Reserved"; break; } var tnfTitle = "0x0" + record.typeNameFormat.ToString("x") + " (" + tnf + ")"; var recordTypeSection = CreateSection(AppResources.TypeNameFormat, tnfTitle); LayoutRoot.Children.Add(recordTypeSection); // type var typeSection = CreateSection(AppResources.Type, record.type); LayoutRoot.Children.Add(typeSection); // payload as sony's camera's records if (record.SonyPayload.Count > 0) { var sonyPayloadSection = new Section(AppResources.SonyRecordTitle, record.SonyPayload) { Margin = new Thickness(0), }; sonyPayloadSection.Open(); LayoutRoot.Children.Add(sonyPayloadSection); AppendToSharingTextAsTitle(AppResources.SonyRecordTitle); foreach (string s in record.SonyPayload) { AppendToSharingText(s); } } // payload in ASCII var payloadSection = CreateSection(AppResources.Payload, record.payload); LayoutRoot.Children.Add(payloadSection); // hex payload var hexPayloadSection = new Section(AppResources.HexPayload, CreateHexAsciiStrigCorrection(record.RawPayload)) { Margin = new Thickness(0), FontFamily = new System.Windows.Media.FontFamily("Courier New"), FontSize = (double)Application.Current.Resources["PhoneFontSizeSmall"], }; hexPayloadSection.Close(); LayoutRoot.Children.Add(hexPayloadSection); AppendToSharingTextAsTitle(AppResources.HexPayload); foreach (string s in CreateHexAsciiStrigCorrection(record.RawPayload)) { AppendToSharingText(s); } }
public NdefPivotItem(int number, NtNfcLib.NdefRecord record, int totalNumber) { stringBuilder = new StringBuilder(); InitializeComponent(); setRecord(number, record, totalNumber); }