VintaSoft Barcode .NET SDK 15.1: Руководство для .NET разработчика
Vintasoft.Barcode.BarcodeInfo Namespace / Code128ValueItem Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс Code128ValueItem
    В этом разделе
    Содержит информацию о значении штрих-кода Code 128 или Code 16K.
    Объектная модель
    Code128ValueItem
    Синтаксис
    'Declaration
    
    Public Class Code128ValueItem
       Inherits TextValueItem
    
    
    public class Code128ValueItem : TextValueItem
    
    
    public __gc class Code128ValueItem : public TextValueItem*
    
    
    public ref class Code128ValueItem : public TextValueItem^
    
    
    Пример

       
       
    Imports Vintasoft.Imaging   
       
    Imports Vintasoft.Barcode   
    Imports Vintasoft.Barcode.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
            Using barcodeImage As VintasoftBitmap = 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 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 VintasoftBitmap   
            ' 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
            Using 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.GetBarcodeAsVintasoftBitmap()   
            End Using   
        End Function   
       
    End Class
    
    
    
    using System;
    
    using Vintasoft.Imaging;
    
    using Vintasoft.Barcode;
    using Vintasoft.Barcode.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
            using (VintasoftBitmap 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 VintasoftBitmap 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
            using (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.GetBarcodeAsVintasoftBitmap();
            }
        }
    
    }
    
    

    Иерархия наследования

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

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также