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




In This Topic
    Code128ValueItem Class
    In This Topic
    Contains information about value of Code 128 or Code 16K barcode.
    Object Model
    Code128ValueItem Class
    Syntax
    'Declaration
     
    Public Class Code128ValueItem 
       Inherits TextValueItem
    'Usage
     
    Dim instance As Code128ValueItem
    public class Code128ValueItem : TextValueItem 
    public __gc class Code128ValueItem : public TextValueItem 
    public ref class Code128ValueItem : public TextValueItem 
    Example
    Imports System.Windows.Media.Imaging   
       
    Imports Vintasoft.WpfBarcode   
    Imports Vintasoft.WpfBarcode.BarcodeInfo   
       
    ''' <summary>   
    ''' Test that shows how to create an image with Code128 barcode with multiple value items.   
    ''' </summary>   
    Class Code128ValueItemExample   
       
    	''' <summary>   
    	''' Runs the test.   
    	''' </summary>   
    	Public Shared Sub TestWriteBCBModes()   
    		' create image with barcode   
    		Dim barcodeImage As BitmapSource = WriteBCBModes("ABC", "12345678", "1234ABC")   
       
    		' create the barcode reader   
    		Using reader As New BarcodeReader()   
    			' specify that reader must search for Code128 barcodes only   
    			reader.Settings.ScanBarcodeTypes = BarcodeType.Code128   
       
    			' read barcode from image   
    			Dim barcodeInfo As IBarcodeInfo = reader.ReadBarcodes(barcodeImage)(0)   
       
    			' print barcode value   
    			Console.WriteLine("Value = {0}", barcodeInfo.Value)   
    			' print value items   
    			Console.WriteLine("ValueItems:")   
    			For Each item As Code128ValueItem In barcodeInfo.ValueItems   
    				Console.WriteLine("[{0}] {1}", item.Mode, item.Value)   
    			Next   
    		End Using   
    	End Sub   
       
    	''' <summary>   
    	''' Writes the Code128 barcode in B, C, B modes.   
    	''' </summary>   
    	Public Shared Function WriteBCBModes(part1B As String, part2C As String, part3B As String) As BitmapSource   
    		' create value items   
       
    		Dim part1 As New Code128ValueItem(part1B, Code128EncodingMode.ModeB)   
    		Dim part2 As New Code128ValueItem(part2C, Code128EncodingMode.ModeC)   
    		Dim part3 As New Code128ValueItem(part3B, Code128EncodingMode.ModeB)   
       
    		' create the barcode writer   
    		Dim writer As New BarcodeWriter()   
       
    		' specify that writer must generate Code128 barcode   
    		writer.Settings.Barcode = BarcodeType.Code128   
       
    		' set value items   
    		writer.Settings.ValueItems = New ValueItemBase() {part1, part2, part3}   
       
    		' generate image with barcode   
    		Return writer.GetBarcodeAsBitmapSource()   
    	End Function   
       
    End Class
    using System;
    using System.Windows.Media.Imaging;
                
    using Vintasoft.WpfBarcode;
    using Vintasoft.WpfBarcode.BarcodeInfo;
                
    /// <summary>
    /// Test that shows how to create an image with Code128 barcode with multiple value items.
    /// </summary>
    class Code128ValueItemExample
    {
                
        /// <summary>
        /// Runs the test.
        /// </summary>
        public static void TestWriteBCBModes()
        {
            // create image with barcode
            BitmapSource barcodeImage = WriteBCBModes("ABC", "12345678", "1234ABC");
                
            // create the barcode reader
            using (BarcodeReader reader = new BarcodeReader())
            {
                // specify that reader must search for Code128 barcodes only
                reader.Settings.ScanBarcodeTypes = BarcodeType.Code128;
                
                // read barcode from image
                IBarcodeInfo barcodeInfo = reader.ReadBarcodes(barcodeImage)[0];
                
                // print barcode value
                Console.WriteLine("Value = {0}", barcodeInfo.Value);
                // print value items
                Console.WriteLine("ValueItems:");
                foreach (Code128ValueItem item in barcodeInfo.ValueItems)
                    Console.WriteLine("[{0}] {1}", item.Mode, item.Value);
            }
        }
                
        /// <summary>
        /// Writes the Code128 barcode in B, C, B modes.
        /// </summary>
        public static BitmapSource WriteBCBModes(string part1B, string part2C, string part3B)
        {
            // create value items
                
            Code128ValueItem part1 = new Code128ValueItem(part1B, Code128EncodingMode.ModeB);
            Code128ValueItem part2 = new Code128ValueItem(part2C, Code128EncodingMode.ModeC);
            Code128ValueItem part3 = new Code128ValueItem(part3B, Code128EncodingMode.ModeB);
                
            // create the barcode writer
            BarcodeWriter writer = new BarcodeWriter();
                
            // specify that writer must generate Code128 barcode
            writer.Settings.Barcode = BarcodeType.Code128;
                
            // set value items
            writer.Settings.ValueItems = new ValueItemBase[] { part1, part2, part3 };
                
            // generate image with barcode
            return writer.GetBarcodeAsBitmapSource();
        }
                
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.WpfBarcode.BarcodeInfo.ValueItemBase
          Vintasoft.WpfBarcode.BarcodeInfo.TextValueItem
             Vintasoft.WpfBarcode.BarcodeInfo.Code128ValueItem

    Requirements

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

    See Also