Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
If FirstTime Then
Server.Initialize(9092, "Server")
Server.Listen
Log("MyIp = " & Server.GetMyIP)
TTS1.Initialize("TTS1")
End If
'txtproductid.Text=0x5011
'txtvendorid.Text=0x4016
Activity.LoadLayout("stampafattura")
imgsplashscreen.SetLayout(0%x,0%y,100%x,100%y)
wifi1.Initialize("wifi1")
wifi2.Initialize
mp1.Initialize
mp2.Initialize
pnlsetup.Visible=False
timer1.Initialize("timer1",1000)
timer2.Initialize("timer2",1000)
timer3.Initialize("timer3",3000)
timer4.Initialize("timer4",1500)
timer6.Initialize("timer6",2000)
lbla.SetLayout(0%x,1%y,18%x,38%y)
txttavolo.SetLayout(22%x,1%y,80%x,38%y)
lblb.SetLayout(0%x,41%y,18%x,38%y)
txttavolo2.SetLayout(22%x,41%y,80%x,38%y)
imgnext.SetLayout(1%x,80%y,45%x,18%y)
imgB1.SetLayout(52%X,80%Y,45%X,18%Y)
txtprintname.SetLayout(1%x,1%y,70%x,10%y)
btnsavename.SetLayout(72%x,1%y,26%x,10%y)
txtproductid.SetLayout(1%x,13%y,20%x,8%y)
btnsaveproductid.SetLayout(22%x,13%y,20%x,10%y)
txtvendorid.SetLayout(44%x,13%y,20%x,8%y)
btnsalvavendorid.SetLayout(73%x,13%y,20%x,10%y)
txtmyip.SetLayout(1%x,25%y,35%x,10%y)
btnsalvamyip.SetLayout(37%x,25%y,20%y,10%y)
txtintestazione.SetLayout(1%x,36%y,98%x,30%y)
btnsalvaintestazione.SetLayout(1%x,67%y,98%x,10%y)
pnlsetup.SetLayout(0%x,0%y,100%x,100%y)
btnchiudisetup.SetLayout(1%x,88%y,98%x,10%y)
txtintestazione.Color=Colors.White
txtvendorid.Color=Colors.White
txtproductid.Color=Colors.White
txtmyip.Color=Colors.White
txtprintname.Color=Colors.White
imgnext.Bitmap=(LoadBitmap(File.DirAssets,"stampaA.jpg"))
imgB1.Bitmap=(LoadBitmap(File.DirAssets,"stampaB.jpg"))
If File.Exists(File.DirInternal, "data.db") = False Then ' se non trova il database allora lo copia usando il rigo di sotto altrimenti non fa nulla.
File.Copy(File.DirAssets, "data.db", File.DirInternal, "data.db")
Else
End If
dbsql2.Initialize(File.DirInternal, "data.db", True) ' inizializza il database
productid
vendorid
'File.Delete(File.DirInternal,"data.db")
If txtvendorid.Text ="" And txtproductid.Text = "" Then
Msgbox("Attenzione devi inserire il product id e vendor id della stampante","ATTENZIONE!!!")
Return
Else
If usb1.UsbPresent(1) = usb1.USB_NONE Then ' Ver_2.4
Msgbox("Stampante non connessa al cavo usb","ATTENZIONE!!")
Return
End If
If (usb1.HasPermission(1)) Then ' Ver_2.4
Log(usb1.DeviceInfo(1))
'This is very important - ( VendorId, ProductId )
Dim Esadecimale As String = txtvendorid.Text
Esadecimale = Esadecimale.Replace("0x", "")
Log("Esad. : " & Esadecimale)
Dim Intero As Int = Bit.ParseInt(Esadecimale, 16)
Log("Intero: " & Intero)
Dim Esadecimale2 As String = txtproductid.Text
Esadecimale2 = Esadecimale2.Replace("0x", "")
Log("Esad. : " & Esadecimale2)
Dim Intero As Int = Bit.ParseInt(Esadecimale2, 16)
Log("Intero: " & Intero)
usb1.SetCustomDevice(usb1.DRIVER_SILABS, Esadecimale, Esadecimale2)
'usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x456,0x808)
Dim dev As Int
dev = usb1.Open(9600, 1) 'STMicroeletronics
If dev <> usb1.USB_NONE Then
Log("Connected successfully! 1")
Log("CONNECTED SUCCESSFULLY!!!")
connected = True
astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
'This is important
usb1.SetParameters(9600, usb1.DATABITS_8,usb1.STOPBITS_1, usb1.PARITY_EVEN)
'Here if you want codce that call print
Else
Log("Error opening USB port 1")
End If
Else
usb1.RequestPermission(1) ' Ver_2.4
End If
End If
INTESTAZIONE
nomestampante
myip
txtmyip.Text = wifi2.getIpAddress
'timer2.Enabled=True
switch=0
'______________________
End Sub