#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Symbol.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <ProgressConstants.au3>
#include <Misc.au3>
Global $ProgramIni = @ProgramFilesDir&"\WinSec\WinSec.ini"
Global $ProgramDir = @ProgramFilesDir&"\WinSec"
If Not FileExists($ProgramDir) Then
DirCreate($ProgramDir)
_IniWrite()
EndIf
Global $FontColor=IniRead($ProgramIni,"Allgemein","FontColor","")
Global $FontSize=IniRead($ProgramIni,"Allgemein","FontSize","")
Global $FontType=IniRead($ProgramIni,"Allgemein","FontType","")
Global $BgColor=IniRead($ProgramIni,"Allgemein","BgColor","")
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 4)
$Form = GUICreate("WinSec", 338, 385)
GUISetBkColor(0x008080)
$Menu_WinSec = GUICtrlCreateMenu("WinSec")
$Menu_DateiVerpacken = GUICtrlCreateMenuItem("Datei Verpacken", $Menu_WinSec)
$Menu_DateiEntpacken = GUICtrlCreateMenuItem("Datei Entpacken", $Menu_WinSec)
GUICtrlCreateMenuItem("", $Menu_WinSec)
$Menu_Einstellungen = GUICtrlCreateMenuItem("Einstellungen", $Menu_WinSec)
GUICtrlCreateMenuItem("", $Menu_WinSec)
$Menu_Beenden = GUICtrlCreateMenuItem("Beenden", $Menu_WinSec)
GUICtrlCreateLabel("WinSec", 240, 312, 91, 29)
GUICtrlSetFont(-1, 16, 800, 2, "Verdana")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input_Verpacken_Dateipfad = GUICtrlCreateInput("", 16, 24, 265, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Button_Verpacken_DateipfadAuswaehlen = GUICtrlCreateButton("^", 288, 22, 35, 25)
GUICtrlSetFont(-1, 12, 800, 0, "Verdana")
$Input_Verpacken_Dateiname = GUICtrlCreateInput("", 144, 56, 177, 21)
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Input_Verpacken_Passwort = GUICtrlCreateInput("", 144, 88, 177, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Button_Verpacken_Verpacken = GUICtrlCreateButton("Verpacken", 240, 152, 83, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
GUICtrlCreateLabel("Dateiname:", 32, 58, 89, 20)
GUICtrlSetFont(-1, 10, 800, 2, "Verdana")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("Passwort:", 32, 90, 76, 20)
GUICtrlSetFont(-1, 10, 800, 2, "Verdana")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input_Verpacken_PasswortWiederholen = GUICtrlCreateInput("", 144, 120, 177, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlCreateLabel("Wiederholen:", 32, 122, 101, 20)
GUICtrlSetFont(-1, 10, 800, 2, "Verdana")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateGroup("Verpacken", 8, 8, 321, 177)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input_Entpacken_Dateipfad = GUICtrlCreateInput("", 16, 208, 265, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
$Button_Entpacken_DateipfadAuswaehlen = GUICtrlCreateButton("^", 288, 206, 35, 25)
GUICtrlSetFont(-1, 12, 800, 0, "Verdana")
$Input_Entpacken_Passwort = GUICtrlCreateInput("", 144, 240, 177, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
GUICtrlCreateLabel("Passwort:", 32, 242, 76, 20)
GUICtrlSetFont(-1, 10, 800, 2, "Verdana")
GUICtrlSetColor(-1, 0xFFFFFF)
$Button_Entpacken_Entpacken = GUICtrlCreateButton("Entpacken", 240, 272, 83, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
GUICtrlCreateGroup("Entpacken", 8, 192, 321, 113)
GUICtrlSetColor(-1, 0xFFFFFF)
$Button_Beenden = GUICtrlCreateButton("Beenden", 8, 312, 83, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
$StatusBar = _GUICtrlStatusBar_Create($Form)
$ContextMenu = GUICtrlCreateContextMenu()
$Con_DateiVerpacken = GUICtrlCreateMenuItem("Datei Verpacken",$ContextMenu)
$Con_DateiEntpacken = GUICtrlCreateMenuItem("Datei Entpacken",$ContextMenu)
GUICtrlCreateMenuItem("",$ContextMenu)
$Con_Einstellungen = GUICtrlCreateMenuItem("Einstellungen",$ContextMenu)
GUICtrlCreateMenuItem("",$ContextMenu)
$Con_Beenden = GUICtrlCreateMenuItem("Beenden",$ContextMenu)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
	Case $GUI_EVENT_CLOSE
		Exit
	Case $Button_Beenden
		Exit
	Case $Button_Verpacken_DateipfadAuswaehlen
		_Verpacken_DateipfadAuswaehlen()
	Case $Button_Entpacken_DateipfadAuswaehlen
		_Entpacken_DateipfadAuswaehlen()
	Case $Button_Entpacken_Entpacken
		_Entpacken()
	Case $Button_Verpacken_Verpacken
		_Verpacken()
	Case $Menu_Beenden
		Exit
	Case $Menu_DateiEntpacken
		_Entpacken_DateipfadAuswaehlen()
	Case $Menu_DateiVerpacken
		_Verpacken_DateipfadAuswaehlen()
	Case $Menu_Einstellungen
		_Einstellungen()
	Case $Con_DateiVerpacken
		_Verpacken_DateipfadAuswaehlen()
	Case $Con_DateiEntpacken
		_Entpacken_DateipfadAuswaehlen()
	Case $Con_Einstellungen
		_Einstellungen()
	Case $Con_Beenden
		Exit
EndSwitch
WEnd
Func _Verpacken_DateipfadAuswaehlen()
	$Pfad = FileSaveDialog( "WinSec","", "Textdateien (*.txt*)", 2)
	If @error Then
	Else
	GUICtrlSetData($Input_Verpacken_Dateipfad,$Pfad)
	EndIf
EndFunc
Func _Entpacken_DateipfadAuswaehlen()
	$Pfad = FileOpenDialog("WinSec", "", "WinSec Datei (*.sec*)", 1)
	If @error Then
	Else
	GUICtrlSetData($Input_Entpacken_Dateipfad,$Pfad)
	EndIf
EndFunc
Func _Entpacken()
	Global $ReadPfad = GUICtrlRead($Input_Entpacken_Dateipfad)
	$ReadPasswort = GUICtrlRead($Input_Entpacken_Passwort)
	If Not $ReadPfad = "" Then
	If Not $ReadPasswort = "" Then
	$File = FileOpen($ReadPfad,0)
	$FileRead = FileRead($File)
	FileClose($File)
	Global $ReadFile = _StringEncrypt(0,$FileRead,$ReadPasswort,2)
	GUISetState(@SW_HIDE,$Form)
	MsgBox(64,"WinSec","Die Datei wurde erfolgreich entpackt.")
	GUICtrlSetData($Input_Entpacken_Dateipfad,"")
	GUICtrlSetData($Input_Entpacken_Passwort,"")
	GUISetState(@SW_SHOW,$Form)
	_Anzeigen()
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
EndFunc
Func _Verpacken()
	$ReadPfad = GUICtrlRead($Input_Verpacken_Dateipfad)
	$ReadDateiname = GUICtrlRead($Input_Verpacken_Dateiname)
	$ReadPasswort = GUICtrlRead($Input_Verpacken_Passwort)
	$ReadWiderholung = GUICtrlRead($Input_Verpacken_PasswortWiederholen)
	If Not $ReadPfad = "" Then
	If Not $ReadDateiname = "" Then
	If Not $ReadPasswort = "" Then
	If Not $ReadWiderholung = "" Then
	If $ReadPasswort == $ReadWiderholung Then
	If FileExists($ReadDateiname&".sec") Then FileDelete($ReadDateiname&".sec")
	$File = FileOpen($ReadPfad,0)
	$FileRead = FileRead($File)
	FileClose($File)
	FileWrite($ReadDateiname&".sec",_StringEncrypt(1,$FileRead,$ReadPasswort,2))
	GUISetState(@SW_HIDE,$Form)
	MsgBox(64,"WinSec","Die Datei wurde erfolgreich verpackt.")
	GUICtrlSetData($Input_Verpacken_Dateipfad,"")
	GUICtrlSetData($Input_Verpacken_Dateiname,"")
	GUICtrlSetData($Input_Verpacken_Passwort,"")
	GUICtrlSetData($Input_Verpacken_PasswortWiederholen,"")
	GUISetState(@SW_SHOW,$Form)
	Else
	MsgBox(64,"WinSec","Die Passwörter überstimmen nicht ein.")
	EndIf
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
	Else
	MsgBox(64,"WinSec","Bitte füllen sie alle Felder aus.")
	EndIf
EndFunc
Func _Anzeigen()
	$Form3 = GUICreate("WinSec", 418, 378)
	GUISetBkColor(0x008080)
	$Button_Schliessen = GUICtrlCreateButton("Schließen", 336, 344, 75, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Edit = GUICtrlCreateEdit("", 8, 8, 401, 329)
	GUICtrlSetFont(-1, $FontSize, 800, 0, $FontType)
	GUICtrlSetColor(-1, $FontColor)
	GUICtrlSetBkColor(-1, $BgColor)
	GUICtrlCreateLabel("WinSec", 8, 344, 91, 29)
	GUICtrlSetFont(-1, 16, 800, 2, "Verdana")
	GUICtrlSetColor(-1, 0xFFFFFF)
	GUISetState(@SW_SHOW)
	WinSetTitle($Form3,"",StringRegExpReplace($ReadPfad,"^.*\\","") &" - WinSec")
	GUICtrlSetData($Edit,$ReadFile)
	While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			GUIDelete($Form3)
			ExitLoop
		Case $Button_Schliessen
			GUIDelete($Form3)
			ExitLoop
	EndSwitch
	WEnd
EndFunc
Func _Einstellungen()
	$Form2 = GUICreate("Einstellungen -  WinSec", 210, 322)
	GUISetBkColor(0x008080)
	$Button_Homepage = GUICtrlCreateButton("Homepage", 8, 96, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Info = GUICtrlCreateButton("Info", 8, 64, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Schliessen = GUICtrlCreateButton("Schließen", 8, 288, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Hintegrundfarbe_aendern = GUICtrlCreateButton("Hintegrundfarbe ändern", 8, 160, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Schrift_aendern = GUICtrlCreateButton("Schrift ändern", 8, 128, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Einstellungsdatei_oeffnen = GUICtrlCreateButton("Einstellungsdatei öffnen", 8, 192, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Einstellungsdatei_zuruecksetzen = GUICtrlCreateButton("Einstellungsdatei zurücksetzen", 8, 224, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	$Button_Programmordner_loeschen = GUICtrlCreateButton("Programmordner löschen", 8, 256, 195, 25)
	GUICtrlSetFont(-1, 8, 400, 0, "Verdana")
	GUICtrlCreateLabel("WinSec", 24, 8, 158, 49)
	GUICtrlSetFont(-1, 28, 800, 2, "Verdana")
	GUICtrlSetColor(-1, 0xFFFFFF)
	GUISetState(@SW_SHOW)
	While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			GUIDelete($Form2)
			ExitLoop
		Case $Button_Schliessen
			GUIDelete($Form2)
			ExitLoop
		Case $Button_Einstellungsdatei_oeffnen
			ShellExecute($ProgramIni)
		Case $Button_Einstellungsdatei_zuruecksetzen
			_IniWrite()
			Global $FontColor=IniRead($ProgramIni,"Allgemein","FontColor","")
			Global $FontSize=IniRead($ProgramIni,"Allgemein","FontSize","")
			Global $FontType=IniRead($ProgramIni,"Allgemein","FontType","")
			Global $BgColor=IniRead($ProgramIni,"Allgemein","BgColor","")
		Case $Button_Homepage
			ShellExecute("http://www.gt.24.eu")
		Case $Button_Info
			MsgBox(64,"WinSec","WinSec © 2011"&@CRLF&"Version: 1.0")
		Case $Button_Programmordner_loeschen
			DirRemove($ProgramDir,1)
			Exit
		Case $Button_Hintegrundfarbe_aendern
			$BgC = _ChooseColor(2,IniRead($ProgramIni,"Allgemein","BgColor",""),2)
			IniWrite($ProgramIni,"Allgemein","BgColor",$BgC)
			Global $BgColor=$BgC
		Case $Button_Schrift_aendern
			$F = _ChooseFont(IniRead($ProgramIni,"Allgemein","FontType",""),IniRead($ProgramIni,"Allgemein","FontSize",""))
			If Not $F = -1 Then
			IniWrite($ProgramIni,"Allgemein","FontColor",$F[7])
			IniWrite($ProgramIni,"Allgemein","FontType",$F[2])
			IniWrite($ProgramIni,"Allgemein","FontSize",$F[3])
			Global $FontColor=$F[7]
			Global $FontSize=$F[3]
			Global $FontType=$F[2]
			EndIf
	EndSwitch
	WEnd
EndFunc
Func _IniWrite()
	IniWrite($ProgramIni,"Allgemein","FontColor","0x000000")
	IniWrite($ProgramIni,"Allgemein","FontType","Verdana")
	IniWrite($ProgramIni,"Allgemein","FontSize","10")
	IniWrite($ProgramIni,"Allgemein","BgColor","0xFFFFFF")
EndFunc