#include <file.au3>
#include <Array.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........:	_LastWord
; Beschreibung ..:	Lässt die eingelessene Datei wie einen Abspann von Oben nach Unten Wandern
; Syntax ........:	_LastWord($hGUI)
; Parameter .....:	$hGUI	-	Das Handle zur HauptGUI
; Return values .:	Erfolg	-	Lässt die eingelessene Datei wie einen Abspann von Oben nach Unten Wandern
;                 	Fehler	-	 0: File 'Creator.txt' nicht gefunden
;								-1: $UpDown und $DownUp enthalten beide True oder False
;
; Author ........:	Skilkor
; Modified ......:
; Beispiel ......:
; ===============================================================================================================================
Func _LastWord($hGUI)
	Local Const $Size = WinGetClientSize($hGUI) ;$Size[0] = Breite(X) des Fensters	-	$Size[1] = Höhe(Y) des Fensters
	Local $Progress = GUICtrlCreateProgress(0, $Size[1] - 20, $Size[0] - 60, 20) ;Erstellt eine Progressbar am Unteren Rand der Gui
	Global $Stop = GUICtrlCreateButton('Jump', $Size[0] - 60, $Size[1] - 20, 60, 20)
	Local $Creator = FileRead('Creator.txt') ;Liest die Datei 'Creator.txt' ein
	Local $Count[1] = [_FileCountLines(@ScriptDir & '\Creator.txt')] ;Gibt die menge an Zeilen von 'Creator.txt' zurück
	If $Creator = '' Then Return SetError(1, 0, 0) ;Wenn 'Creator.txt' nicht Existiert oder Leer ist
	Local $FontColor = 0xFFFFFAFA
	Local $fSize = 20 ;Grüssen Angabe zu _GDIPlus_FontCreate
	Local $bSize = $fSize * 3
	Local $iStyle = 0 ;Style Angabe zu _GDIPlus_FontCreate 	(0 - Normal | 1 - Fett | 2 - Kursiv | 4 - Unterstrichen | 8 - Durchgestrichen)
	Local $iUnit = 2 ;Unit Angabe zu _GDIPlus_FontCreate 	(0 - Weltkoordinaten, eine nichtphysikalische Einheit | 1 - Anzeigeeinheiten | 2 - Eine Einheit ist 1 Pixel
	;;~														 3 - Eine Einheit ist 1 Punkt oder 1/72 Inch | 4 - Eine Einheit ist 1 Inch | 5 - Eine Einheit ist 1/300 Inch
	;;~														 6 - Eine Einheit ist 1 Millimeter)
	Local $UpDown = False ;Wenn True, wird der Text von Oben nach Unter Dargestellt
	Local $DownUp = True ;Wenn True, Wird der Text von Untern nach Oben Dargestellt
	If $UpDown = True And $DownUp = True Then Return SetError(1, 0, -1)
	If $UpDown = False And $DownUp = False Then Return SetError(1, 0, -1)
	Local $Speed = 5 ;Die Geschwindigkeit des Durchlaufenden Textes
	Local $EndSleep = 3000 ;Die Wartezeit wie lange 'The End' in der Mitte stehenbleiben soll
	Local $Distance[1] = [0] ;Distanz Array
	Local $FamilyFont = 'Arial' ;Schrift Art (Kann je nach unterstützung von _GDIPlus_FontFamilyCreate beliebig geändert werden)
	;;~
	For $d = 1 To $Count[0]
		_ArrayInsert($Distance, $d, $d * 1.2 * $fSize) ;|Erstellen des Distanz Array's
	Next
	;;~
	$hStringFormat = _GDIPlus_StringFormatCreate()
	_GDIPlus_StringFormatSetAlign($hStringFormat, 1)
	$hBrush = _GDIPlus_BrushCreateSolid($FontColor)
	$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
	$hFamily = _GDIPlus_FontFamilyCreate($FamilyFont)
	$hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle, $iUnit)
	$hBitmap = _GDIPlus_BitmapCreateFromGraphics($Size[0], $Size[1] - 20, $hGraphic)
	$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
	;;~
	$bStringFormat = _GDIPlus_StringFormatCreate()
	_GDIPlus_StringFormatSetAlign($bStringFormat, 1)
	$bBrush = _GDIPlus_BrushCreateSolid($FontColor)
	$bGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
	$bFamily = _GDIPlus_FontFamilyCreate($FamilyFont)
	$bFont = _GDIPlus_FontCreate($bFamily, $bSize, $iStyle, $iUnit)
	$bBitmap = _GDIPlus_BitmapCreateFromGraphics($Size[0], $Size[1] - 20, $bGraphic)
	$bBuffer = _GDIPlus_ImageGetGraphicsContext($bBitmap)
	;;~
	For $i = 0 To $Size[1] + $Distance[$Count[0]]
		Switch GUIGetMsg()
			Case $Stop
				$i = $Size[1] + $Distance[$Count[0]]
				ExitLoop
		EndSwitch
		;;~
		GUICtrlSetData($Progress, $i / ($Distance[$Count[0]] + $Size[1]) * 100)
		;;~
		If $UpDown = True Then
			$tLayout = _GDIPlus_RectFCreate($Size[0] / 2 - 150, $i - $Distance[$Count[0]] + $Size[1], 300, $Distance[$Count[0]])
		ElseIf $DownUp = True Then
			$tLayout = _GDIPlus_RectFCreate($Size[0] / 2 - 150, $Size[1] - $i, 300, $Distance[$Count[0]])
		EndIf
		_GDIPlus_GraphicsClear($hBuffer)
		_GDIPlus_GraphicsDrawStringEx($hBuffer, $Creator, $hFont, $tLayout, $hStringFormat, $hBrush)
		_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $Size[0], $Size[1] - 20)
		Sleep($Speed)
	Next
	For $i = 0 To $Size[1] + $Distance[$Count[0]]
		Switch GUIGetMsg()
			Case $Stop
				GUICtrlSetData($Stop, 'Exit')
				ExitLoop
		EndSwitch
		;;~
		GUICtrlSetData($Progress, $i / ($Distance[$Count[0]] + $Size[1]) * 100)
		;;~
		If $UpDown = True Then
			$tLayout = _GDIPlus_RectFCreate($Size[0] / 2 - 150, $i - $Distance[$Count[0]] + $Size[1], 300, $Distance[$Count[0]])
		ElseIf $DownUp = True Then
			$tLayout = _GDIPlus_RectFCreate($Size[0] / 2 - 150, $Size[1] - $i, 300, $Distance[$Count[0]])
		EndIf
		If $i = $Size[1] / 2 Then Sleep($EndSleep)
		_GDIPlus_GraphicsClear($bBuffer)
		_GDIPlus_GraphicsDrawStringEx($bBuffer, 'The End', $bFont, $tLayout, $bStringFormat, $bBrush)
		_GDIPlus_GraphicsDrawImageRect($bGraphic, $bBitmap, 0, 0, $Size[0], $Size[1] - 20)
		Sleep($Speed)
	Next
EndFunc   ;==>_LastWord