VintaSoft Barcode .NET SDK v10.0
NonDataFlags Class
Members  Example 




Vintasoft.WpfBarcode.BarcodeInfo Namespace : NonDataFlags Class
Contains available non-data flags.
Object Model
NonDataFlags ClassNonDataFlagValueItem ClassNonDataFlagValueItem ClassNonDataFlagValueItem ClassNonDataFlagValueItem ClassNonDataFlagValueItem ClassNonDataFlagValueItem ClassMacroCharacter ClassMacroCharacter ClassNonDataFlagValueItem ClassNonDataFlagValueItem Class
Syntax
'Declaration
 
Public NotInheritable Class NonDataFlags 
'Usage
 
Dim instance As NonDataFlags
public sealed class NonDataFlags 
public __gc __sealed class NonDataFlags 
public ref class NonDataFlags sealed 
Example
This example shows how to write and read non-data flags in barcode.
Imports System.Collections.Generic   
Imports System.Windows.Media.Imaging   
   
Imports Vintasoft.WpfBarcode   
Imports Vintasoft.WpfBarcode.BarcodeInfo   
   
''' <summary>   
''' Test that shows how to create barcodes with data flags.   
''' </summary>   
Class NonDataFlagsExample   
   
	''' <summary>   
	''' Runs the test.   
	''' </summary>   
	Public Shared Sub Test()   
		' create image with Code128 barcode with FNC1 flag   
		Dim image As BitmapSource = WriteFlagUsingValueProperty(BarcodeType.Code128, "", NonDataFlags.Fnc1, "abc")   
   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.Code128)   
   
		' create image with Code128 barcode with FNC1 flag   
		image = WriteFlagUsingValueItemsProperty(BarcodeType.Code128, "123", NonDataFlags.Fnc1, "456")   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.Code128)   
   
		' create the barcode value with multiple FNC1 flags   
		Dim barcodeValue As String = NonDataFlags.Fnc1.Name   
		barcodeValue += "A" + NonDataFlags.Fnc1.Name   
		barcodeValue += "B" + NonDataFlags.Fnc1.Name   
		barcodeValue += "C" + NonDataFlags.Fnc1.Name   
   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
		' specify that writer must generate Code128 barcode   
		writer.Settings.Barcode = BarcodeType.Code128   
		writer.Settings.ProcessSpecialSymbols = True   
		' set the barcode value   
		writer.Settings.Value = barcodeValue   
		' create image with Code128 barcode with  multiple FNC1 flags   
		image = writer.GetBarcodeAsBitmapSource()   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.Code128)   
   
		' create image with DataMatrix barcode with FNC1 flag   
		image = WriteFlagUsingValueItemsProperty(BarcodeType.DataMatrix, "DataMatrix", NonDataFlags.Fnc1, "!")   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.DataMatrix)   
   
		' create image with QR barcode with ECI123456 flag   
		image = WriteFlagUsingValueProperty(BarcodeType.QR, "", NonDataFlags.CreateECICharacter(123456), "QR Test ECI123456")   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.QR)   
   
		' create image with DataMatrix barcode with Macro05 flag   
		image = WriteFlagUsingValueItemsProperty(BarcodeType.DataMatrix, "", NonDataFlags.Macro05, "BarcodeData")   
		' read barcode from image   
		ReadBarcode(image, BarcodeType.DataMatrix)   
	End Sub   
   
	''' <summary>   
	''' Writes a data flag to a barcode using WriterSettings.Value property.   
	''' </summary>   
	Private Shared Function WriteFlagUsingValueProperty(barcodeType As BarcodeType, leftValuePart As String, flag As NonDataFlagValueItem, rightValuePart As String) As BitmapSource   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must generate barcode of specified type   
		writer.Settings.Barcode = barcodeType   
   
		' specify that writer must process special characters in the barcode value   
		writer.Settings.ProcessSpecialSymbols = True   
   
		' set the barcode value   
		writer.Settings.Value = leftValuePart & Convert.ToString(flag.Name) & rightValuePart   
   
		' create image with barcode   
		Return writer.GetBarcodeAsBitmapSource()   
	End Function   
   
	''' <summary>   
	''' Writes a data flag to a barcode using WriterSettings.ValueItems property.   
	''' </summary>   
	Private Shared Function WriteFlagUsingValueItemsProperty(barcodeType As BarcodeType, leftValuePart As String, flag As NonDataFlagValueItem, rightValuePart As String) As BitmapSource   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must generate barcode of specified type   
		writer.Settings.Barcode = barcodeType   
   
		' create the barcode value items   
   
		Dim items As New List(Of ValueItemBase)()   
		If leftValuePart <> "" Then   
			items.Add(New TextValueItem(leftValuePart))   
		End If   
		items.Add(flag)   
		If rightValuePart <> "" Then   
			items.Add(New TextValueItem(rightValuePart))   
		End If   
   
		' set the barcode value items   
		writer.Settings.ValueItems = items.ToArray()   
   
		' create image with barcode   
		Return writer.GetBarcodeAsBitmapSource()   
	End Function   
   
	''' <summary>   
	''' Reads barcode and shows the barcode value.   
	''' </summary>   
	Private Shared Sub ReadBarcode(image As BitmapSource, barcodeType As BarcodeType)   
		' create the barcode reader   
		Using reader As New BarcodeReader()   
			' specify that reader must search for barcodes of specified type   
			reader.Settings.ScanBarcodeTypes = barcodeType   
   
			' reader barcode from image   
			Dim barcodeInfo As IBarcodeInfo = reader.ReadBarcodes(image)(0)   
   
			barcodeInfo.ShowNonDataFlagsInValue = False   
			Console.WriteLine("Barcode value without flags: {0}", barcodeInfo.Value)   
   
			barcodeInfo.ShowNonDataFlagsInValue = True   
			Console.WriteLine("Barcode value with flags:    {0}", barcodeInfo.Value)   
   
			Console.WriteLine("Barcode value items:")   
			For i As Integer = 0 To barcodeInfo.ValueItems.Length - 1   
				Dim valueItem As ValueItemBase = barcodeInfo.ValueItems(i)   
				Console.WriteLine("  [{0}]: {1}", valueItem.[GetType]().Name, valueItem)   
			Next   
		End Using   
   
		Console.WriteLine()   
	End Sub   
End Class
using System;
using System.Collections.Generic;
using System.Windows.Media.Imaging;
            
using Vintasoft.WpfBarcode;
using Vintasoft.WpfBarcode.BarcodeInfo;
            
/// <summary>
/// Test that shows how to create barcodes with data flags.
/// </summary>
class NonDataFlagsExample
{
            
    /// <summary>
    /// Runs the test.
    /// </summary>
    public static void Test()
    {
        // create image with Code128 barcode with FNC1 flag
        BitmapSource image = WriteFlagUsingValueProperty(BarcodeType.Code128, "", NonDataFlags.Fnc1, "abc");
            
        // read barcode from image
        ReadBarcode(image, BarcodeType.Code128);
            
        // create image with Code128 barcode with FNC1 flag
        image = WriteFlagUsingValueItemsProperty(BarcodeType.Code128, "123", NonDataFlags.Fnc1, "456");
        // read barcode from image
        ReadBarcode(image, BarcodeType.Code128);
            
        // create the barcode value with multiple FNC1 flags
        string barcodeValue = NonDataFlags.Fnc1.Name;
        barcodeValue += "A" + NonDataFlags.Fnc1.Name;
        barcodeValue += "B" + NonDataFlags.Fnc1.Name;
        barcodeValue += "C" + NonDataFlags.Fnc1.Name;
            
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
        // specify that writer must generate Code128 barcode
        writer.Settings.Barcode = BarcodeType.Code128;
        writer.Settings.ProcessSpecialSymbols = true;
        // set the barcode value
        writer.Settings.Value = barcodeValue;
        // create image with Code128 barcode with  multiple FNC1 flags
        image = writer.GetBarcodeAsBitmapSource();
        // read barcode from image
        ReadBarcode(image, BarcodeType.Code128);
            
        // create image with DataMatrix barcode with FNC1 flag
        image = WriteFlagUsingValueItemsProperty(
            BarcodeType.DataMatrix, "DataMatrix", NonDataFlags.Fnc1, "!");
        // read barcode from image
        ReadBarcode(image, BarcodeType.DataMatrix);
            
        // create image with QR barcode with ECI123456 flag
        image = WriteFlagUsingValueProperty(
            BarcodeType.QR, "", NonDataFlags.CreateECICharacter(123456), "QR Test ECI123456");
        // read barcode from image
        ReadBarcode(image, BarcodeType.QR);
            
        // create image with DataMatrix barcode with Macro05 flag
        image = WriteFlagUsingValueItemsProperty(
            BarcodeType.DataMatrix, "", NonDataFlags.Macro05, "BarcodeData");
        // read barcode from image
        ReadBarcode(image, BarcodeType.DataMatrix);
    }
            
    /// <summary>
    /// Writes a data flag to a barcode using WriterSettings.Value property.
    /// </summary>
    static BitmapSource WriteFlagUsingValueProperty(
        BarcodeType barcodeType,
        string leftValuePart,
        NonDataFlagValueItem flag,
        string rightValuePart)
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must generate barcode of specified type
        writer.Settings.Barcode = barcodeType;
            
        // specify that writer must process special characters in the barcode value
        writer.Settings.ProcessSpecialSymbols = true;
            
        // set the barcode value
        writer.Settings.Value = leftValuePart + flag.Name + rightValuePart;
            
        // create image with barcode
        return writer.GetBarcodeAsBitmapSource();
    }
            
    /// <summary>
    /// Writes a data flag to a barcode using WriterSettings.ValueItems property.
    /// </summary>
    static BitmapSource WriteFlagUsingValueItemsProperty(
        BarcodeType barcodeType,
        string leftValuePart,
        NonDataFlagValueItem flag,
        string rightValuePart)
    {
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must generate barcode of specified type
        writer.Settings.Barcode = barcodeType;
            
        // create the barcode value items
            
        List<ValueItemBase> items = new List<ValueItemBase>();
        if (leftValuePart != "")
            items.Add(new TextValueItem(leftValuePart));
        items.Add(flag);
        if (rightValuePart != "")
            items.Add(new TextValueItem(rightValuePart));
            
        // set the barcode value items
        writer.Settings.ValueItems = items.ToArray();
            
        // create image with barcode
        return writer.GetBarcodeAsBitmapSource();
    }
            
    /// <summary>
    /// Reads barcode and shows the barcode value.
    /// </summary>
    static void ReadBarcode(BitmapSource image, BarcodeType barcodeType)
    {
        // create the barcode reader
        using (BarcodeReader reader = new BarcodeReader())
        {
            // specify that reader must search for barcodes of specified type
            reader.Settings.ScanBarcodeTypes = barcodeType;
            
            // reader barcode from image
            IBarcodeInfo barcodeInfo = reader.ReadBarcodes(image)[0];
            
            barcodeInfo.ShowNonDataFlagsInValue = false;
            Console.WriteLine("Barcode value without flags: {0}", barcodeInfo.Value);
            
            barcodeInfo.ShowNonDataFlagsInValue = true;
            Console.WriteLine("Barcode value with flags:    {0}", barcodeInfo.Value);
            
            Console.WriteLine("Barcode value items:");
            for (int i = 0; i < barcodeInfo.ValueItems.Length; i++)
            {
                ValueItemBase valueItem = barcodeInfo.ValueItems[i];
                Console.WriteLine("  [{0}]: {1}", valueItem.GetType().Name, valueItem);
            }
        }
            
        Console.WriteLine();
    }
}
Inheritance Hierarchy

System.Object
   Vintasoft.WpfBarcode.BarcodeInfo.NonDataFlags

Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

NonDataFlags Members
Vintasoft.WpfBarcode.BarcodeInfo Namespace
NonDataFlagValueItem Class
IBarcodeInfo.ShowNonDataFlagsInValue
WriterSettings.ProcessSpecialSymbols
EciCharacterValueItem Class
AztecStructuredAppendCharacter Class
DataMatrixStructuredAppendCharacter Class
PDF417StructuredAppendCharacter Class
QRStructuredAppendCharacter Class