VintaSoft Barcode .NET SDK v10.0
Vintasoft.Barcode.BarcodeInfo Namespace / NonDataFlags Class
Members Example




In This Topic
    NonDataFlags Class
    In This Topic
    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.Drawing   
    Imports Vintasoft.Barcode   
    Imports Vintasoft.Barcode.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   
    		Using image As Image = WriteFlagUsingValueProperty(BarcodeType.Code128, "", NonDataFlags.Fnc1, "abc")   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.Code128)   
    		End Using   
    		' create image with Code128 barcode with FNC1 flag   
    		Using image As Image = WriteFlagUsingValueItemsProperty(BarcodeType.Code128, "123", NonDataFlags.Fnc1, "456")   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.Code128)   
    		End Using   
       
       
    		' 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   
    		Using image As Image = writer.GetBarcodeAsBitmap()   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.Code128)   
    		End Using   
       
       
    		' create image with DataMatrix barcode with FNC1 flag   
    		Using image As Image = WriteFlagUsingValueItemsProperty(BarcodeType.DataMatrix, "DataMatrix", NonDataFlags.Fnc1, "!")   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.DataMatrix)   
    		End Using   
       
    		' create image with QR barcode with ECI123456 flag   
    		Using image As Image = WriteFlagUsingValueProperty(BarcodeType.QR, "", NonDataFlags.CreateECICharacter(123456), "QR Test ECI123456")   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.QR)   
    		End Using   
       
    		' create image with DataMatrix barcode with Macro05 flag   
    		Using image As Image = WriteFlagUsingValueItemsProperty(BarcodeType.DataMatrix, "", NonDataFlags.Macro05, "BarcodeData")   
    			' read barcode from image   
    			ReadBarcode(image, BarcodeType.DataMatrix)   
    		End Using   
    	End Sub   
       
    	''' <summary>   
    	''' Writes a data flag to barcode using WriterSettings.Value property.   
    	''' </summary>   
    	Private Shared Function WriteFlagUsingValueProperty(barcodeType As BarcodeType, leftValuePart As String, flag As NonDataFlagValueItem, rightValuePart As String) As Image   
    		' 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.GetBarcodeAsBitmap()   
    	End Function   
       
    	''' <summary>   
    	''' Writes a data flag to barcode using WriterSettings.ValueItems property.   
    	''' </summary>   
    	Private Shared Function WriteFlagUsingValueItemsProperty(barcodeType As BarcodeType, leftValuePart As String, flag As NonDataFlagValueItem, rightValuePart As String) As Image   
    		' 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.GetBarcodeAsBitmap()   
    	End Function   
       
    	''' <summary>   
    	''' Reads a barcode and shows the recognized barcode value.   
    	''' </summary>   
    	Private Shared Sub ReadBarcode(image As Image, 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.Drawing;
    using Vintasoft.Barcode;
    using Vintasoft.Barcode.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
            using (Image image = WriteFlagUsingValueProperty(BarcodeType.Code128, "", NonDataFlags.Fnc1, "abc"))
            {
                // read barcode from image
                ReadBarcode(image, BarcodeType.Code128);
            }
            // create image with Code128 barcode with FNC1 flag
            using (Image 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
            using (Image image = writer.GetBarcodeAsBitmap())
            {
                // read barcode from image
                ReadBarcode(image, BarcodeType.Code128);
            }
                
                
            // create image with DataMatrix barcode with FNC1 flag
            using (Image image = WriteFlagUsingValueItemsProperty(
                BarcodeType.DataMatrix, "DataMatrix", NonDataFlags.Fnc1, "!"))
            {
                // read barcode from image
                ReadBarcode(image, BarcodeType.DataMatrix);
            }
                
            // create image with QR barcode with ECI123456 flag
            using (Image 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
            using (Image image = WriteFlagUsingValueItemsProperty(
                BarcodeType.DataMatrix, "", NonDataFlags.Macro05, "BarcodeData"))
            {
                // read barcode from image
                ReadBarcode(image, BarcodeType.DataMatrix);
            }
        }
                
        /// <summary>
        /// Writes a data flag to barcode using WriterSettings.Value property.
        /// </summary>
        static Image 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.GetBarcodeAsBitmap();
        }
                
        /// <summary>
        /// Writes a data flag to barcode using WriterSettings.ValueItems property.
        /// </summary>
        static Image 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.GetBarcodeAsBitmap();
        }
                
        /// <summary>
        /// Reads a barcode and shows the recognized barcode value.
        /// </summary>
        static void ReadBarcode(Image 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.Barcode.BarcodeInfo.NonDataFlags

    Requirements

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

    See Also