unit U_VocabularyTraining;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.StdCtrls, JPEG;
type
TForm2 =
class(TForm)
Bt_Compare: TButton;
E_UserGuess: TEdit;
Img_FeedBack: TImage;
Img_Background_04: TImage;
Img_Background_03: TImage;
L_HeadingTrainer: TLabel;
L_RemainingWords: TLabel;
Img_BackgroundUnknownWord: TImage;
L_UnknownWord: TLabel;
L_CorrectAnswer: TLabel;
Img_BackgroundCorrectAnswer: TImage;
Img_FlagQuestion: TImage;
Img_FlagAnswer: TImage;
L_HeadingTrainerDescription: TLabel;
procedure FormCreate(Sender: TObject);
procedure Bt_CompareClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
var
Vocabulary: TStringList;
RandomNumber, Abfragen: Integer;
jpgFlag, jpgCorrect, jpgWrong: TJpegImage;
StartTime: TDateTime;
Duration: TDateTime;
end;
var
Form2: TForm2;
implementation
uses
U_MainMenu, U_Conclusion;
{$R *.dfm}
procedure TForm2.Bt_CompareClick(Sender: TObject);
var
Input:
String;
Answer, RepetitionCheck: Integer;
Form3: TForm3;
Begin
If Vocabulary.Count > 0
Then
Begin
If GermanEnglish = True
Then
Begin
Input:= E_UserGuess.Text;
E_UserGuess.Text:= '
';
Answer:=AnsiCompareStr(Vocabulary.Names[RandomNumber], Input);
If Answer=0
Then
Begin
L_CorrectAnswer.Caption:='
';
Img_FeedBack.Picture.Bitmap.Assign(jpgCorrect);
Vocabulary.Delete(RandomNumber);
End
Else
Begin
L_CorrectAnswer.Caption:='
Deine Antwort: '+(Input)+'
'+'
Richtige Antwort: '+(Vocabulary.Names[RandomNumber]);
Img_FeedBack.Picture.Bitmap.Assign(jpgWrong);
End;
RepetitionCheck:=RandomNumber;
While RepetitionCheck = RandomNumber
Do RandomNumber:=random(Vocabulary.Count);
try
L_UnknownWord.Caption:= Vocabulary.ValueFromIndex[RandomNumber];
L_RemainingWords.Caption:= '
Verbleibende Vokabeln: '+IntToStr(Vocabulary.Count);
L_RemainingWords.Font.
Name:='
Helvetica LT Std';
L_RemainingWords.Font.Size:= 16;
L_RemainingWords.Font.Color:=
RGB(170,220,70);
finally
end;
end
Else
Begin
Input:= E_UserGuess.Text;
E_UserGuess.Text:= '
';
Answer:=AnsiCompareStr(Vocabulary.ValueFromIndex[RandomNumber], Input);
If Answer=0
Then
Begin
L_CorrectAnswer.Caption:='
';
Img_FeedBack.Picture.Bitmap.Assign(jpgCorrect);
jpgCorrect.free;
Vocabulary.Delete(RandomNumber);
End
Else
Begin
L_CorrectAnswer.Caption:='
Deine Antwort: '+(Input)+'
'+'
Richtige Antwort: '+(Vocabulary.ValueFromIndex[RandomNumber]);
Img_FeedBack.Picture.Bitmap.Assign(jpgWrong);
jpgWrong.free;
End;
RepetitionCheck:=RandomNumber;
While RepetitionCheck = RandomNumber
Do RandomNumber:=random(Vocabulary.Count);
try
L_UnknownWord.Caption:= Vocabulary.Names[RandomNumber];
L_RemainingWords.Caption:= '
Verbleibende Vokabeln: '+IntToStr(Vocabulary.Count);
L_RemainingWords.Font.
Name:='
Helvetica LT Std';
L_RemainingWords.Font.Size:= 16;
L_RemainingWords.Font.Color:=
RGB(170,220,70);
finally
end;
End;
End
Else
Begin
FormDestroy(Vocabulary);
End;
End;
procedure TForm2.FormCreate(Sender: TObject);
var
CenterTextHeadingTrainer_1, CenterTextHeadingTrainer_2,
CenterTextHeadingTrainerDescription_1, CenterTextHeadingTrainerDescription_2,
CenterTextRemainingWords_1, CenterTextRemainingWords_2: Integer;
begin
//Color := RGB(170,220,70); //Hintergrund grün
//P_Question.Color := RGB(255,255,255); //Fragefeld Hintergrund weiß
//P_Answer.Color := RGB(255,255,255); //Antwortfeld Hintergrund weiß
Img_Background_03.Canvas.Brush.Color:=
RGB(170,220,70);
Img_Background_03.Canvas.Rectangle(-1,-1,Img_Background_03.Width+1,Img_Background_03.Height+1);
Img_Background_04.Canvas.Brush.Color:=
RGB(170,220,70);
Img_Background_04.Canvas.Rectangle(-1,-1,Img_Background_04.Width+1,Img_Background_04.Height+1);
Img_BackgroundUnknownWord.Canvas.Brush.Color:=
RGB(170,220,70);
Img_BackgroundUnknownWord.Canvas.Rectangle(-1,-1,Img_BackgroundUnknownWord.Width+1,Img_BackgroundUnknownWord.Height+1);
Img_BackgroundCorrectAnswer.Canvas.Brush.Color:=
RGB(220,220,220);
Img_BackgroundCorrectAnswer.Canvas.Rectangle(-1,-1,Img_BackgroundCorrectAnswer.Width+1,Img_BackgroundCorrectAnswer.Height+1);
L_HeadingTrainer.Font.
Name:='
Helvetica LT Std';
L_HeadingTrainer.Font.Size:= 24;
L_HeadingTrainer.Font.Color:= clWhite;
CenterTextHeadingTrainer_1:= Form1.Width
div 2;
CenterTextHeadingTrainer_2:= L_HeadingTrainer.Width
div 2;
L_HeadingTrainer.Left:= CenterTextHeadingTrainer_1 - CenterTextHeadingTrainer_2;
L_HeadingTrainerDescription.Font.
Name:='
Helvetica LT Std';
L_HeadingTrainerDescription.Font.Size:= 16;
L_HeadingTrainerDescription.Font.Color:= clWhite;
CenterTextHeadingTrainerDescription_1:= Form1.Width
div 5;
CenterTextHeadingTrainerDescription_2:= L_HeadingTrainerDescription.Width
div 2;
L_HeadingTrainerDescription.Left:= CenterTextHeadingTrainerDescription_1 - CenterTextHeadingTrainerDescription_2;
L_RemainingWords.Caption:= '
Verbleibende Vokabeln: 3';
L_RemainingWords.Font.
Name:='
Helvetica LT Std';
L_RemainingWords.Font.Size:= 16;
L_RemainingWords.Font.Color:=
RGB(170,220,70);
CenterTextRemainingWords_1:= Form1.Width
div 2;
CenterTextRemainingWords_2:= L_RemainingWords.Width
div 2;
L_RemainingWords.Left:= CenterTextRemainingWords_1 - CenterTextRemainingWords_2;
jpgCorrect:= TJpegImage.Create;
jpgCorrect.LoadFromFile('
True.jpg');
jpgWrong:= TJpegImage.Create;
jpgWrong.LoadFromFile('
False.jpg');
StartTime := Now;
Vocabulary:= TStringList.Create;
Vocabulary.LoadFromFile('
Vocabulary.txt');
RandomNumber:= random(Vocabulary.Count);
L_RemainingWords.Caption:= '
Verbleibende Vokabeln: '+IntToStr(Vocabulary.Count);
If GermanEnglish = True
Then
try
L_HeadingTrainerDescription.Caption:= '
Deutsch -> Englisch | '+IntToStr(Repititions)+'
Abfragen | 10 Vokabeln';
jpgFlag := TJpegImage.Create;
jpgFlag.LoadFromFile('
GermanFlag.jpg');
Img_FlagQuestion.Picture.Bitmap.Assign(jpgFlag);
jpgFlag.free;
jpgFlag := TJpegImage.Create;
jpgFlag.LoadFromFile('
BritishFlag.jpg');
Img_FlagAnswer.Picture.Bitmap.Assign(jpgFlag);
jpgFlag.free;
L_UnknownWord.Caption:= Vocabulary.ValueFromIndex[RandomNumber];
L_CorrectAnswer.Caption:= '
';
finally
end
Else
try
L_HeadingTrainerDescription.Caption:='
Englisch -> Deutsch | '+IntToStr(Repititions)+'
Abfragen | 10 Vokabeln';
jpgFlag := TJpegImage.Create;
jpgFlag.LoadFromFile('
BritishFlag.jpg');
Img_FlagQuestion.Picture.Bitmap.Assign(jpgFlag);
jpgFlag.free;
jpgFlag := TJpegImage.Create;
jpgFlag.LoadFromFile('
GermanFlag.jpg');
Img_FlagAnswer.Picture.Bitmap.Assign(jpgFlag);
jpgFlag.free;
L_UnknownWord.Caption:= Vocabulary.Names[RandomNumber];
L_CorrectAnswer.Caption:= '
';
finally
End;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
Vocabulary.Free;
jpgWrong.free;
jpgCorrect.free;
Form3 := TForm3.Create(self);
try
Form3.ShowModal;
finally
Form3.Free;
end;
end;
end.