клавиатурный тренажёр

Так выглядит программ. А ниже представлена главная форма программы в disign-time.

Главная форма

Раздел INTERFACE выглядит следующим образом:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Menus, ToolWin, ActnMan, ActnCtrls, ComCtrls;

type
TForm1 = class(TForm)
Button2: TButton;
Image1: TImage;
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
MainMenu1: TMainMenu;
f1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
Timer2: TTimer;
Label3: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Image2: TImage;
N3: TMenuItem;
N4: TMenuItem;
OpenDialog1: TOpenDialog;
Label10: TLabel;
Label11: TLabel;
Image3: TImage;
Label4: TLabel;
Button1: TButton;
Shape1: TShape;
N11: TMenuItem;
N21: TMenuItem;
N31: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure N1Click(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Timer2Timer(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N31Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
press,x,up,procent,p,l:integer;
chas1,min1,sec1,msec1,chas2,min2,sec2,msec2:word;
stroka:string;
i,osx,osy,colshape:integer;
file1:textfile;
sk1,sec1real,msreal,sk,j,obsk,e,f:real;


Код модуля представлен ниже

 

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
colshape:=0;
button1.Visible:=false;
button2.Visible:=false;
shape1.Visible:=false;
label10.Visible:=false;
button2.Click;
label9.Caption:=inttostr(press);
label6.Caption:=floattostr(obsk)+' '+'симв/мин';
label3.Caption:=floattostr(x)+' '+'симв/мин';
timer2timer(timer2);
Image1.Canvas.Rectangle(0,0,537,145);
image3.Picture.LoadFromFile('Клавиатура.bmp');
end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
var begtime,vreme:tdatetime;
begin
if (form1.N4.Checked) or (form1.n11.checked) or (form1.n21.checked) or (form1.n31.checked) then
begin
label11.Caption:='0';
image2.Canvas.MoveTo(osx,osy); //позиция графика на картинке после
if i>=1 then // загрузки задания
begin
timer1.Enabled:=false;
end;
vreme:=time;
DecodeTime((vreme), chas2, min2, sec2, msec2);
if sec2<sec1 then //если секунды2<секунды1
begin
sec2:=(sec2+60-sec1);
end
else
begin
sec2:=sec2-sec1;
end;
if msec2<msec1 then //если милисекунды2<милисекунды1
begin
msec2:=msec2+1000-msec1;
end
else
begin
msec2:=msec2-msec1;
end;
sec1real:=round(sec2);
msreal:=round(msec2);
sk1:=sec1real+(msreal/1000);
sk:=(60 / sk1); //скорость набора за 1 минуту
obsk:=(obsk+sk)/ 2;
label6.Caption:=floattostr(round(obsk))+'симв/мин';
image2.Canvas.Pen.Color:=clblack;
label3.Caption:=floattostr(round(sk))+'симв/мин';
label1.Caption:='0 %';
setlength(stroka,length(stroka));
image1.Canvas.Font.Height:=40;
image1.Canvas.Font.Name:='MS Referense Sans Serif';
image1.Canvas.Font.Color:=clblue;
image1.Canvas.TextOut(187,5,stroka[i]); //все символы строчные
if (key=(stroka[i])) then
begin
button1.Click;
label11.Caption:=inttostr(i); // выводит при помощи Label11
osx:=osx+4; // количество набранных символов
j:=113-(obsk / 3);
osy:=trunc(j);
image2.Canvas.Pen.Width:=2;
image2.Canvas.Pen.Color:=clgreen;
image2.canvas.LineTo(osx,osy);
if i>=100 then
begin
image2.Canvas.TextOut(15,2,'110 c. -- 120 с. -- 130 c. -- 140 с. -- 150 c. -- 160 с. -- 170 c. -- 180 с. -- 190 c. -- 200 с.');
end
else
begin
image2.Canvas.TextOut(15,2,'-0 c. -- 10 c. -- 20 с. -- 30 c. -- 40 с. -- 50 c. -- 60 с. -- 70 c. -- 80 с. -- 90 c. -- 100 с.');
end;
image2.canvas.moveto(osx,osy);
if osx>410 then
begin
button2.Click;
osx:=15;
image2.Canvas.TextOut(15,2,'110 c. -- 120 с. -- 130 c. -- 140 с. -- 150 c. -- 160 с. -- 170 c. -- 180 с. -- 190 c. -- 200 с.');
end;
image2.Canvas.Font.Color:=clred;
f:=f+e;
procent:=round(f);
label1.Caption:=inttostr(procent)+'%';
timer1.Enabled:=true;
begtime:=time;
DecodeTime((BegTime), chas1, min1, sec1, msec1);
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i+1]);
i:=i+1;
button1.Click;
n4.Checked:=false; //n4.Checked:=false, иначе при удерживании любой
if stroka[i]='' then // клавиши начнет повторно выполняться событие OnKeyPress,
begin // и вызовет ошибку, если key=stroka[i]=false;
label1.Caption:='100 %' ;
showmessage('Поздравляю! Ты выполнил задание.')
end;
end
else //если нажата неверная клавиша
begin
press:=press+1;
showmessage('Ошибка!!!');
label9.Caption:=inttostr(press);
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i]);
up:=press-1;
if press >=4 then //если допущено 4 ошибки
begin
showmessage('Вы допустили слишком много ошибок!!!');
form1.N4.Click;
press:=0;
up:=press;
end;
end;
end;
end;

