'Class module
Sub Class_Globals
Public ABMComp As ABMCustomComponent
Private myValue As String
Public mySize As Double
Public myID As String
Public mBCType As String = "CODE39"
Public mHeight As Int = 40
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String, value As String, size As Double, bcType As String, height As Int)
ABMComp.Initialize("ABMComp", Me, InternalPage, ID, "")
myValue = value
mySize = size
mBCType = bcType
mHeight = height
End Sub
Sub ABMComp_Build(InternalPage As ABMPage, internalID As String) As String
Dim varID As String = internalID.Replace("-", "_")
myID = varID
Return $"<svg id="${varID}svg" class="barcode"></svg>"$
End Sub
' Is useful to run some initalisation script.
Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String)
If myValue = "" Then Return
Dim varID As String = internalID.Replace("-", "_")
Dim script As String = $"JsBarcode("#${varID}svg", "${myValue}", {
format: "${mBCType}",
textMargin: 0,
width: ${mySize},
background: "transparent",
displayValue: false,
height: ${mHeight},
fontSize: 15
});"$
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
' flush not needed, it's done in the refresh method in the lib
End Sub
' runs when a refresh is called
Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String)
Dim varID As String = internalID.Replace("-", "_")
Dim script As String
If myValue = "" Then
script = $"$('#${varID}svg').hide();"$
Else
script = $"JsBarcode("#${varID}svg", "${myValue}", {
format: "${mBCType}",
textMargin: 0,
width: ${mySize},
background: "transparent",
displayValue: false,
height: ${mHeight},
fontSize: 15
});
$('#${varID}svg').show()"$
End If
InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
End Sub
public Sub SetValue(InternalPage As ABMPage, value As String)
myValue = value
ABMComp_Refresh(InternalPage, myID)
InternalPage.ws.Flush
End Sub
' do the stuff needed when the object is removed
Sub ABMComp_CleanUp(InternalPage As ABMPage, internalID As String)
End Sub