*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="setariupdate.scx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS dataenvironment AS dataenvironment 
 	*< CLASSDATA: Baseclass="dataenvironment" Timestamp="" Scale="" Uniqueid="" ClassIcon="1" />

	*<PropValue>
		DataSource = .NULL.
		Height = 0
		Left = 0
		Name = "Dataenvironment"
		Top = 0
		Width = 0
	*</PropValue>

ENDDEFINE

DEFINE CLASS form1 AS form 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Commandgroup1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Combo1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command2" UniqueID="" Timestamp="" />

	*<PropValue>
		AutoCenter = .T.
		BorderStyle = 1
		Caption = "Setari update"
		DoCreate = .T.
		Height = 143
		MaxButton = .F.
		MinButton = .F.
		Name = "Form1"
		ShowInTaskBar = .T.
		ShowWindow = 1
		Width = 550
		WindowType = 1
	*</PropValue>

	ADD OBJECT 'Combo1' AS combobox WITH ;
		ControlSource = "", ;
		Height = 24, ;
		Left = 129, ;
		Name = "Combo1", ;
		RowSource = "", ;
		RowSourceType = 0, ;
		Style = 2, ;
		TabIndex = 2, ;
		Top = 65, ;
		Width = 290
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Command2' AS commandbutton WITH ;
		Caption = "...", ;
		Height = 23, ;
		Left = 425, ;
		Name = "Command2", ;
		TabIndex = 4, ;
		Top = 99, ;
		Width = 24
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Commandgroup1' AS commandgroup WITH ;
		ButtonCount = 0, ;
		Height = 123, ;
		Left = 12, ;
		Name = "Commandgroup1", ;
		TabIndex = 5, ;
		Top = 9, ;
		Value = 0, ;
		Width = 528
		*< END OBJECT: BaseClass="commandgroup" />

	ADD OBJECT 'Label3' AS label WITH ;
		AutoSize = .T., ;
		Caption = "Director temporar", ;
		Height = 17, ;
		Left = 26, ;
		Name = "Label3", ;
		TabIndex = 6, ;
		Top = 102, ;
		Width = 98
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label4' AS label WITH ;
		AutoSize = .T., ;
		Caption = "Adresa update", ;
		Height = 17, ;
		Left = 26, ;
		Name = "Label4", ;
		TabIndex = 7, ;
		Top = 36, ;
		Width = 82
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		AutoSize = .T., ;
		Caption = "Frecventa update", ;
		Height = 17, ;
		Left = 26, ;
		Name = "Label5", ;
		TabIndex = 8, ;
		Top = 69, ;
		Width = 96
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Text1' AS textbox WITH ;
		Height = 23, ;
		Left = 129, ;
		Name = "Text1", ;
		TabIndex = 3, ;
		Top = 99, ;
		Width = 289
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Text2' AS textbox WITH ;
		Height = 23, ;
		Left = 129, ;
		Name = "Text2", ;
		TabIndex = 1, ;
		Top = 33, ;
		Width = 384
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Init
		SET PROCEDURE TO wwapi.prg ADDITIVE 
		lcIniFileName = FORCEEXT(SYS(16,0), 'ini')
		&& populez combo-ul cu valorile default
		thisform.combo1.AddItem("La fiecare deschidere a programului", 1)   && val = -1
		thisform.combo1.AddItem("In fiecare zi", 2) 						&& val =  1
		thisform.combo1.AddItem("Niciodata", 3) 							&& val =  0
		
		&& iau datele din ini ca sa completez formularul
		
		loAPI = CREATEOBJECT("wwAPI")
		
		ldLastCheckDate = NVL(CTOD(loApi.GetProfileString(lcIniFileName, "Main", "LastVersionCheck")), {})
		
		thisform.text1.Value = NVL(ALLTRIM(loApi.GetProfileString(lcIniFileName, "Main", "DownloadPath")),"")
		thisform.text2.Value = NVL(ALLTRIM(loApi.GetProfileString(lcIniFileName, "Main", "VersionUpdateUrl")),"")
		lnFrecventa = VAL(loApi.GetProfileString(lcIniFileName, "Main", "UpdateFrequency"))
		DO CASE
			CASE lnFrecventa = -1
				thisform.combo1.ListIndex = 1
			CASE lnFrecventa = 1
				thisform.combo1.ListIndex = 2
			CASE lnFrecventa = 0
				thisform.combo1.ListIndex = 3
		ENDCASE 
	ENDPROC

	PROCEDURE Combo1.LostFocus
		&& la lost focus scriu in ini
		loAPI = CREATEOBJECT("wwAPI")
		lcIniFileName = FORCEEXT(SYS(16,0), 'ini')
		lnSelectat = this.ListIndex
		DO CASE
			CASE lnSelectat = 1
				loAPI.WriteProfileString(lcIniFileName, "Main", "UpdateFrequency", "-1")
			CASE lnSelectat = 2
				loAPI.WriteProfileString(lcIniFileName, "Main", "UpdateFrequency", "1")
			CASE lnSelectat = 3
				loAPI.WriteProfileString(lcIniFileName, "Main", "UpdateFrequency", "0")
		ENDCASE 
	ENDPROC

	PROCEDURE Command2.Click
		lcDirector = ALLTRIM(GETDIR("c:\","Alegeti directorul destinatie."))
		IF DIRECTORY(lcDirector)
			thisform.text1.Value = lcDirector
			thisform.text1.SetFocus()
		ENDIF
	ENDPROC

	PROCEDURE Text1.LostFocus
		&& la lostfocus scriu in ini
		lcDownloadPath = ADDBS(ALLTRIM(UPPER(this.Value)))
		IF EMPTY(lcDownloadPath)
			RETURN
		ENDIF
		loAPI = CREATEOBJECT("wwAPI")
		lcIniFileName = FORCEEXT(SYS(16,0), 'ini')
		IF !DIRECTORY(lcDownloadPath)
			md(lcDownloadPath)
		ENDIF
		loAPI.WriteProfileString(lcIniFileName, "Main", "DownloadPath", lcDownloadPath)
		
	ENDPROC

	PROCEDURE Text2.LostFocus
		&& la lost focus scriu in ini.
		lcURL = ALLTRIM(this.Value)
		IF EMPTY(lcURL)
			RETURN
		ENDIF 
		loAPI = CREATEOBJECT("wwAPI")
		lcIniFileName = FORCEEXT(SYS(16,0), 'ini')
		loAPI.WriteProfileString(lcIniFileName, "Main", "VersionUpdateUrl", lcURL)
	ENDPROC

ENDDEFINE
