Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic

Module LKPrint

    'You must to set dll file name for your system
    Public Const SEWOODIR As String = "P11CPCL.dll"

    <DllImport(SEWOODIR, EntryPoint:="OpenPort")> _
    Public Function OpenPort(ByVal PortName As String, ByVal BaudRate As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="ClosePort")> _
    Public Function ClosePort() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrinterCheck")> _
    Public Function PrinterCheck() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="status")> _
    Public Function status() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetForm")> _
    Public Function SetForm(ByVal HorizonOffset As String, ByVal XResol As Int32, ByVal YResol As Int32, ByVal LabelHeight As String, ByVal Quantity As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrintForm")> _
    Public Function PrintForm() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetMeasure")> _
    Public Function SetMeasure(ByVal Measure As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetJustification")> _
    Public Function SetJustification(ByVal Justify As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLPrintText")> _
    Public Function CPCLPrintText(ByVal Rotation As Int32, ByVal FontType As Int32, ByVal FontSize As Int32, ByVal PrintX As String, ByVal PrintY As String, ByVal Data As String, ByVal count As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetConcat")> _
    Public Function SetConcat(ByVal ConcatMode As Int32, ByVal PrintX As Int32, ByVal PrintY As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="ConcatText")> _
    Public Function ConcatText(ByVal FontType As Int32, ByVal FontSize As Int32, ByVal Offset As Int32, ByVal Data As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="ResetConcat")> _
    Public Function ResetConcat() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetMultiLine")> _
    Public Function SetMultiLine(ByVal LineHeight As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="MultiLineText")> _
    Public Function MultiLineText(ByVal Rotation As Int32, ByVal FontType As Int32, ByVal FontSize As Int32, ByVal PrintX As Int32, ByVal PrintY As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="MultiLineData")> _
    Public Function MultiLineData(ByVal Data As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="ResetMultiLine")> _
    Public Function ResetMultiLine() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetMagnify")> _
    Public Function SetMagnify(ByVal Width As Int32, ByVal Height As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="ResetMagnify")> _
    Public Function ResetMagnify() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetFormMode")> _
    Public Function SetFormMode() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetJournalMode")> _
    Public Function SetJournalMode() As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLPrintBarCode")> _
    Public Function CPCLPrintBarCode(ByVal Rotation As Int32, ByVal BarCodeType As Int32, ByVal NB As Int32, ByVal Ratio As Int32, ByVal BarHeight As Int32, ByVal PrintX As String, ByVal PrintY As String, ByVal Data As String, ByVal count As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrintBox")> _
    Public Function PrintBox(ByVal xs As Int32, ByVal ys As Int32, ByVal xx As Int32, ByVal yx As Int32, ByVal Thickness As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrintLine")> _
    Public Function PrintLine(ByVal xs As Int32, ByVal ys As Int32, ByVal xx As Int32, ByVal yx As Int32, ByVal Thickness As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="InverseLine")> _
    Public Function InverseLine(ByVal xs As Int32, ByVal ys As Int32, ByVal xx As Int32, ByVal yx As Int32, ByVal Thickness As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetPattern")> _
    Public Function SetPattern(ByVal PatternNum As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="PrintGraphic")> _
    Public Function PrintGraphic(ByVal BytesWidth As Int32, ByVal DotHeight As Int32, ByVal PrintX As Int32, ByVal PrintY As Int32, ByVal Data As Byte()) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetContrast")> _
    Public Function SetContrast(ByVal Darkness As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetPageWidth")> _
    Public Function SetPageWidth(ByVal PageWidth As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLPrintImage")> _
    Public Function CPCLPrintImage(ByVal ImageName As String, ByVal PrintX As String, ByVal PrintY As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetSpeed")> _
    Public Function SetSpeed(ByVal Speed As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="SetTone")> _
    Public Function SetTone(ByVal Tone As Int32) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLSetBarCode")> _
    Public Function CPCLSetBarCode(ByVal FontNum As Int32, ByVal FontSize As Int32, ByVal Offset As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCL2DPrintBarCode")> _
    Public Function CPCL2DPrintBarCode(ByVal Rotation As Int32, ByVal BarCodeType As Int32, ByVal PrintX As String, ByVal PrintY As String, ByVal UnitWidth As Int32, ByVal UnitHeight As Int32, ByVal Column As Int32, ByVal SecurityLevel As Int32, ByVal Data As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLPrintBitmap")> _
    Public Function CPCLPrintBitmap(ByVal ImageName As String, ByVal PrintX As String, ByVal PrintY As String) As Int32
    End Function

    <DllImport(SEWOODIR, EntryPoint:="CPCLPrintText2Image")> _
    Public Function CPCLPrintText2Image(ByVal Rotation As Int32, ByVal PrintX As String, ByVal PrintY As String, ByVal FontFace As String, ByVal FontStyle As Int32, ByVal FontSize As Int32, ByVal TextData As String, ByVal ReversePrint As Int32) As Int32
    End Function

    'Method return value
    Public Const LK_SUCCESS As Integer = 0
    Public Const LK_CREATE_ERROR As Integer = 1
    Public Const LK_NOT_OPENED As Integer = 2
    Public Const LK_FAIL As Integer = -1

    ' Printer Status flag
    Public Const LK_STS_NORMAL As Integer = 0
    Public Const LK_STS_BUSY As Integer = 1
    Public Const LK_STS_PAPER_EMPTY As Integer = 2
    Public Const LK_STS_COVER_OPEN As Integer = 4
    Public Const LK_STS_BATTERY_LOW As Integer = 8

    Public Const LK_CPCL_DOTS As Integer = 0
    Public Const LK_CPCL_MILLI As Integer = 1
    Public Const LK_CPCL_CENTI As Integer = 2
    Public Const LK_CPCL_INCH As Integer = 3

    ' Alignment Code
    Public Const LK_ALIGNMENT_LEFT As Integer = 0
    Public Const LK_ALIGNMENT_CENTER As Integer = 1
    Public Const LK_ALIGNMENT_RIGHT As Integer = 2

    ' Rotation
    Public Const LK_CPCL_NO_ROTATION As Integer = 0
    Public Const LK_CPCL_90_ROTATION As Integer = 1
    Public Const LK_CPCL_180_ROTATION As Integer = 2
    Public Const LK_CPCL_270_ROTATION As Integer = 3

    ' Concatenation
    Public Const LK_CPCL_CONCAT As Integer = 0
    Public Const LK_CPCL_VCONCAT As Integer = 1

    ' Magnification(Width)
    Public Const LK_CPCL_TXT_1WIDTH As Integer = 0
    Public Const LK_CPCL_TXT_2WIDTH As Integer = 1
    Public Const LK_CPCL_TXT_3WIDTH As Integer = 2
    Public Const LK_CPCL_TXT_4WIDTH As Integer = 3
    Public Const LK_CPCL_TXT_5WIDTH As Integer = 4
    Public Const LK_CPCL_TXT_6WIDTH As Integer = 5
    Public Const LK_CPCL_TXT_7WIDTH As Integer = 6
    Public Const LK_CPCL_TXT_8WIDTH As Integer = 7
    Public Const LK_CPCL_TXT_9WIDTH As Integer = 8
    Public Const LK_CPCL_TXT_10WIDTH As Integer = 9
    Public Const LK_CPCL_TXT_11WIDTH As Integer = 10
    Public Const LK_CPCL_TXT_12WIDTH As Integer = 11
    Public Const LK_CPCL_TXT_13WIDTH As Integer = 12
    Public Const LK_CPCL_TXT_14WIDTH As Integer = 13
    Public Const LK_CPCL_TXT_15WIDTH As Integer = 14
    Public Const LK_CPCL_TXT_16WIDTH As Integer = 15

    ' Magnification(Height)
    Public Const LK_CPCL_TXT_1HEIGHT As Integer = 0
    Public Const LK_CPCL_TXT_2HEIGHT As Integer = 1
    Public Const LK_CPCL_TXT_3HEIGHT As Integer = 2
    Public Const LK_CPCL_TXT_4HEIGHT As Integer = 3
    Public Const LK_CPCL_TXT_5HEIGHT As Integer = 4
    Public Const LK_CPCL_TXT_6HEIGHT As Integer = 5
    Public Const LK_CPCL_TXT_7HEIGHT As Integer = 6
    Public Const LK_CPCL_TXT_8HEIGHT As Integer = 7
    Public Const LK_CPCL_TXT_9HEIGHT As Integer = 8
    Public Const LK_CPCL_TXT_10HEIGHT As Integer = 9
    Public Const LK_CPCL_TXT_11HEIGHT As Integer = 10
    Public Const LK_CPCL_TXT_12HEIGHT As Integer = 11
    Public Const LK_CPCL_TXT_13HEIGHT As Integer = 12
    Public Const LK_CPCL_TXT_14HEIGHT As Integer = 13
    Public Const LK_CPCL_TXT_15HEIGHT As Integer = 14
    Public Const LK_CPCL_TXT_16HEIGHT As Integer = 15

    ' one-dimension barcode
    Public Const LK_CPCL_BCS_39 As Integer = 0
    Public Const LK_CPCL_BCS_39C As Integer = 1
    Public Const LK_CPCL_BCS_39F As Integer = 2
    Public Const LK_CPCL_BCS_39FC As Integer = 3
    Public Const LK_CPCL_BCS_93 As Integer = 4
    Public Const LK_CPCL_BCS_128 As Integer = 5
    Public Const LK_CPCL_BCS_EAN128 As Integer = 6
    Public Const LK_CPCL_BCS_CODABAR As Integer = 7
    Public Const LK_CPCL_BCS_CODABARC As Integer = 8
    Public Const LK_CPCL_BCS_EAN8 As Integer = 9
    Public Const LK_CPCL_BCS_EAN82 As Integer = 10
    Public Const LK_CPCL_BCS_EAN85 As Integer = 11
    Public Const LK_CPCL_BCS_EAN13 As Integer = 12
    Public Const LK_CPCL_BCS_EAN132 As Integer = 13
    Public Const LK_CPCL_BCS_EAN135 As Integer = 14
    Public Const LK_CPCL_BCS_I2OF5 As Integer = 15
    Public Const LK_CPCL_BCS_POSTNET As Integer = 16
    Public Const LK_CPCL_BCS_UPCA As Integer = 17
    Public Const LK_CPCL_BCS_UPCA2 As Integer = 18
    Public Const LK_CPCL_BCS_UPCA5 As Integer = 19
    Public Const LK_CPCL_BCS_UPCE As Integer = 20
    Public Const LK_CPCL_BCS_UPCE2 As Integer = 21
    Public Const LK_CPCL_BCS_UPCE5 As Integer = 22
    Public Const LK_CPCL_BCS_MSI As Integer = 23
    Public Const LK_CPCL_BCS_MSI1C As Integer = 24
    Public Const LK_CPCL_BCS_MSI2C As Integer = 25
    Public Const LK_CPCL_BCS_MSI11C As Integer = 26
    Public Const LK_CPCL_BCS_PLUS2 As Integer = 27
    Public Const LK_CPCL_BCS_PLUS5 As Integer = 28

    ' two-dimension barcode
    Public Const LK_CPCL_BCS_PDF417 As Integer = 0
    Public Const LK_CPCL_BCS_MAXICODE As Integer = 1

    ' Barcode Ratio.
    Public Const LK_CPCL_BCS_0RATIO As Integer = 1
    Public Const LK_CPCL_BCS_1RATIO As Integer = 2
    Public Const LK_CPCL_BCS_2RATIO As Integer = 3
    Public Const LK_CPCL_BCS_3RATIO As Integer = 4
    Public Const LK_CPCL_BCS_4RATIO As Integer = 5
    Public Const LK_CPCL_BCS_20RATIO As Integer = 6
    Public Const LK_CPCL_BCS_21RATIO As Integer = 7
    Public Const LK_CPCL_BCS_22RATIO As Integer = 8
    Public Const LK_CPCL_BCS_23RATIO As Integer = 9
    Public Const LK_CPCL_BCS_24RATIO As Integer = 10
    Public Const LK_CPCL_BCS_25RATIO As Integer = 11
    Public Const LK_CPCL_BCS_26RATIO As Integer = 12
    Public Const LK_CPCL_BCS_27RATIO As Integer = 13
    Public Const LK_CPCL_BCS_28RATIO As Integer = 14
    Public Const LK_CPCL_BCS_29RATIO As Integer = 15
    Public Const LK_CPCL_BCS_30RATIO As Integer = 16

    ' pattern.
    Public Const LK_CPCL_DEFAULT_PATTERN As Integer = 1
    Public Const LK_CPCL_HORIZON_PATTERN As Integer = 2
    Public Const LK_CPCL_VERTICAL_PATTERN As Integer = 3
    Public Const LK_CPCL_RDIAGON_PATTERN As Integer = 4
    Public Const LK_CPCL_LDIAGON_PATTERN As Integer = 5
    Public Const LK_CPCL_SQUARE_PATTERN As Integer = 6
    Public Const LK_CPCL_CROSS_PATTERN As Integer = 7

    ' contrast.
    Public Const LK_CPCL_CONT_DEFAULT As Integer = 0
    Public Const LK_CPCL_CONT_MEDIUM As Integer = 1
    Public Const LK_CPCL_CONT_DARK As Integer = 2
    Public Const LK_CPCL_CONT_VERY_DARK As Integer = 3

End Module
