VintaSoft Barcode .NET SDK 16.0: Руководство для .NET разработчика
Vintasoft.Barcode.BarcodeStructure Namespace / LinearBarcodeStructure Class
Члены типа Объект Синтаксис Пример Иерархия Требования Смотрите также
В этом разделе
Класс LinearBarcodeStructure
В этом разделе
Сохраняет структуру линейного штрих-кода (Code 39, Code 128, EAN 13 и т. д.).
Объектная модель
LinearBarcodeStructure
Синтаксис
'Declaration

Public Class LinearBarcodeStructure
   Inherits BarcodeStructureBase

public class LinearBarcodeStructure : BarcodeStructureBase

Пример

Вот C#/VB.NET код, который демонстрирует, как получить информацию о ширине штрихов одномерного линейного штрих-кода и вывести информацию в консоль.

   
''' <summary>
''' Gets information about bar widths of 1D linear barcode and outputs information to the console.
''' </summary>
''' <param name="barcodeType">The barcode type.</param>
''' <param name="value">The barcode value.</param>
Public Shared Sub PrintLinearBarcodeBars(barcodeType As Vintasoft.Barcode.BarcodeType, value As String)   
    Dim barWidths As Integer() = GetLinearBarcodeBars(barcodeType, value)   
    For Each barWidth As Integer In barWidths   
        System.Console.Write(barWidth.ToString() & " ")   
    Next   
End Sub   
   
''' <summary>
''' Returns information about bar widths of 1D linear barcode.
''' </summary>
''' <param name="barcodeType">The barcode type.</param>
''' <param name="value">The barcode value.</param>
''' <returns>The array that contains bar widths.</returns>
Public Shared Function GetLinearBarcodeBars(barcodeType As Vintasoft.Barcode.BarcodeType, value As String) As Integer()   
    ' create barcode writer
    Using writer As New Vintasoft.Barcode.BarcodeWriter()   
        writer.Settings.Barcode = barcodeType   
        writer.Settings.Value = value   
   
        ' generate structure of 1D linear barcode
        Dim barcode As Vintasoft.Barcode.BarcodeStructure.LinearBarcodeStructure = DirectCast(writer.GetBarcodeStructure(), Vintasoft.Barcode.BarcodeStructure.LinearBarcodeStructure)   
   
        ' get information about bars of 1D linear barcode
        Dim bars As Vintasoft.Barcode.BarcodeStructure.BarcodeBarElement() = barcode.GetBars()   
   
        ' copy bar widths to an array
        Dim result As Integer() = New Integer(bars.Length - 1) {}   
        For i As Integer = 0 To bars.Length - 1   
            result(i) = bars(i).Width   
        Next   
        Return result   
    End Using   
End Function


/// <summary>
/// Gets information about bar widths of 1D linear barcode and outputs information to the console.
/// </summary>
/// <param name="barcodeType">The barcode type.</param>
/// <param name="value">The barcode value.</param>
public static void PrintLinearBarcodeBars(Vintasoft.Barcode.BarcodeType barcodeType, string value)
{
    int[] barWidths = GetLinearBarcodeBars(barcodeType, value);
    foreach (int barWidth in barWidths)
        System.Console.Write(barWidth.ToString() + " ");
}

/// <summary>
/// Returns information about bar widths of 1D linear barcode.
/// </summary>
/// <param name="barcodeType">The barcode type.</param>
/// <param name="value">The barcode value.</param>
/// <returns>The array that contains bar widths.</returns>
public static int[] GetLinearBarcodeBars(Vintasoft.Barcode.BarcodeType barcodeType, string value)
{
    // create barcode writer
    using (Vintasoft.Barcode.BarcodeWriter writer = new Vintasoft.Barcode.BarcodeWriter())
    {
        writer.Settings.Barcode = barcodeType;
        writer.Settings.Value = value;

        // generate structure of 1D linear barcode
        Vintasoft.Barcode.BarcodeStructure.LinearBarcodeStructure barcode = 
            (Vintasoft.Barcode.BarcodeStructure.LinearBarcodeStructure)writer.GetBarcodeStructure();
        
        // get information about bars of 1D linear barcode
        Vintasoft.Barcode.BarcodeStructure.BarcodeBarElement[] bars = barcode.GetBars();
        
        // copy bar widths to an array
        int[] result = new int[bars.Length];
        for (int i = 0; i < bars.Length; i++)
            result[i] = bars[i].Width;
        return result;
    }
}

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

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

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