#Region Project Attributes
#MainFormWidth: 1000
#MainFormHeight: 700
#AdditionalJar: sqlite-jdbc-3.7.2
#End Region
Sub Process_Globals
Private fx As JFX
Public MainForm As Form
Public lavagna As Pane
Public lineCanvas, ragnoCanvas As Canvas
Private scrolllavagna As ScrollPane
Private tools As ToolsLayout
Public groupValue As Boolean = False
Public listMaster, listSlave As List
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
MainForm.Title = "Lavagna"
MainForm.Resizable = False
lavagna.Initialize("lavagna")
lavagna.PrefHeight = 685
lavagna.PrefWidth = 6000
lavagna.Style="-fx-background-color:#2D2D30"
scrolllavagna.Initialize("scrolllavagna")
scrolllavagna.InnerNode = lavagna
scrolllavagna.PrefHeight = 700
scrolllavagna.PrefWidth = 3000
scrolllavagna.Pannable = False
scrolllavagna.HPosition=0
scrolllavagna.Style=lavagna.Style
MainForm.RootPane.AddNode(scrolllavagna,90,0,910,700)
tools.Initialize()
Dim img As Image
img.Initialize(File.DirAssets,"Menu-01.png")
Dim imgw As ImageView
imgw.Initialize("imgw")
imgw.SetImage(img)
MainForm.RootPane.AddNode(imgw,MainForm.WindowWidth-58,10,32,32)
listMaster.Initialize()
listSlave.Initialize()
gridcanvas
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
public Sub gridcanvas
lineCanvas = createCanvasGrid(lavagna, 0, 0, lavagna.PrefWidth, lavagna.PrefHeight, True)
ragnoCanvas = createCanvasGrid(lavagna, 0, 0, lavagna.PrefWidth, lavagna.PrefHeight, True)
End Sub
Sub createCanvasGrid(grid As Pane, x As Int, y As Int, width As Int, height As Int, sharp As Boolean) As Canvas
Dim cvs As Canvas
cvs.Initialize("")
grid.AddNode(cvs, x, y, width, height)
For x = 0 To width Step 10
Dim x1 As Double
If sharp Then x1 = x + 0.5 Else x1 = x
cvs.DrawLine(x1, 0, x1, height, fx.Colors.Black, 1.0)
Next
For y = 0 To height Step 10
Dim y1 As Double
If sharp Then y1 = y + 0.5 Else y1 = y
cvs.DrawLine(0, y1, width, y1, fx.Colors.Black, 1.0)
Next
Return cvs
End Sub
Public Sub group(grid As Pane, cvs As Canvas)
cvs.ClearRect(0,0,cvs.Width,cvs.Height)
Dim sharp As Boolean = True
For x = 0 To grid.PrefWidth Step 10
Dim x1 As Double
If sharp Then x1 = x + 0.5 Else x1 = x
cvs.DrawLine(x1, 0, x1, grid.PrefHeight, fx.Colors.Black, 1.0)
Next
For y = 0 To grid.PrefHeight Step 10
Dim y1 As Double
If sharp Then y1 = y + 0.5 Else y1 = y
cvs.DrawLine(0, y1, grid.PrefWidth, y1, fx.Colors.Black, 1.0)
Next
End Sub
Sub ragnoclear(grid As Pane, cvs As Canvas)
cvs.ClearRect(0,0,cvs.Width,cvs.Height)
End Sub
Sub ragnodraw(grid As Pane, cvs As Canvas)
cvs.ClearRect(0,0,cvs.Width,cvs.Height)
If groupValue = False Then Return
For i = 0 To lavagna.NumberOfNodes-1
If grid.GetNode(i) Is Button Then
Dim ls As List = grid.GetNode(i).Tag
If ls.Get(18) = "master" Then
cvs.DrawRect(grid.GetNode(i).Left-1,grid.GetNode(i).Top-1,grid.GetNode(i).PrefWidth+2,grid.getNode(i).PrefHeight+3,ls.Get(17), True,3)
listMaster.Add(ls)
Else
cvs.DrawRect(grid.GetNode(i).Left-1,grid.GetNode(i).Top-1,grid.GetNode(i).PrefWidth+2,grid.getNode(i).PrefHeight+3,ls.Get(17), True,1)
listSlave.Add(ls)
End If
End If
Next
Dim x,y,x2,y2 As Int
For i=0 To listMaster.Size-1
Dim lsM As List = listMaster.Get(i)
x = lsM.Get(0) +( lsM.Get(2)/2)
y = lsM.Get(1) +( lsM.Get(3)/2)
For ii=0 To listSlave.Size-1
Dim lsS As List = listSlave.Get(ii)
If lsS.Get(16) = lsM.Get(16) Then
x2=lsS.Get(0) + ( lsS.Get(2)/2)
y2=lsS.Get(1) + ( lsS.Get(3)/2)
cvs.DrawLine(x, y, x2, y2, lsS.Get(17),1)
End If
Next
Next
End Sub