/// <summary> /// Gets a barcode information as text. /// </summary> private string GetBarcodeInfo(int index, IBarcodeInfo info) { info.ShowNonDataFlagsInValue = true; string value = info.Value; if ((info.BarcodeType & BarcodeType.UPCE) != 0) { value += string.Format(" (UPC-E: {0})", (info as UPCEANInfo).UPCEValue); } if ((info.BarcodeType & BarcodeType.UPCA) != 0) { value += string.Format(" (UPC-A: {0})", (info as UPCEANInfo).UPCAValue); } string confidence; if (info.Confidence == ReaderSettings.ConfidenceNotAvailable) { confidence = "N/A"; } else { confidence = Math.Round(info.Confidence).ToString() + "%"; } string barcodeTypeValue; if (info is BarcodeSubsetInfo) { if (info is AamvaBarcodeInfo) { AamvaBarcodeValue aamvaValue = ((AamvaBarcodeInfo)info).AamvaValue; StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(string.Format("Issuer identification number: {0}", aamvaValue.Header.IssuerIdentificationNumber)); sb.AppendLine(string.Format("File type: {0}", aamvaValue.Header.FileType)); sb.AppendLine(string.Format("AAMVA Version number: {0} ({1})", aamvaValue.Header.VersionLevel, (int)aamvaValue.Header.VersionLevel)); sb.AppendLine(string.Format("Jurisdiction Version number: {0}", aamvaValue.Header.JurisdictionVersionNumber)); sb.AppendLine(); foreach (AamvaSubfile subfile in aamvaValue.Subfiles) { sb.AppendLine(string.Format("[{0}] subfile:", subfile.SubfileType)); foreach (AamvaDataElement dataElement in subfile.DataElements) { if (dataElement.Identifier.VersionLevel != AamvaVersionLevel.Undefined) { sb.Append(string.Format(" [{0}] {1}:", dataElement.Identifier.ID, dataElement.Identifier.Description)); } else { sb.Append(string.Format(" [{0}]:", dataElement.Identifier.ID)); } sb.AppendLine(string.Format(" {0}", dataElement.Value)); } } value = sb.ToString(); } else { value = string.Format("{0}{1}Base value: {2}", RemoveSpecialCharacters(value), Environment.NewLine, RemoveSpecialCharacters(((BarcodeSubsetInfo)info).BaseBarcodeInfo.Value)); } barcodeTypeValue = ((BarcodeSubsetInfo)info).BarcodeSubset.ToString(); } else { value = RemoveSpecialCharacters(value); barcodeTypeValue = info.BarcodeType.ToString(); } StringBuilder result = new StringBuilder(); result.AppendLine(string.Format("[{0}:{1}]", index + 1, barcodeTypeValue)); result.AppendLine(string.Format("Value: {0}", value)); result.AppendLine(string.Format("Confidence: {0}", confidence)); result.AppendLine(string.Format("Reading quality: {0}", info.ReadingQuality)); result.AppendLine(string.Format("Threshold: {0}", info.Threshold)); result.AppendLine(string.Format("Region: {0}", info.Region)); return(result.ToString()); }
/// <summary> /// Returns an encoded barcode value of specified barcode info. /// </summary> /// <param name="info">A barcode.</param> /// <param name="textEncodingName">A name of choosen text encoding.</param> /// <returns> /// Encoded barcode value. /// </returns> internal static string GetEncodedBarcodeValue(IBarcodeInfo info, string textEncodingName) { if (info is AamvaBarcodeInfo) { AamvaBarcodeValue aamvaValue = ((AamvaBarcodeInfo)info).AamvaValue; StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("Issuer identification number: {0}", aamvaValue.Header.IssuerIdentificationNumber)); foreach (AamvaSubfile subfile in aamvaValue.Subfiles) { foreach (AamvaDataElement dataElement in subfile.DataElements) { if (dataElement.Identifier.VersionLevel != AamvaVersionLevel.Undefined) { sb.AppendLine(string.Format("{0}={1} ({2})", dataElement.Identifier.ID, dataElement.Value, dataElement.Identifier.Description)); } else { sb.AppendLine(string.Format("{0}={1}", dataElement.Identifier.ID, dataElement.Value)); } } } return(sb.ToString()); } if (info is SwissQRCodeBarcodeInfo) { SwissQRCodeValueItem value = ((SwissQRCodeBarcodeInfo)info).DecodedValue; StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("Version: {0}", value.Version)); sb.AppendLine(string.Format("CodingType: {0}", value.CodingType)); if (!string.IsNullOrEmpty(value.IBAN)) { sb.AppendLine(string.Format("IBAN: {0}", value.IBAN)); } if (!string.IsNullOrEmpty(value.CreditorAddressType)) { sb.AppendLine(string.Format("Creditor address type: {0}", value.CreditorAddressType)); } if (!string.IsNullOrEmpty(value.CreditorName)) { sb.AppendLine(string.Format("Creditor name: {0}", value.CreditorName)); } if (!string.IsNullOrEmpty(value.CreditorStreetOrAddressLine1)) { sb.AppendLine(string.Format("Creditor street or address line 1: {0}", value.CreditorStreetOrAddressLine1)); } if (!string.IsNullOrEmpty(value.CreditorBuildingNumberOrAddressLine2)) { sb.AppendLine(string.Format("Creditor building number or address line 2: {0}", value.CreditorBuildingNumberOrAddressLine2)); } if (!string.IsNullOrEmpty(value.CreditorTown)) { sb.AppendLine(string.Format("Creditor town: {0}", value.CreditorTown)); } if (!string.IsNullOrEmpty(value.CreditorCountry)) { sb.AppendLine(string.Format("Creditor country: {0}", value.CreditorCountry)); } if (!string.IsNullOrEmpty(value.Amount)) { sb.AppendLine(string.Format("Amount: {0}", value.Amount)); } if (!string.IsNullOrEmpty(value.AmountCurrency)) { sb.AppendLine(string.Format("Amount currency: {0}", value.AmountCurrency)); } if (!string.IsNullOrEmpty(value.UltimateDebtorAddressType)) { sb.AppendLine(string.Format("Ultimate debtor address type: {0}", value.UltimateDebtorAddressType)); } if (!string.IsNullOrEmpty(value.UltimateDebtorName)) { sb.AppendLine(string.Format("Ultimate debtor name: {0}", value.UltimateDebtorName)); } if (!string.IsNullOrEmpty(value.UltimateDebtorStreetOrAddressLine1)) { sb.AppendLine(string.Format("Ultimate debtor street or address line 1: {0}", value.UltimateDebtorStreetOrAddressLine1)); } if (!string.IsNullOrEmpty(value.UltimateDebtorBuildingNumberOrAddressLine2)) { sb.AppendLine(string.Format("Ultimate debtor building number or address line 2: {0}", value.UltimateDebtorBuildingNumberOrAddressLine2)); } if (!string.IsNullOrEmpty(value.UltimateDebtorTown)) { sb.AppendLine(string.Format("Ultimate debtor town: {0}", value.UltimateDebtorTown)); } if (!string.IsNullOrEmpty(value.UltimateDebtorCountry)) { sb.AppendLine(string.Format("Ultimate debtor country: {0}", value.UltimateDebtorCountry)); } if (!string.IsNullOrEmpty(value.PaymentReferenceType)) { sb.AppendLine(string.Format("Payment reference type: {0}", value.PaymentReferenceType)); } if (!string.IsNullOrEmpty(value.PaymentReference)) { sb.AppendLine(string.Format("Payment reference: {0}", value.PaymentReference)); } if (!string.IsNullOrEmpty(value.UnstructuredMessage)) { sb.AppendLine(string.Format("Unstructured message: {0}", value.UnstructuredMessage)); } if (!string.IsNullOrEmpty(value.BillInformation)) { sb.AppendLine(string.Format("Bill information: {0}", value.BillInformation)); } if (!string.IsNullOrEmpty(value.AlternativeSchemeParameters1)) { sb.AppendLine(string.Format("Alternative scheme parameters 1: {0}", value.AlternativeSchemeParameters1)); } if (!string.IsNullOrEmpty(value.AlternativeSchemeParameters1)) { sb.AppendLine(string.Format("Alternative scheme parameters 2: {0}", value.AlternativeSchemeParameters2)); } return(sb.ToString()); } if (textEncodingName == "-1") { return(info.Value); } if (info is BarcodeSubsetInfo || info.BarcodeType == BarcodeType.Mailmark4StateC || info.BarcodeType == BarcodeType.Mailmark4StateL) { return(info.Value); } Encoding newEncoding = AvailableEncodings[textEncodingName].GetEncoding(); return(GetEncodedString(info.Value, newEncoding)); }