#include <TreeViewConstants.au3>
#include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <File.au3>
Opt("GUIOnEventMode", 1)
$listFile = @ScriptDir&'\plugins.inf'
$files = _FileListToArray(@ScriptDir,'*.txt') ;читаем файлы в папке
If @error > 0 Then
MsgBox (0,'','Файлы/папки не найдены.')
Exit
EndIf
$sText = FileRead($listFile) ;Читаем файл
$aLines = StringSplit($sText, @CRLF, 1) ;Разбиваем текст на строки, строки помещаем в массив
GUICreate('',400,400)
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
$list = GUICtrlCreateTreeView(10,10,350,350,$TVS_CHECKBOXES)
For $i = 1 To $files[0] Step + 1
$a = GUICtrlCreateTreeViewItem($files[$i],$list)
For $c = 1 To $aLines[0] Step +1
If StringInStr($aLines[$c], $files[$i]) Then
GUICtrlSetState($a,$GUI_CHECKED)
EndIf
Next
Next
$SaveList = GUICtrlCreateButton('Save',360,10,35)
GUICtrlSetOnEvent($SaveList, "SaveList")
$CheckAll = GUICtrlCreateButton('All',360,40,35)
GUICtrlSetOnEvent($CheckAll, "CheckAll")
$CheckNone = GUICtrlCreateButton('None',360,70,35)
GUICtrlSetOnEvent($CheckNone, "CheckNone")
$CheckInvert = GUICtrlCreateButton('Invert',360,100,35)
GUICtrlSetOnEvent($CheckInvert, "CheckInvert")
GUISetState()
while 1
Sleep(100)
WEnd
Func SaveList()
FileSetAttrib($listFile,"-RASHNOT",1)
FileDelete($listFile)
$asa = _GUICtrlTreeView_GetFirstItem($list)
$itChecked = _GUICtrlTreeView_GetChecked($list,$asa)
$itName = _GUICtrlTreeView_GetText($list,$asa)
If $itChecked = 1 Then
FileWriteLine($listFile,$itName)
EndIf
for $i = 1 to _GUICtrlTreeView_GetCount($list)-1 Step + 1
$asa = _GUICtrlTreeView_GetNextSibling($list,$asa)
$itChecked = _GUICtrlTreeView_GetChecked($list,$asa)
$itName = _GUICtrlTreeView_GetText($list,$asa)
If $itChecked = 1 Then
FileWriteLine($listFile,$itName)
EndIf
Next
EndFunc
Func CheckAll()
$asa = _GUICtrlTreeView_GetFirstItem($list)
_GUICtrlTreeView_SetChecked($list,$asa,1)
for $i = 1 to _GUICtrlTreeView_GetCount($list)-1 Step + 1
$asa = _GUICtrlTreeView_GetNextSibling($list,$asa)
_GUICtrlTreeView_SetChecked($list,$asa,1)
Next
EndFunc
Func CheckNone()
$asa = _GUICtrlTreeView_GetFirstItem($list)
_GUICtrlTreeView_SetChecked($list,$asa,0)
for $i = 1 to _GUICtrlTreeView_GetCount($list)-1 Step + 1
$asa = _GUICtrlTreeView_GetNextSibling($list,$asa)
_GUICtrlTreeView_SetChecked($list,$asa,0)
Next
EndFunc
Func CheckInvert()
$asa = _GUICtrlTreeView_GetFirstItem($list)
$state = _GUICtrlTreeView_GetChecked($list,$asa)
If $state = 'True' Then
_GUICtrlTreeView_SetChecked($list,$asa,0)
Else
_GUICtrlTreeView_SetChecked($list,$asa)
EndIf
For $i = 1 to _GUICtrlTreeView_GetCount($list)-1 Step + 1
$asa = _GUICtrlTreeView_GetNextSibling($list,$asa)
$state = _GUICtrlTreeView_GetChecked($list,$asa)
If $state = 'True' Then
_GUICtrlTreeView_SetChecked($list,$asa,0)
Else
_GUICtrlTreeView_SetChecked($list,$asa)
EndIf
Next
EndFunc
Func OnExit()
If Not FileExists($listFile) Then
FileWrite($listFile,'')
EndIf
Exit
EndFunc