Code : Tout sélectionner
#include <GuiEdit.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#Include <GuiComboBoxEx.au3>
Opt('MustDeclareVars', 1)
;form
Global $Classement_zippo
;Input
Global $inp_left,$inp_right
;label
Global $lbl_left,$lbl_right,$lbl_date,$lbl_other
;bouton
Global $btn_go,$btn_model
;Combo
Global $cmb_other
;variables Globales
Global $model=1
Global $other_ini
HotKeySet("{ESC}", "Close") ;Permet de quitter lapplication avec la touche Echap
_Main()
Func Create_GUI()
;main form
$Classement_zippo = GUICreate("Classement Zippo", 300, 170, 400, 100)
;Input
$inp_left = GUICtrlCreateInput("",70,20,90,20)
$inp_right = GUICtrlCreateInput("",70,50,90,20)
;label
$lbl_left = GUICtrlCreateLabel("Gauche : ", 20,22)
$lbl_right = GUICtrlCreateLabel("Droite : ", 20,52)
$lbl_date = GUICtrlCreateLabel("Date : ", 20,95)
$lbl_other = GUICtrlCreateLabel("Autres : ", 20,125)
;bouton
$btn_go = GUICtrlCreateButton("Go !" , 180,15)
$btn_model = GUICtrlCreateButton("Petit",180,45,40,25)
;Combo
$cmb_other = GUICtrlCreateCombo("Autres Zippo", 60, 125, 235, 25)
GUICtrlSetOnEvent($btn_go,"Zippo")
GUICtrlSetOnEvent($btn_model,"Size")
GUICtrlSetOnEvent($cmb_other,"Combo_choose")
Opt("GUIOnEventMode", 1) ;Permet d'utiliser les évènement GUICtrlSetOnEvent
Load_Combo()
GUISetState(@SW_SHOW) ; Affiche la GUI
EndFunc
Func Zippo()
Local $left = _GUICtrlEdit_GetText($inp_left)
Local $right = _GUICtrlEdit_GetText($inp_right)
Local $test = ""
Local $i,$temp,$temp_2="",$month
Local $year
$test = StringRegExp($left, '[a-zA-Z]{1}', 1)
If @error = 0 Then
$temp=IniReadSection("C:\Users\localuser\Documents\Zippo.ini","Month")
Local $size_string = StringLen($right)
$year=1984
For $i=0 to 12
If $left = $temp[$i][0] Then
$month= $temp[$i][1]
EndIf
Next
For $i=1 to $size_string
$temp=StringMid($right,$i,1)
;
Switch $temp
Case "I"
$year += 1
Case "V"
If $temp_2 <> "I" Then
$year += 5
Else
$year += 3 ; Il faut bien retiré -2 car le I est compté une fois don sa fait +1
; or si on retire 1 a 5 sa fait 4 mais comme le +1 est compté sa donne 5
; il faut donc enlever 2 pour annulé le I et faire un 4(IV) et non pas un cinq (V)
EndIf
Case "X"
If $temp_2 <>"I" Then
$year += 10
Else
$year += 8
EndIf
Case "L"
If $temp_2 <> "I" Then
$year += 50
Else
$year += 48
EndIf
EndSwitch
$temp_2 = $temp
Next
$lbl_date = GUICtrlCreateLabel("Date : "& $month & " " & $year, 20,95)
EndIf
$test = StringRegExp($left, '[/\\°]{0,4}', 1)
If @error=0 Then
$temp=StringMid($right,1,1)
Switch $temp
case "°"
$year=(1966 - StringLen($left) - StringLen($right) - $model)
Case "/"
$year=(1982 - StringLen($left) - StringLen($right) )
Case "\"
$year=(1986 - StringLen($left) - StringLen($right) )
EndSwitch
EndIf
$lbl_date = GUICtrlCreateLabel("Date : " & $year , 20,95)
EndFunc
Func Load_Combo()
$other_ini = IniReadSection("C:\Users\localuser\Documents\Zippo.ini", "other")
_GUICtrlComboBox_ResetContent($cmb_other)
For $i=1 To UBound($other_ini)-1
_GUICtrlComboBox_AddString($cmb_other,$other_ini[$i][1])
Next
EndFunc
Func Combo_choose()
Local $test = _GUICtrlComboBox_GetEditText($cmb_other)
For $i=1 To UBound($other_ini)-1
If $test == $other_ini[$i][1] Then
$lbl_date = GUICtrlCreateLabel("Date : " & $other_ini[$i][0] , 20,95)
EndIf
Next
EndFunc
Func Size()
If _GUICtrlEdit_GetText($btn_model)="Petit" Then
GUICtrlSetData($btn_model,"Grand")
$model=0
ElseIf _GUICtrlEdit_GetText($btn_model)="Grand" Then
GUICtrlSetData($btn_model,"Petit")
$model=1
EndIf
EndFunc
Func Close()
Exit
EndFunc
Func _Main()
Create_GUI()
While True
Sleep(1000)
WEnd
EndFunc