procedure TForm1.N1Click(Sender: TObject);
begin
showmessage('Автор: Горяной Дмитрий, 34 группа, 3 курс(заочник),Запорожская обл., Мелитопольское отделение ТНУ им. В.И.Вернадского.');
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
up:=up+1;
n4.Checked:=true;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
label2.Caption:=timetostr(now);
end;

procedure TForm1.N3Click(Sender: TObject);
begin
Showmessage('Программа написана на языке {Pascal} с помощью программы Delphi 7');
end;

 

procedure TForm1.N4Click(Sender: TObject);
var f1:textfile;
begin
i:=1;
label11.Caption:='0';
label10.Visible:=true;
procent:=0;
e:=0;
f:=0;
Opendialog1.filter:='текстовые файлы *.txt';
opendialog1.Execute;
if fileexists(opendialog1.FileName)=true then
begin
j:=0;
button2.Click;
image2.Canvas.MoveTo(15,113);
osx:=15;
osy:=113;
label1.Caption:='0 %';
x:=0;
setlength(stroka,i);
assignfile(f1,opendialog1.FileName);
reset(f1);
read(f1,stroka);
closefile(f1);
image1.Canvas.Font.Height:=40;
image1.Canvas.Font.Name:='MS Referense Sans Serif';
image1.Canvas.Font.Color:=clblue;
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i]);
label3.caption:=' ';
label6.caption:=' ';
press:=0;
label9.Caption:=inttostr(press);
obsk:=0;
label6.Caption:=floattostr(obsk)+' '+'симв/мин';
label3.Caption:=floattostr(x)+' '+'симв/мин';
for i:=1 to length (stroka) do
begin
e:=e+1;
end;
e:= 100/e;
i:=1;
button1.Click;
end
else
showmessage('Файл не найден!!');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
image2.Canvas.Font.Color:=clred;
image2.Canvas.Brush.Color:=clskyblue;
image2.Canvas.Rectangle(0,0,441,113);
image2.Canvas.TextOut(15,2,'-0 c. -- 10 c. -- 20 с. -- 30 c. -- 40 с. -- 50 c. -- 60 с. -- 70 c. -- 80 с. -- 90 c. -- 100 с.');
image2.Canvas.Font.Color:=clblue;
image2.Canvas.TextOut(2,5,'с');
image2.Canvas.TextOut(2,16,'к');
image2.Canvas.TextOut(2,27,'о');
image2.Canvas.TextOut(2,38,'р');
image2.Canvas.TextOut(2,51,'о');
image2.Canvas.TextOut(2,62,'с');
image2.Canvas.TextOut(2,73,'т');
image2.Canvas.TextOut(2,84,'ь');
image2.Canvas.TextOut(420,10,'300');
image2.Canvas.TextOut(420,25,'250');
image2.Canvas.TextOut(420,40,'200');
image2.Canvas.TextOut(420,55,'150');
image2.Canvas.TextOut(420,70,'100');
image2.Canvas.TextOut(420,85,'50');
image2.Canvas.TextOut(420,100,'0');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
shape1.Width:=35;
if (stroka[i]='`') or (stroka[i]='ё') then
begin
shape1.Left:=2;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='1') then
begin
shape1.Left:=38;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='2') then
begin
shape1.Left:=72;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='3') then
begin
shape1.Left:=104;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='4') then
begin
shape1.Left:=140;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='5') then
begin
shape1.Left:=174;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='6') then
begin
shape1.Left:=208;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='7') then
begin
shape1.Left:=242;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='8') then
begin
shape1.Left:=274;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='9') then
begin
shape1.Left:=310;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='0') then
begin
shape1.Left:=345;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='-') then
begin
shape1.Left:=379;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='=') then
begin
shape1.Left:=413;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='\') then
begin
shape1.Left:=446;
shape1.Top:=258;
colshape:=1;
end;
if (stroka[i]='q') or (stroka[i]='й') then
begin
shape1.Left:=54;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='w') or (stroka[i]='ц') then
begin
shape1.Left:=88;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='у') or (stroka[i]='e') then
begin
shape1.Left:=122;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='r') or (stroka[i]='к') then
begin
shape1.Left:=156;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='е') or (stroka[i]='t') then
begin
shape1.Left:=190;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='y') or (stroka[i]='н') then
begin
shape1.Left:=224;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='г') or (stroka[i]='u') then
begin
shape1.Left:=258;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='i') or (stroka[i]='ш') then
begin
shape1.Left:=292;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='щ') or (stroka[i]='o') then
begin
shape1.Left:=326;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='p') or (stroka[i]='з') then
begin
shape1.Left:=360;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='х') or (stroka[i]='[') then
begin
shape1.Left:=394;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]=']') or (stroka[i]='ъ') then
begin
shape1.Left:=428;
shape1.Top:=293;
colshape:=1;
end;
if (stroka[i]='ф') or (stroka[i]='a') then
begin
shape1.Left:=70;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='s') or (stroka[i]='ы') then
begin
shape1.Left:=104;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='в') or (stroka[i]='f') then
begin
shape1.Left:=138;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='а') or (stroka[i]='f') then
begin
shape1.Left:=172;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='g') or (stroka[i]='п') then
begin
shape1.Left:=206;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='р') or (stroka[i]='h') then
begin
shape1.Left:=240;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='j') or (stroka[i]='о') then
begin
shape1.Left:=274;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='л') or (stroka[i]='k') then
begin
shape1.Left:=308;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='l') or (stroka[i]='д') then
begin
shape1.Left:=342;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='ж') or (stroka[i]=';') then
begin
shape1.Left:=376;
shape1.Top:=328;
colshape:=1;
end;
if stroka[i]='э' then
begin
shape1.Left:=410;
shape1.Top:=328;
colshape:=1;
end;
if (stroka[i]='я') or (stroka[i]='z') then
begin
shape1.Left:=86;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='x') or (stroka[i]='ч') then
begin
shape1.Left:=120;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='с') or (stroka[i]='c') then
begin
shape1.Left:=154;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='v') or (stroka[i]='м') then
begin
shape1.Left:=188;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='и') or (stroka[i]='b') then
begin
shape1.Left:=222;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='n') or (stroka[i]='т') then
begin
shape1.Left:=256;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='ь') or (stroka[i]='m') then
begin
shape1.Left:=290;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]=',') or (stroka[i]='б') then
begin
shape1.Left:=324;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='ю') or (stroka[i]='.') then
begin
shape1.Left:=358;
shape1.Top:=364;
colshape:=1;
end;
if (stroka[i]='/') or (stroka[i]='.') then
begin
shape1.Left:=392;
shape1.Top:=364;
colshape:=1;
end;
if stroka[i]=' ' then
begin
shape1.Left:=136;
shape1.Top:=398;
shape1.height:=35;
shape1.width:=241;
colshape:=1;
end;
if colshape=1 then
begin
shape1.Visible:=true;
end;
colshape:=0;
end;

