#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIDataSeparatorChar", ",")
DirCreate(@ScriptDir & "\项目1")
DirCreate(@ScriptDir & "\项目2")
;IniWrite(@ScriptDir & "\项目1\Config.ini", "项目", "数据", "项目一测试1,项目一测试2,项目一测试3")
;IniWrite(@ScriptDir & "\项目2\Config.ini", "项目", "数据", "项目二测试4,项目二测试5,项目二测试6")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 610, 511)
$TreeView1 = GUICtrlCreateTreeView(16, 16, 161, 473, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem1 = GUICtrlCreateTreeViewItem("项目列表", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$FileList = _FileListToArray(@ScriptDir & "", "*", 2)
For $y = 1 To $FileList[0]
$Child = GUICtrlCreateTreeViewItem($FileList[$y], $generalitem1)
Next
$Label1 = GUICtrlCreateLabel("Label1", 256, 40, 108, 25)
$ListView1 = GUICtrlCreateListView("项目数据 ", 232, 80, 153, 281)
$Input1 = GUICtrlCreateInput("", 232, 376, 153, 21)
$Button1 = GUICtrlCreateButton("添加", 232, 416, 75, 25)
$Button2 = GUICtrlCreateButton("删除", 320, 416, 75, 25)
GUICtrlSetState($generalitem1, BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Child - $FileList[0] To $Child
If GUICtrlRead($nMsg, 1) = "项目列表" Then
GUICtrlSetData($Label1, "")
Else
GUICtrlSetData($Label1, GUICtrlRead($nMsg, 1))
$Single = IniRead(@ScriptDir & "" & GUICtrlRead($nMsg, 1) & "\Config.ini", "项目", "数据", "")
If $Single <> "" Then
$aDays = StringSplit($Single, ",")
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
For $a = 1 To $aDays[0]
GUICtrlCreateListViewItem($aDays[$a], $ListView1)
Next
EndIf
EndIf
Case $Button1
If GUICtrlRead($Input1, 0) = "" Then
MsgBox(16, "错误", "请输入要添加的数据。")
Else
GUICtrlCreateListViewItem(GUICtrlRead($Input1, 0), $ListView1)
EndIf
$Lab=GUICtrlRead($Label1)
FileDelete(@ScriptDir & "" & $Lab & "\Config.ini")
Local $cont = _GUICtrlListView_GetItemCount($ListView1);取得数组的行列数
Local $h1 = ""
For $id = 0 To $cont - 1
$str = _GUICtrlListView_GetItemTextArray($ListView1, $id)
$h1 &= $str[1] & ","
Next
Local $sString = StringTrimRight($h1, 1) ; 删除字符串右起 1个字符.
IniWrite(@ScriptDir & "" & $Lab & "\Config.ini", "项目", "数据", $sString)
Case $Button2
GUICtrlDelete(GUICtrlRead($ListView1))
MsgBox(64, "提示", "删除成功。")
$Lab=GUICtrlRead($Label1)
FileDelete(@ScriptDir & "" & $Lab & "\Config.ini")
Local $cont = _GUICtrlListView_GetItemCount($ListView1);取得数组的行列数
Local $h1 = ""
For $id = 0 To $cont - 1
$str = _GUICtrlListView_GetItemTextArray($ListView1, $id)
$h1 &= $str[1] & ","
Next
Local $sString = StringTrimRight($h1, 1) ; 删除字符串右起 1个字符.
IniWrite(@ScriptDir & "" & $Lab & "\Config.ini", "项目", "数据", $sString)
EndSwitch
WEnd