; AutoHotkey v2 script - Catalogue Documentaire (minimal functional scaffold) #Requires AutoHotkey v2.0 global AppTitle := "Catalogue Documentaire (v2)" global DataFile := A_ScriptDir "\catalogue-data.txt" global ImagesDir := A_ScriptDir "\images" global ListsDir := A_ScriptDir "\lists" ; Data structures global Documents := [] ; Array of document objects (Map) global Gouvernements := [] global ClassesLot := [] global DocumentsKofax := [] ; GUI refs global MainGui := Gui(, AppTitle) global LV, Pic, PicName, SearchEdit, DDGov, DDClasse LoadLists() LoadData() CreateMainGui() MainGui.Show("w900 h600") return CreateMainGui() { global MainGui, LV, Pic, PicName, SearchEdit, DDGov, DDClasse MainGui.MarginX := 10, MainGui.MarginY := 10 MainGui.Add("Text",, "Recherche:") SearchEdit := MainGui.Add("Edit", "w300") SearchEdit.OnEvent("Change", ApplyFilters) MainGui.Add("Button", "x+m", "Effacer").OnEvent("Click", (*) => (SearchEdit.Value := "", ApplyFilters())) MainGui.Add("Text", "xm y+10", "Gouvernement:") DDGov := MainGui.Add("DropDownList", "w150", ["Tous"] + Gouvernements) DDGov.Value := 1 DDGov.OnEvent("Change", ApplyFilters) MainGui.Add("Text", "x+m", "Classe Lot:") DDClasse := MainGui.Add("DropDownList", "w150", ["Tous"] + ClassesLot) DDClasse.Value := 1 DDClasse.OnEvent("Change", ApplyFilters) LV := MainGui.Add("ListView", "xm y+10 w520 r20", ["ID","Titre","Tag","Modele","Classe Lot","Gouvernement","Document Kofax","Fichier"]) LV.OnEvent("ItemSelect", OnListSelect) MainGui.Add("Text", "x+10 yp", "Apercu de l'image") Pic := MainGui.Add("Picture", "x+10 y+5 w300 h350 Border") PicName := MainGui.Add("Text", "w300 Center") Pic.OnEvent("Click", ShowFullImage) ; Resize handler MainGui.OnEvent("Size", OnMainResize) PopulateListView(Documents) } OnMainResize(gui, minMax, w, h) { global LV, Pic, PicName if (minMax = -1) ; minimized return margin := 10 availW := w - margin*3 leftW := Floor(availW * 0.6) rightW := availW - leftW topY := 90 listH := h - topY - 40 if (listH < 120) listH := 120 LV.Move(margin, topY, leftW, listH) prevX := margin + leftW + margin Pic.Move(prevX, topY, rightW, listH - 40) PicName.Move(prevX, topY + listH - 35, rightW, 25) } ApplyFilters(*) { global Documents, SearchEdit, DDGov, DDClasse search := Trim(SearchEdit.Value) gov := DDGov.Text classe := DDClasse.Text filtered := [] for doc in Documents { if (gov != "Tous" && doc.Gouvernement != gov) continue if (classe != "Tous" && doc.ClasseLot != classe) continue if (search) { text := doc.Titre " " doc.Tag " " doc.Modele " " doc.ClasseLot " " doc.Gouvernement " " doc.DocumentKofax " " doc.Keywords if !InStr(text, search) continue } filtered.Push(doc) } PopulateListView(filtered) } PopulateListView(list) { global LV LV.Delete() for doc in list { LV.Add("", doc.Id, doc.Titre, doc.Tag, doc.Modele, doc.ClasseLot, doc.Gouvernement, doc.DocumentKofax, doc.Filename) } if (LV.GetCount() > 0) { LV.Modify(1, "Select Vis") } else { ShowPreview("") } } OnListSelect(ctrl, item, selected) { if (!selected) return global LV id := LV.GetText(item, 1) ShowPreviewById(id) } ShowPreviewById(id) { global Documents for doc in Documents { if (doc.Id = id) { ShowPreview(doc.Filename) return } } ShowPreview("") } ShowPreview(filename) { global Pic, PicName, ImagesDir if (!filename) { Pic.Value := "" PicName.Value := "" return } path := ImagesDir "\" filename if FileExist(path) { Pic.Value := path PicName.Value := filename } else { Pic.Value := "" PicName.Value := "" } } ShowFullImage(*) { global Pic if (!Pic.Value) return fg := Gui("+Resize +MaximizeBox +MinimizeBox", "Apercu") fg.Add("Picture",, Pic.Value) fg.Show("AutoSize") } LoadLists() { global ListsDir, Gouvernements, ClassesLot, DocumentsKofax Gouvernements := ReadList(ListsDir "\gouvernements.txt") ClassesLot := ReadList(ListsDir "\classes_lot.txt") DocumentsKofax := ReadList(ListsDir "\documents_kofax.txt") } ReadList(path) { list := [] if FileExist(path) { for line in StrSplit(FileRead(path, "UTF-8"), ["`r`n","`n","`r"]) { line := Trim(line) if (line) list.Push(line) } } return list } LoadData() { global DataFile, Documents Documents := [] if !FileExist(DataFile) return for line in StrSplit(FileRead(DataFile, "UTF-8"), ["`r`n","`n","`r"]) { if (!Trim(line)) continue parts := StrSplit(line, "|") if (parts.Length < 10) continue doc := Map() doc.Id := parts[1] doc.Titre := parts[2] doc.Tag := parts[3] doc.Modele := parts[4] doc.ClasseLot := parts[5] doc.DocumentKofax := parts[6] doc.Gouvernement := parts[7] doc.Directives := parts[8] doc.Keywords := parts[9] doc.Filename := parts[10] Documents.Push(doc) } }