procedure TForm1.N11Click(Sender: TObject);
var f1:textfile;
begin
i:=1;
label11.Caption:='0';
label10.Visible:=true;
procent:=0;
e:=0;
f:=0;
if fileexists('Задание 1.txt')=true then
begin
j:=0;
button2.Click;
image2.Canvas.MoveTo(15,113);
osx:=15;
osy:=113;
label1.Caption:='0 %';
x:=0;
setlength(stroka,i);
assignfile(f1,'Задание 1.txt');
reset(f1);
read(f1,stroka);
closefile(f1);
image1.Canvas.Font.Height:=40;
image1.Canvas.Font.Name:='MS Referense Sans Serif';
image1.Canvas.Font.Color:=clblue;
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i]);
label3.caption:=' ';
label6.caption:=' ';
press:=0;
label9.Caption:=inttostr(press);
obsk:=0;
label6.Caption:=floattostr(obsk)+' '+'симв/мин';
label3.Caption:=floattostr(x)+' '+'симв/мин';
for i:=1 to length (stroka) do
begin
e:=e+1;
end;
e:= 100/e;
i:=1;
button1.Click;
end
else
showmessage('Файл не найден!!');

end;

procedure TForm1.N21Click(Sender: TObject);
var f1:textfile;
begin
i:=1;
label11.Caption:='0';
label10.Visible:=true;
procent:=0;
e:=0;
f:=0;
if fileexists('Задание 2.txt')=true then
begin
j:=0;
button2.Click;
image2.Canvas.MoveTo(15,113);
osx:=15;
osy:=113;
label1.Caption:='0 %';
x:=0;
setlength(stroka,i);
assignfile(f1,'Задание 2.txt');
reset(f1);
read(f1,stroka);
closefile(f1);
image1.Canvas.Font.Height:=40;
image1.Canvas.Font.Name:='MS Referense Sans Serif';
image1.Canvas.Font.Color:=clblue;
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i]);
label3.caption:=' ';
label6.caption:=' ';
press:=0;
label9.Caption:=inttostr(press);
obsk:=0;
label6.Caption:=floattostr(obsk)+' '+'симв/мин';
label3.Caption:=floattostr(x)+' '+'симв/мин';
for i:=1 to length (stroka) do
begin
e:=e+1;
end;
e:= 100/e;
i:=1;
button1.Click;
end
else
showmessage('Файл не найден!!');
end;
procedure TForm1.N31Click(Sender: TObject);
var f1:textfile;
begin
i:=1;
label11.Caption:='0';
label10.Visible:=true;
procent:=0;
e:=0;
f:=0;
if fileexists('Задание 3.txt')=true then
begin
j:=0;
button2.Click;
image2.Canvas.MoveTo(15,113);
osx:=15;
osy:=113;
label1.Caption:='0 %';
x:=0;
setlength(stroka,i);
assignfile(f1,'Задание 3.txt');
reset(f1);
read(f1,stroka);
closefile(f1);
image1.Canvas.Font.Height:=40;
image1.Canvas.Font.Name:='MS Referense Sans Serif';
image1.Canvas.Font.Color:=clblue;
Image1.Canvas.Rectangle(0,0,377,49);
image1.Canvas.TextOut(187,5,stroka[i]);
label3.caption:=' ';
label6.caption:=' ';
press:=0;
label9.Caption:=inttostr(press);
obsk:=0;
label6.Caption:=floattostr(obsk)+' '+'симв/мин';
label3.Caption:=floattostr(x)+' '+'симв/мин';
for i:=1 to length (stroka) do
begin
e:=e+1;
end;
e:= 100/e;
i:=1;
button1.Click;
end
else
showmessage('Файл не найден!!');
end;

end.

 

 

Сайт создан в системе uCoz