UI Control

You can draw 1D barcodes using GdPicture. The code snippet below draws a barcode in the area of a rectangle you select on the image:

/// <summary>
/// On the `mouseup` event on GdViewer, draw a 1D barcode.
/// </summary>
/// <param name=" eventSender ">The object the event has occurred on.
/// <param name=" eventArgs ">The event's data.
/// <remarks>
/// If no selection area was painted on the GdViewer, this event will do nothing.
/// </remarks>
public void Draw_Barcode(System.Object eventSender, System.EventArgs eventArgs)
{
    // Initializing variables to hold the position of the selection area on the document.
    int leftArea = 0;
    int topArea = 0;
    int widthArea = 0;
    int heightArea = 0;
    // Checking if a selection area has been painted on the GdViewer.
    if (GdViewer1.IsRect())
    {
        // Getting the location of the selection on the document.
        GdViewer1.GetRectCoordinatesOnDocument(ref leftArea, ref topArea, ref widthArea, ref heightArea);

        Barcode1DWriterType barcodeType = Barcode1DWriterType.Barcode1DWriterCode128;
        // Drawing the 1D barcode.
        GdPictureStatus status = oGdPictureImaging.Barcode1DWrite(imageId, barcodeType, "GdPicture 1D Barcode", leftArea, topArea, widthArea, heightArea, oGdPictureImaging.ARGB(255, 0, 0, 0));
        if (status != GdPictureStatus.OK)
        {
            MessageBox.Show("ERROR: " + status.ToString(), "Barcode Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        else
        {
            // Redrawing the whole image.
            GdViewer1.Redraw();
        }
    }
}
''' <summary>
''' On the `mouseup` event on GdViewer, draw a 1D barcode.
''' </summary>
''' <param name=" eventSender ">The object the event occurred on.
''' <param name=" eventArgs ">The event's data.
''' <remarks>
''' If no selection area was painted on the GdViewer, this event will do nothing.
''' </remarks>
Public Sub Draw_Barcode(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles GdViewer1.MouseUp
   'Initializing variables to hold the position of the selection area on the document.
   Dim leftArea As Integer, topArea As Integer, widthArea As Integer, heightArea As Integer
   'Checking if a selection area has been painted on the GdViewer.
   If GdViewer1.IsRect() Then
      'Getting the location of the selection on the document.
      GdViewer1.GetRectCoordinatesOnDocument(leftArea, topArea, widthArea, heightArea)

      Dim barcodeType As Barcode1DWriterType = Barcode1DWriterType.Barcode1DWriterCode128
      'Drawing the 1D barcode.
      Dim status As GdPictureStatus = oGdPictureImaging.Barcode1DWrite(imageId, barcodeType, "GdPicture 1D Barcode", leftArea, topArea, widthArea, heightArea, oGdPictureImaging.ARGB(255, 0, 0, 0))
      If status <> GdPictureStatus.OK Then
         MessageBox.Show("ERROR: " + status.ToString(), "Barcode Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
      Else
         'Redrawing the whole image.
         GdViewer1.Redraw()
      End If
   End If
End Sub