;------  Included Files  ------;

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <Fade.au3>

;------  Main Menu  ------;
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ###
$COLOR_2010 = GUICreate("COLOR Finder 1.0", 721, 202, -1, -1)
GUISetFont(12, 400, 0, "Verdana")
GUISetBkColor(0xF0F0F0)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$DEC = GUICtrlCreateInput("16777215", 70, 100, 150, 26,$SS_CENTER)
GUICtrlSetBkColor(-1, 0xF0F0F0)
GUICtrlSetOnEvent(-1, "DECCOLORChange")
$HEX = GUICtrlCreateInput("0xFFFFFF", 320, 100, 150, 26,$SS_CENTER)
GUICtrlSetBkColor(-1, 0xF0F0F0)
GUICtrlSetOnEvent(-1, "HEXCOLORChange")
$FINDER = GUICtrlCreateButton("Farbfinder", 510, 100, 190, 26, 0)
GUICtrlSetOnEvent(-1, "FinderClick")
GUICtrlCreateButton("Farbe testen", 20, 140, 320, 24, 0)
GUICtrlSetOnEvent(-1, "COLORTESTClick")
GUICtrlCreateButton("Farbe übernehmen", 380, 140, 320, 24, 0)
GUICtrlSetOnEvent(-1, "ACCEPTClick")
;------  TEXT  ------;
GUICtrlCreateLabel("Bitte wählen sie Die Farbe im richtigen Format aus oder benutzen sie den Farbfinder", 10, 45, 701, 22)
GUICtrlCreateLabel("DEC:", 20, 102, 44, 22)
GUICtrlCreateLabel("HEX:", 256, 102, 44, 22)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;------  Default Functions  ------;
_FADEIN("COLOR Finder 1.0",20)
Sleep(1000)
While WinExists("Farbe") = False
	$WINPOSITION = WinGetPos("COLOR Finder 1.0")
	$WINPOSITION[0]-=101
	WinMove("COLOR Finder 1.0","",$WINPOSITION[0],$WINPOSITION[1],Default,Default,10)
	$WINPOSITION[0]+=750
	$COLOR = GUICreate("Farbe", 220, 220, $WINPOSITION[0], $WINPOSITION[1],$WS_POPUPWINDOW)
	GUISetBkColor(0xFFFFFF)
	GUISetState(@SW_SHOW)
	_FADEIN("Farbe",10)
WEnd


While 1
	Sleep(100)
WEnd

;------  Color Settings  ------;

;------  Hex Color  ------;
Func HEXCOLORChange()
	If WinExists("Farbe") Then
	EndIf
	$DECCODE = Dec(GUICtrlRead($HEX))
	GUICtrlSetData($DEC,$DECCODE)
EndFunc

;------  Hex Color  ------;
Func DECCOLORChange()
	$HEXCODE = "0x"&Hex(GUICtrlRead($DEC),6)
	GUICtrlSetData($HEX,$HEXCODE)
EndFunc

;------ Color Finder  ------;
Func FinderClick()
	TrayTip("HOW To USE","Dies ist ein Assistent mit dem sie bequem eine Farbe auswählen können"&@CRLF&"Um dies zu tun fahren sie mit der Maus über den Bildschirm und suchen sie die gewünschte Farbe, wenn sie die richtige Farbe gefunden haben beenden sie den Assistenten indem sie die linke Maustaste drücken",5,1)
	Sleep(5000)
	TrayTip("Der Assistent wird nun gestartet","Suchen sie die gewünschte Farbe",1,1)
	_FADEOUT("COLOR Finder 1.0",20)
		
		$POSITION = MouseGetPos()
		$POSITION[0]+=10
		$POSITION[1]+=10
		WinMove("Farbe","",$POSITION[0],$POSITION[1],85,85,5)
		
	While _IsPressed(01) = False
		$POSITION = MouseGetPos()
		$COLOR = PixelGetColor($POSITION[0],$POSITION[1])
		$POSITION[0]+=10
		$POSITION[1]+=10
		WinMove("Farbe","",$POSITION[0],$POSITION[1],85,85)
		GUISetBkColor($Color)
	WEnd
	_FADEIN("COLOR Finder 1.0",20)
	$WINPOSITION = WinGetPos("COLOR Finder 1.0")
	$WINPOSITION[0]+=750
	WinMove("Farbe","",$WINPOSITION[0], $WINPOSITION[1],220, 220,30)
	

	GUICtrlSetData($DEC,$COLOR)
	GUICtrlSetData($HEX,"0x"&Hex($COLOR,6))
EndFunc


;------  Default Buttons  ------;
Func ACCEPTClick()

EndFunc

Func COLORTESTClick()
	_FADEOUT("Farbe",20)
	$BACKGROUND = GUICtrlRead($DEC)
	GUISetBkColor($BACKGROUND)
	_FADEIN("Farbe",20)
EndFunc

Func Close()
	Exit
EndFunc