#Region Project Attributes
#MainFormWidth: 300
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Dim aci As Short=0
Private MainForm As Form
Dim csvGauge, csvNeedle As Canvas
Dim bmpGauge, bmpNeedle As Image
Dim imvGauge, imvNeedle As ImageView
'Dim SRectGauge, DRectGauge, SRectNeedle, DRectNeedle As Rect
Private ImageView1 As ImageView
Private Button1 As Button
Private Label1 As Label
Private lbl2 As Label
Private Slider1 As Slider
Private my_font As Font
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("UNIFIED")
MainForm.RootPane.LoadLayout("ekran1") 'Load the layout file.
MainForm.Resizable=False
MainForm.BackColor=fx.Colors.Blue
MainForm.Show
MainForm.Title="Gauge Test Ahmet UCAN"
csvGauge.Initialize("cvs")
csvNeedle.Initialize("csv")
lbl2.Initialize("")
bmpGauge=fx.LoadImage(File.DirAssets,"led_base.png")
bmpNeedle=fx.LoadImage(File.DirAssets,"led_nedle.png")
Dim w,h As Double
w=bmpGauge.Width '+ 100
h=bmpGauge.Height'+100
MainForm.RootPane.AddNode(csvGauge, 10, 10, w,h)
MainForm.RootPane.AddNode(csvNeedle, 10, 10, bmpNeedle.Width,bmpNeedle.Height)
MainForm.RootPane.AddNode(lbl2,120,180,100,50)
csvGauge.DrawImage(bmpGauge,0dip,0dip,w,h)
aci=0
move_needle(0)
Label1.Text="0"
lbl2.Alpha=1
lbl2.TextColor=fx.Colors.Red
lbl2.Font=fx.CreateFont("",22,True,False)
lbl2.Text="---"
End Sub
Sub Button1_Action
'Dim x,y As Double
Dim deg As Short
If aci < 180 Then
aci=aci + 1
Else
aci=0
End If
deg=(-90)+ aci
move_needle(deg)
End Sub
Sub slider1_ValueChange (Value As Double)
Dim a,n As Int
n=Value
a=(-90)+n
move_needle(a)
lbl2.Text=n
End Sub
Sub move_needle(teta As Short)
Dim x,y As Double
x=Abs(csvGauge.Width - csvNeedle.Width)/2
y=Abs(csvGauge.Height - csvNeedle.Height)/2
csvNeedle.ClearRect(x,y,bmpNeedle.Width,bmpNeedle.Height)
Label1.Text=teta
csvNeedle.DrawImageRotated(bmpNeedle,x,y,bmpNeedle.Width,bmpNeedle.Height,teta)
End Sub