Code : Tout sélectionner
Enumeration
#Window_0
EndEnumeration
Enumeration
#Button_0
#ExplorerTree_0
#Listview_0
#Button_1
#String_0
#Text_0
#Text_1
#String_1
#ProgressBar_0
#CheckBox_0
#ProgressBar_1
#Button_3
#String_3
#Frame3D_0
#lExplorerTree_0
#lText_0
#lString_0
#lButton_0
#CheckBox_2
EndEnumeration
Declare initialisationini()
Global listviewcompte.l
Global extention.s = "*.*"
Global extentionarchive.s = "*.*"
Global kk.l=0
Global repertoiredestination.s = "c:\", repertoiredestinationcocher.l = 0
Global unrepertoireparfichier.l = 0
Global comptecliquer.l=0
Global valeurprogression.l=0 , valeurprogressiondepart.l=0
Global nomfichier.s
Global repertoire.s = "c:\"
Global Dim hlm.l(48)
Global idimagehlm.l=0
Procedure hlm02()
hlm(0 ) = 0
hlm(1 ) = 0
hlm(2 ) = 2
hlm(3 ) = 0
hlm(4 ) = 0
hlm(5 ) = 17
hlm(6 ) = 2
hlm(7 ) = 17
hlm(8 ) = 2
hlm(9 ) = 0
hlm(10 ) = 2
hlm(11 ) = 17
hlm(12 ) = 3
hlm(13 ) = 8
hlm(14 ) = 35
hlm(15 ) = 8
hlm(16 ) = 14
hlm(17 ) = 0
hlm(18 ) = 14
hlm(19 ) = 18
hlm(20 ) = 6
hlm(21 ) = 0
hlm(22 ) = 7
hlm(23 ) = 0
hlm(24 ) = 7
hlm(25 ) = 0
hlm(26 ) = 7
hlm(27 ) = 6
hlm(28 ) = 6
hlm(29 ) = 6
hlm(30 ) = 11
hlm(31 ) = 6
hlm(32 ) = 5
hlm(33 ) = 10
hlm(34 ) = 5
hlm(35 ) = 17
hlm(36 ) = 5
hlm(37 ) = 10
hlm(38 ) = 8
hlm(39 ) = 13
hlm(40 ) = 8
hlm(41 ) = 13
hlm(42 ) = 11
hlm(43 ) = 10
hlm(44 ) = 11
hlm(45 ) = 10
hlm(46 ) = 11
hlm(47 ) = 17
EndProcedure
Procedure CallbackForTest(file.s, PerCent.f)
d1.l=PerCent
SetGadgetState(#ProgressBar_1,d1)
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 0, 0, 625, 512, "H.L.M.", #PB_Window_SystemMenu | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ExplorerTreeGadget(#ExplorerTree_0, 0, 50, 230, 360, repertoire, #PB_Explorer_NoDriveRequester | #PB_Explorer_NoFiles | #PB_Explorer_NoMyDocuments)
ListViewGadget(#Listview_0, 240, 50, 370, 360,#PB_ListView_Multiselect)
StringGadget(#String_0, 430, 30, 40, 20, "*.*", #PB_String_LowerCase)
TextGadget(#Text_0, 340, 30, 90, 20, "Fichiers a afficher :", #PB_Text_Center)
TextGadget(#Text_1, 340, 410, 90, 20, "fichiers a extraire :")
StringGadget(#String_1, 430, 410, 40, 20, "*.*")
ProgressBarGadget(#ProgressBar_0, 300, 480, 220, 20, 0, 100)
CheckBoxGadget(#CheckBox_0, 0, 430, 210, 20, "rajouter nom du fichier comme repertoire")
ProgressBarGadget(#ProgressBar_1, 300, 460, 220, 20, 0, 100, #PB_ProgressBar_Smooth)
ButtonGadget(#Button_3, 260, 470, 20, 20, "...")
StringGadget(#String_3, 10, 470, 250, 20, "")
Frame3DGadget(#Frame3D_0, 0, 450, 290, 50, "Chemin d'extraction")
CheckBoxGadget(#CheckBox_2, 0, 410, 270, 20, "Creer 1 repertoire pour chaque fichier dans l'archive")
ButtonGadget(#Button_1, 520, 410, 100, 70, "Extraire")
EndIf
EndIf
EndProcedure
Procedure infozip(fichier.s)
rajoutdestination.s=""
If (repertoiredestinationcocher=1)
rajoutdestination=nomfichier
EndIf
myFileinfo.PureZIP_FileInfo
PureZIP_SetProgressionCallback(@CallbackForTest())
MyZIP.s = fichier
For i = 0 To PureZIP_GetFileCount(MyZIP) - 1 ; tourne jusqu'a fin fichier zip
plusrajoutrepertoire.s = ""
PureZIP_GetFileInfo(MyZIP,i , @myFileinfo)
nomfichier.s = LCase(myFileinfo\FileName)
longueurchaine.l = Len(extentionarchive)
resultatchaine.s = Right(extentionarchive,longueurchaine-1)
If (extentionarchive="*.*") Or (FindString(nomfichier,resultatchaine,1) >0)
If (unrepertoireparfichier=1)
plusrajoutrepertoire="\"+nomfichier
EndIf
PureZIP_ExtractFiles(fichier,extentionarchive,repertoiredestination+rajoutdestination+plusrajoutrepertoire,#True)
EndIf
SetGadgetState(#ProgressBar_0,valeurprogression + valeurprogressiondepart)
Next
valeurprogressiondepart=valeurprogressiondepart+ valeurprogression
EndProcedure
Procedure listrepertoire(nomrep.s)
kk=kk+1
If kk>1
ProcedureReturn
EndIf
Directory$ = nomrep
ClearGadgetItemList(#Listview_0)
If ExamineDirectory(0, Directory$, extention)
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
AddGadgetItem(#Listview_0,-1,DirectoryEntryName(0))
listviewcompte=listviewcompte+1
Wend
FinishDirectory(0)
EndIf
EndProcedure
Procedure extraction()
kk=kk+1
If kk>1
ProcedureReturn
EndIf
cheminrepertoire.s = GetGadgetText(#ExplorerTree_0)
For i.l = 0 To listviewcompte
If GetGadgetItemState(#Listview_0, i) = 1
nomfichier = GetGadgetItemText(#Listview_0,i,0)
infozip(cheminrepertoire + nomfichier)
EndIf
Next
EndProcedure
Procedure initialisationini()
CreateFile(0,"zippage.ini")
WriteStringN(0,extention )
WriteStringN(0,extentionarchive )
WriteStringN(0,repertoiredestination )
WriteStringN(0,repertoire )
EndProcedure
Procedure lectureini()
extention=ReadString(0)
extentionarchive=ReadString(0)
repertoiredestination=ReadString(0)
repertoire=ReadString(0)
EndProcedure
Procedure painturehlm()
If CreateImage(0, 37, 20)
If StartDrawing(ImageOutput(0))
Box (0,0,37,20,GetSysColor_(#COLOR_MENU))
For i=0 To 11
LineXY(hlm((i*4))+1,hlm((i*4)+1)+1,hlm((i*4)+2)+1,hlm((i*4)+3)+1,RGB(255,255,255))
LineXY(hlm((i*4)),hlm((i*4)+1),hlm((i*4)+2),hlm((i*4)+3),RGB(0,0,0))
Next
StopDrawing()
EndIf
EndIf
CreateGadgetList(WindowID(0))
idimagehlm=ImageGadget(0, WindowWidth(#Window_0)-39, WindowHeight(#Window_0)-22, 0, 0, ImageID(0))
EndProcedure
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
hlm02()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; lecture fichier ini ;;;;;;;;;;;;;;;;;;;;;
If ReadFile(0, "zippage.ini")
lectureini()
Else
initialisationini()
EndIf
CloseFile(0)
Open_Window_0()
painturehlm()
SetGadgetText(#String_0,extention)
SetGadgetText(#String_1,extentionarchive)
SetGadgetText(#String_3,repertoiredestination)
Repeat
event = WaitWindowEvent()
kk=0
If Event = #PB_Event_Gadget
Select EventGadget()
Case idimagehlm & #PB_EventType_LeftClick
RunProgram ("http://hlm02.com")
Case #ExplorerTree_0
repertoire = GetGadgetText(#ExplorerTree_0)
listviewcompte=0
listrepertoire(repertoire)
initialisationini()
;Debug repertoire
Case #String_0
extention=GetGadgetText(#String_0)
listrepertoire(repertoire)
initialisationini()
Case #String_1
extentionarchive=GetGadgetText(#String_1)
initialisationini()
Case #CheckBox_0
repertoiredestinationcocher=GetGadgetState(#CheckBox_0)
Case #CheckBox_2
unrepertoireparfichier=GetGadgetState(#CheckBox_2)
Case #Button_1
comptecliquer=0
valeurprogressiondepart=0
For i.l = 0 To listviewcompte
If GetGadgetItemState(#Listview_0, i)= #PB_ListIcon_Selected
comptecliquer=comptecliquer+1
EndIf
Next
If (comptecliquer>0)
valeurprogression = 100 / comptecliquer
EndIf
For i.l = 0 To listviewcompte
If GetGadgetItemState(#Listview_0, i)= #PB_ListIcon_Selected
extraction()
SetGadgetItemState(#Listview_0,i,0)
EndIf
Next
SetGadgetState(#ProgressBar_0,0) ;;;;; remets bar de progression a 0
SetGadgetState(#ProgressBar_1,0)
Case #Button_3
chemin.s = PathRequester("Choisissez un répertoire", repertoiredestination)
If chemin
repertoiredestination=chemin
SetGadgetText(#String_3,repertoiredestination)
initialisationini()
EndIf
EndSelect
EndIf
Until event=#PB_Event_CloseWindow
End
; IDE Options = PureBasic v4.02 (Windows - x86)
; CursorPosition = 225
; FirstLine = 47
; Folding = A9
; UseIcon = ..\..\..\bc5\titou\Hlm.ico
; Executable = zippage2.exe
integrer purezip pour que ca fonctionne.