NBPRG23.PAS
{ Nikita Beloshenko (GNU) 2012 }
program NBPRG23;
uses Graph,Crt,N23t1,N23t2,N23t3,N23t4,Inst,Simple,Calc,Edit,Files,NBPRG_I;
label NEXT,PREV,START,EXIT;
const
MaxNTask = 20;
MenuColor = 4;
var
TFile : Text;
TaskList : array[1..MaxNTask] of String;
PNameList : array[1..MaxNTask] of String;
Ntask : Byte;
gd,gm,i : Integer;
s : String;
ch : Char;
procedure DrawSmallPicture16x16(var X0,Y0 : Integer; Path : String);
var
X,Y : Integer;
i1,j1 : Byte;
TFile : Text;
Color : Byte;
begin
assign(TFile, Path);
reset(TFile);
for i1 := 1 to 16 do
begin
for j1 := 1 to 16 do
begin
X := X0 + j1;
Y := Y0 + i1;
Read(TFile, Color);
PutPixel(X,Y,Color);
end;
ReadLn(TFile);
end;
close(TFile);
end;
procedure DrawRectangle(var x1,y1,x2,y2:Integer);
begin
Line(x1,y1,x2,y1);
Line(x2,y1,x2,y2);
Line(x2,y2,x1,y2);
Line(x1,y2,x1,y1);
end;
procedure DrawNtaskRectangle;
var
x1,y1,x2,y2:Integer;
j:Byte;
Path : String;
begin
SetColor(MenuColor);
for j:=1 to Ntask do
begin
x1 := 20; y1 := 20 + (j-1)*40;
x2 := 40; y2 := 40 + (j-1)*40;
DrawRectangle(x1,y1,x2,y2);
SetTextStyle(2, HorizDir, 5);
OutTextXY(x2 + 20, y1, TaskList[j]);
Path := PNameList[j];
DrawSmallPicture16x16(x1,y1,Path);
end;
x1 := 20 - 5;
x2 := 20 + 20 + 5;
y1 := 20 - 5;
y2 := 40 + (Ntask - 1)*40 + 5;
DrawRectangle(x1,y1,x2,y2);
end;
procedure DrawMRectangle;
var
x1,y1,x2,y2:Integer;
begin
SetColor(4);
x1:=20 - 1;y1:=20 + (i-1)*40 - 1;x2:=40 + 1;y2:=40 + (i-1)*40 + 1;
DrawRectangle(x1,y1,x2,y2);
end;
procedure ErraseMRectangle;
var
x1,y1,x2,y2:Integer;
begin
SetColor(0);
x1:=20 - 1;y1:=20 + (i-1)*40 - 1;x2:=40 + 1;y2:=40 + (i-1)*40 + 1;
DrawRectangle(x1,y1,x2,y2);
end;
procedure ExecuteTask(var Command:String);
begin
if Command ='task1' then DoTask1;
if Command ='task2' then DoTask2;
if Command ='task3' then DoTask3;
if Command ='task4' then DoTask4;
{...TODO : ADD HERE REACTIONS...}
if Command = 'calc' then DoCalc;
if Command = 'edit' then DoEdit;
if Command = 'files' then DoFiles;
if Command ='install/del customer task (help)' then DoInstHelp;
if Command ='Reset SIMPLE.PAS (test user task)' then DoInst;
if Command ='Simple (test user task)' then DoSimple;
end;
var
x1,y1,x2,y2 : Integer;
begin
gd := Detect;
InitGraph(gd,gm,'');
Ntask := 0;
assign(TFile,'list.tck');
reset(TFile);
while not eof(TFile) do
begin
Inc(NTask);
ReadLn(TFile,TaskList[Ntask]);
ReadLn(TFile,PNameList[Ntask]);
end;
close(TFile);
if NTask > MaxNTask then NTask := MaxNTask;
i:=1;
{ ADDITION GRAPHICAL INTERFACE RELOADING ... }
NBPRG_I_reload_interf;
START:
DrawNtaskRectangle;
SetTextStyle(2, HorizDir, 5);
OutTextXY(350,300,'Enter - Select task');
x1 := 350 - 10;
x2 := 500 + 10;
y1 := 300 - 10;
y2 := 300 + 20 + 10;
DrawRectangle(x1,y1,x2,y2);
OutTextXY(350,50,'Nikita Beloshenko (GNU) 2012');
DrawMRectangle;
ch := ReadKey;
ErraseMRectangle;
if Ord(ch) = 80 then goto NEXT;
if Ord(ch) = 72 then goto PREV;
if Ord(ch) = 27 then goto EXIT;
{ 13 = "ENTER". }
if Ord(ch) = 13 then
begin
ExecuteTask(TaskList[i]);
{ ADDITION GRAPHICAL INTERFACE RELOADING ... }
NBPRG_I_reload_interf;
end;
goto START;
NEXT:
Inc(i);
if i>Ntask then Dec(i);
goto START;
PREV:
Dec(i);
if i<1 br="" i="" inc="" then="">goto START;
EXIT:
ReadLn(s);
CloseGraph;
end.1>
Немає коментарів:
Дописати коментар