#Region Project Attributes
#MainFormWidth: 800
#MainFormHeight: 800
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private TreeTableView1 As TreeTableView
Private TTV_agac As TreeTableView
Private lblSelectedItem As Label
Private FolderImage As Image
Private btnItem As Button
Private btnListSelected As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
MainForm.RootPane.LoadLayout("1")
FolderImage = fx.LoadImage(File.DirAssets, "Folder.png")
AddFolder(TreeTableView1.Root, File.DirApp)
TreeTableView1.RowHeight = 50
TreeTableView1.SetColumnWidth(0, 180)
TreeTableView1.SetColumnWidth(1, 60)
TreeTableView1.SetColumnWidth(3, 180)
'SubExists("x","TEST")
IterateOverChildren(TreeTableView1.Root)
TTV_agac.Initialize("TTV_agac")
TTV_agac.SetSize(300,280)
TTV_agac.RowHeight=40
TTV_agac.Root.Initialize("",Array As String("1","2"))
MainForm.RootPane.AddNode(TTV_agac,0,0,100,280)
TTV_agac.Root.Children.Initialize
TTV_agac.Root.Children.AddAll(TreeTableView1.root.Children)
End Sub
Sub AddFolder(Parent As TreeTableItem, Folder As String)
For Each f As String In File.ListFiles(Folder)
Dim tti As TreeTableItem
Dim Name As String = f
Dim Size As String = $"$1.0{File.Size(Folder, f) / 1024} KB"$
Dim Date As String = $"$DateTime{File.LastModified(Folder, f)}"$
Dim p As Pane
p.Initialize("")
p.LoadLayout("ItemLayout")
tti.Initialize("tti", Array(Name, Size, Date, p))
btnItem.Tag = tti
Parent.Children.Add(tti)
If File.IsDirectory(Folder, f) Then
AddFolder(tti, File.Combine(Folder, f))
tti.Expanded = True
tti.Image = FolderImage
End If
Next
End Sub
Sub btnItem_Action
Dim b As Button = Sender
Dim tti As TreeTableItem = b.Tag
lblSelectedItem.Text = "Clicked on: " & FullNameFromItem(tti)
End Sub
Sub test
TreeTableView1.PrefWidth=(200)
End Sub
Sub btnListSelected_Click
TreeTableView1.PrefWidth=(200)
End Sub
Sub btnListSelected_Action
Log("Selected items:")
IterateOverChildren(TreeTableView1.Root)
End Sub
Sub IterateOverChildren(parent As TreeTableItem)
For Each tti As TreeTableItem In parent.Children
Dim p As Pane = tti.GetValue(3)
Dim chk As CheckBox = p.GetNode(0) 'first node
If chk.Checked Then
Log("Selected: " & FullNameFromItem(tti))
End If
If tti.Children.Size > 0 Then
IterateOverChildren(tti)
End If
Next
End Sub
Sub FullNameFromItem(tti As TreeTableItem) As String
Dim sb As StringBuilder
sb.Initialize
'combine the first column of this item and its parents
Do While tti.Root = False
If sb.Length > 0 Then
sb.Insert(0, "\")
End If
sb.Insert(0, tti.GetValue(0))
tti = tti.Parent
Loop
Return sb.ToString
End Sub
Sub TreeTableView1_SelectedItemChanged (SelectedItem As TreeTableItem)
'It will not be initialized when the selection is cleared
If SelectedItem.IsInitialized = False Then Return
lblSelectedItem.Text = FullNameFromItem(SelectedItem)
End Sub