2019-08-02 10:17:49 +03:00
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
2015-06-27 19:33:50 +03:00
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
2015-05-14 22:35:07 +03:00
unit RobotField;
//#savepcu false
interface
uses GraphABC;
const
IniFileName = 'ABC.ini' ;
MAX_DimX = 1 0 0 ;
MAX_DimY = 1 0 0 ;
var
RPaintColor: Color;
RBorderColor: Color;
RobotColor: Color;
RobotColor1: Color;
BackColor: Color;
LabelReadyColor: Color;
LabelDoColor: Color;
LabelStopColor: Color;
LabelErrorColor: Color;
LabelBadEndColor: Color;
LabelGoodEndColor: Color;
2017-06-26 21:22:27 +03:00
HelpStr : =
2019-01-28 03:30:18 +03:00
'Разработчик исполнителя Робот: Михалкович С .С ., 2002-19 ' #10 #13 #10 #13 +
2017-06-26 21:22:27 +03:00
'Команды исполнителя Робот:' #10 #13 +
' Right - вправо' #10 #13 +
' Left - влево' #10 #13
' Up - вверх' #10 #13 +
' Down - вниз' #10 #13
' Paint - закрасить текущую клетку' #10 #13
' Task(name) - вызвать задание с указанным именем' #10 #13
' StandardField - вызвать стандартное поле' #10 #13
' Field(n,m) - вызвать поле размера n на m' #10 #13 #10 #13
'Условия, проверяемые исполнителем Робот:' #10 #13
' WallFromRight - справа стена' #10 #13
' WallFromLeft - слева стена' #10 #13
' WallFromUp - сверху стена' #10 #13
' WallFromDown - снизу стена' #10 #13
' FreeFromRight - справа свободно' #10 #13
' FreeFromLeft - слева свободно' #10 #13
' FreeFromUp - сверху свободно' #10 #13
' FreeFromDown - снизу свободно' #10 #13
' CellIsPainted - клетка закрашена' #10 #13
' CellIsFree - клетка не закрашена' #10 #13 ;
2015-05-14 22:35:07 +03:00
type
TRobotField = class
private
Tags: array [ 1 .. MAX_DimX, 1 .. MAX_DimY] of boolean ;
Painted: array [ 1 .. MAX_DimX, 1 .. MAX_DimY] of integer ; // 0-not 1-user painted 2-zadan painted
HorizWalls: array [ 1 .. MAX_DimX, 0 .. MAX_DimY] of boolean ;
VertWalls: array [ 0 .. MAX_DimX, 1 .. MAX_DimY] of boolean ;
FirstRobotX, FirstRobotY: integer ;
LastRobotX, LastRobotY: integer ;
RobotX, RobotY: integer ;
Interval: integer ;
StepFlag: boolean ;
movenum: integer ;
CellSize, DimX, DimY, X0, Y0: integer ;
procedure Draw0;
procedure DrawFieldOnly;
2015-12-28 14:25:15 +03:00
procedure DrawCell( x, y: integer ) ; { нарисовать одну ячейку }
2015-05-14 22:35:07 +03:00
public
2015-12-28 14:25:15 +03:00
// Добавил - М А
2015-05-14 22:35:07 +03:00
TaskName: string ;
//
constructor Create( sizex, sizey, cellsize: integer ) ;
procedure DrawCentered;
procedure Draw;
procedure Clear;
procedure SetSpeed( speed: integer ) ;
property StepState: boolean read StepFlag;
property SizeX: integer read DimX;
property SizeY: integer read DimY;
function IsSolution: boolean ;
procedure CheckTaskCall;
2015-12-28 14:25:15 +03:00
// примитивы для постановщика
2015-05-14 22:35:07 +03:00
procedure DrawLastRobotPos;
procedure DrawTag( x, y: integer ) ;
procedure SetDim( DX, DY, CellSz: integer ) ;
2015-12-28 14:25:15 +03:00
procedure SetPaintMaker( x, y: integer ) ; { пометить ячейку как нарисованную - постановщик}
procedure SetTag( x, y: integer ) ; { пометить ячейку как помеченную }
2015-05-14 22:35:07 +03:00
procedure SetTagRect( x1, y1, x2, y2: integer ) ;
procedure SetFirstRobotPos( x, y: integer ) ;
procedure MoveRobotToFirstPos;
procedure SetLastRobotPos( x, y: integer ) ;
procedure SetFirstLastRobotPos( x, y, x1, y1: integer ) ;
procedure HorizWall( x, y, len: integer ) ;
procedure VertWall( x, y, len: integer ) ;
procedure TaskText( s: string ) ;
2015-12-28 14:25:15 +03:00
// примитивы для выполнителя
2015-05-14 22:35:07 +03:00
procedure DrawRobot;
procedure MoveRobot( x, y: integer ) ;
2015-12-28 14:25:15 +03:00
procedure SetPaintUser( x, y: integer ) ; { пометить ячейку как нарисованную - выполнитель}
procedure SetRobotPos( x, y: integer ) ; // синоним MoveRobot
2015-05-14 22:35:07 +03:00
function WallFromLeft( x, y: integer ) : boolean ;
function WallFromRight( x, y: integer ) : boolean ;
function WallFromUp( x, y: integer ) : boolean ;
function WallFromDown( x, y: integer ) : boolean ;
function CellIsFree( x, y: integer ) : boolean ;
function CellIsPainted( x, y: integer ) : boolean ;
procedure Right;
procedure Left;
procedure Up;
procedure Down;
procedure Paint;
procedure Pause;
function WallFromLeft: boolean ;
function WallFromRight: boolean ;
function WallFromUp: boolean ;
function WallFromDown: boolean ;
function CellIsFree: boolean ;
function CellIsPainted: boolean ;
procedure Start;
procedure Stop;
end ;
procedure CorrectWHLT;
procedure SetTaskCall;
procedure RobotError( s: string ) ;
procedure RobotError( s, s1: string ) ;
var
RobField: TRobotField;
///--
procedure __InitModule__;
///--
procedure __FinalizeModule__;
implementation
uses
System,
System. Windows. Forms,
System. Drawing,
GraphABC,
IniFile;
type
TLabel = System. Windows. Forms. Label ;
IniSettings = record
Width: integer ;
Height: integer ;
Left: integer ;
Top: integer ;
Speed: integer ;
end ;
var
BottomPanel: Panel;
panelBottomLeft: Panel;
buttonHelp: Button;
buttonExit: Button;
buttonStep: Button;
buttonStart: Button;
tableLayoutPanelBottom: TableLayoutPanel;
labelExState: TLabel;
groupBoxExState: GroupBox;
tableLayoutPanel1: TableLayoutPanel;
labelState: TLabel;
labelStep: TLabel;
trackBarSpeed: TrackBar;
labelSpeed: TLabel;
tableLayoutPanelTop: TableLayoutPanel;
labelZad: TLabel;
TaskIsCalled: boolean ;
t: System. Threading. Thread;
2022-09-17 09:13:04 +03:00
ScreenScale: real : = 1 ;
2015-12-28 14:25:15 +03:00
//------------ Вспомогательные -------------
2015-05-14 22:35:07 +03:00
procedure SetLabelStepText( s: string ) ;
begin
labelStep. Text : = s;
end ;
procedure SetSafeLabelStepText( s: string ) ;
begin
labelStep. Invoke( SetLabelStepText, s) ;
end ;
procedure SetLabelZadText( s : string ) ;
begin
labelZad. Text : = s;
end ;
procedure SetSafeLabelZadText( s: string ) ;
begin
labelZad. Invoke( SetLabelZadText, s) ;
end ;
procedure SetTrackBarSpeedValue( speed: integer ) ;
begin
trackBarSpeed. Value : = speed;
end ;
procedure SetSafeTrackBarSpeedValue( speed: integer ) ;
begin
trackBarSpeed. Invoke( SetTrackBarSpeedValue, speed) ;
end ;
//------------ TRobotField -------------
constructor TRobotField. Create( sizex, sizey, cellsize: integer ) ;
begin
Self. CellSize : = cellsize;
DimX : = sizex;
DimY : = sizey;
RobotX : = 1 ;
RobotY : = 1 ;
FirstRobotX : = 1 ;
FirstRobotY : = 1 ;
LastRobotX : = 0 ;
LastRobotY : = 0 ;
X0 : = 0 ;
y0 : = 0 ;
StepFlag : = False ;
movenum : = 0 ;
SetSpeed( 3 ) ;
Clear;
end ;
procedure TRobotField. Draw;
begin
if ( MainForm. windowstate= formwindowstate. Minimized) then
Exit;
LockDrawing;
ClearWindow( BackColor) ;
Draw0;
UnLockDrawing;
end ;
procedure TRobotField. DrawCentered;
var w, h: integer ;
begin
if ( DimX= 0 ) or ( DimY= 0 ) then
exit;
w : = CellSize* DimX;
h : = CellSize* DimY;
X0 : = ( GraphABCControl. Width - w) div 2 ;
Y0 : = ( GraphABCControl. Height - h) div 2 ;
Draw;
end ;
procedure TRobotField. DrawFieldOnly;
begin
2017-06-26 21:22:27 +03:00
var w : = CellSize* DimX;
var h : = CellSize* DimY;
2015-05-14 22:35:07 +03:00
Brush. Color : = clWhite;
FillRectangle( X0, Y0, X0+ w+ 1 , Y0+ h+ 1 ) ;
Pen. Width : = 1 ;
Pen. Color : = RGB( 1 9 1 , 1 9 1 , 1 9 1 ) ;
2017-06-26 21:22:27 +03:00
for var ix: = 0 to DimX do
2015-05-14 22:35:07 +03:00
Line( X0+ ix* CellSize, Y0, X0+ ix* CellSize, Y0+ h) ;
2017-06-26 21:22:27 +03:00
for var iy: = 0 to DimY do
2015-05-14 22:35:07 +03:00
Line( X0, Y0+ iy* CellSize, X0+ w, Y0+ iy* CellSize) ;
end ;
procedure TRobotField. Draw0;
begin
DrawFieldOnly;
Pen. Color: = clBlack;
Pen. Width: = 3 ;
2017-06-26 21:22:27 +03:00
for var x: = 1 to DimX do
for var y: = 0 to DimY do
2015-05-14 22:35:07 +03:00
if HorizWalls[ x, y] then
begin
MoveTo( X0+ ( x- 1 ) * CellSize, Y0+ y* CellSize) ;
LineTo( X0+ x* CellSize, Y0+ y* CellSize) ;
end ;
2017-06-26 21:22:27 +03:00
for var x: = 0 to DimX do
for var y: = 1 to DimY do
2015-05-14 22:35:07 +03:00
if VertWalls[ x, y] then
begin
MoveTo( X0+ x* CellSize, Y0+ ( y- 1 ) * CellSize) ;
LineTo( X0+ x* CellSize, Y0+ y* CellSize) ;
end ;
Pen. Color: = clBlack;
Pen. Width: = 1 ;
2017-06-26 21:22:27 +03:00
for var x: = 1 to DimX do
for var y: = 1 to DimY do
2015-05-14 22:35:07 +03:00
DrawCell( x, y) ;
end ;
procedure TRobotField. DrawLastRobotPos;
var Sz, Z, Dim: integer ;
begin
Sz: = CellSize;
Z: = max( Sz div 1 2 , 2 ) ;
2019-02-18 10:36:06 +03:00
{ if Sz> 6 4 then Dim: = 1 0
2015-05-14 22:35:07 +03:00
else if Sz> 5 6 then Dim: = 9
else if Sz> 4 8 then Dim: = 8
else if Sz> 4 0 then Dim: = 8
else if Sz> 3 4 then Dim: = 7
2019-02-18 10:36:06 +03:00
else } if Sz> 2 8 then Dim: = Round( ( Sz+ 2 0 ) / 8 )
2015-05-14 22:35:07 +03:00
else if Sz> 2 2 then Dim: = 5
else if Sz> 1 2 then Dim: = 4
else Dim: = 3 ;
Brush. Color: = RobotColor;
Pen. Color: = RBorderColor;
Pen. Style: = psSolid;
Rectangle( X0+ Sz* ( LastRobotX- 1 ) + Z, Y0+ Sz* ( LastRobotY- 1 ) + Z, X0+ Sz* ( LastRobotX- 1 ) + Z+ Dim, Y0+ Sz* ( LastRobotY- 1 ) + Z+ Dim) ;
end ;
procedure TRobotField. DrawTag( x, y: integer ) ;
2019-02-18 10:36:06 +03:00
var sz2: integer ;
begin
var Sz: = CellSize;
var s2 : = Sz div 2 ;
{ if Sz> 1 7 2 then
sz2: = S2 - 6
else } if Sz> 1 3 2 then
sz2: = S2 - 5
else if Sz> 9 2 then
sz2: = S2 - 4
else if Sz> 5 2 then
sz2: = S2 - 3
else if Sz> 1 2 then
sz2: = S2 - 2
else sz2: = S2 - 1 ;
2015-05-14 22:35:07 +03:00
if ( RobotX= x) and ( RobotY= y)
then Brush. Color: = clLightGray
else Brush. Color: = clBlack;
FillRectangle( X0+ Sz* ( x- 1 ) + 1 + sz2, Y0+ Sz* ( y- 1 ) + 1 + sz2, X0+ Sz* x+ 1 - sz2, Y0+ Sz* y+ 1 - sz2) ;
end ;
procedure TRobotField. DrawRobot;
var Sz, Z1: integer ;
begin
Sz: = CellSize;
Z1: = max( Sz div 6 , 3 ) ;
if CellSize< 1 0 then Z1: = 2 ;
if Painted[ RobotX, RobotY] = 0
then Brush. Color: = RobotColor
else Brush. Color: = RobotColor1;
Pen. Color: = RBorderColor;
Pen. Style: = psSolid;
Rectangle( X0+ Sz* ( RobotX- 1 ) + Z1, Y0+ Sz* ( RobotY- 1 ) + Z1, X0+ Sz* RobotX+ 1 - Z1, Y0+ Sz* RobotY+ 1 - Z1) ;
end ;
procedure TRobotField. DrawCell( x, y: integer ) ;
var Sz, Z: integer ;
begin
Sz: = CellSize;
Z: = max( Sz div 1 2 , 2 ) ;
if ( Painted[ x, y] = 1 ) or ( Painted[ x, y] = 2 ) then
Brush. Color: = RPaintColor
else
Brush. Color: = clWhite;
if ( Painted[ x, y] = 1 ) or ( Painted[ x, y] = 2 ) then
FillRectangle( X0+ Sz* ( x- 1 ) + Z, Y0+ Sz* ( y- 1 ) + Z, X0+ Sz* x+ 2 - Z- 1 , Y0+ Sz* y+ 2 - Z- 1 )
else
FillRectangle( X0+ Sz* ( x- 1 ) + 2 , Y0+ Sz* ( y- 1 ) + 2 , X0+ Sz* x+ 2 - 3 , Y0+ Sz* y+ 2 - 3 ) ;
if ( LastRobotX= x) and ( LastRobotY= y) then
DrawLastRobotPos;
if ( RobotX= x) and ( RobotY= y) then
DrawRobot;
if Tags[ x, y] then
DrawTag( x, y) ;
end ;
procedure TRobotField. SetPaintUser( x, y: integer ) ;
begin
if Painted[ x, y] = 0 then
Painted[ x, y] : = 1 ;
end ;
procedure TRobotField. SetPaintMaker( x, y: integer ) ;
begin
Painted[ x, y] : = 2 ;
end ;
procedure TRobotField. SetTag( x, y: integer ) ;
begin
Tags[ x, y] : = True ;
end ;
procedure TRobotField. SetTagRect( x1, y1, x2, y2: integer ) ;
begin
2017-06-26 21:22:27 +03:00
for var x: = x1 to x2 do
for var y: = y1 to y2 do
2015-05-14 22:35:07 +03:00
SetTag( x, y) ;
end ;
procedure TRobotField. SetFirstRobotPos( x, y: integer ) ;
begin
FirstRobotX: = x;
FirstRobotY: = y;
SetRobotPos( x, y) ;
end ;
procedure TRobotField. MoveRobotToFirstPos;
begin
SetRobotPos( FirstRobotX, FirstRobotY) ;
end ;
procedure TRobotField. SetLastRobotPos( x, y: integer ) ;
begin
LastRobotX: = x;
LastRobotY: = y;
end ;
procedure TRobotField. SetFirstLastRobotPos( x, y, x1, y1: integer ) ;
begin
SetFirstRobotPos( x, y) ;
SetLastRobotPos( x1, y1) ;
end ;
procedure TRobotField. MoveRobot( x, y: integer ) ;
begin
2019-02-18 10:36:06 +03:00
var vx: = RobotX;
var vy: = RobotY;
2015-05-14 22:35:07 +03:00
RobotX: = x;
RobotY: = y;
DrawCell( vx, vy) ;
DrawCell( x, y) ;
Inc( movenum) ;
2015-12-28 14:25:15 +03:00
SetSafeLabelStepText( 'Шаг: ' + IntToStr( movenum) ) ;
// labelStep.Invoke(SetLabelStepText,'Шаг: ' + IntToStr(movenum));
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. SetRobotPos( x, y: integer ) ;
begin
MoveRobot( x, y) ;
end ;
function TRobotField. WallFromLeft( x, y: integer ) : boolean ;
begin
CheckTaskCall;
WallFromLeft: = VertWalls[ x- 1 , y] ;
end ;
function TRobotField. WallFromRight( x, y: integer ) : boolean ;
begin
CheckTaskCall;
WallFromRight: = VertWalls[ x, y] ;
end ;
function TRobotField. WallFromUp( x, y: integer ) : boolean ;
begin
CheckTaskCall;
WallFromUp: = HorizWalls[ x, y- 1 ] ;
end ;
function TRobotField. WallFromDown( x, y: integer ) : boolean ;
begin
CheckTaskCall;
WallFromDown: = HorizWalls[ x, y] ;
end ;
function TRobotField. CellIsFree( x, y: integer ) : boolean ;
begin
CheckTaskCall;
CellIsFree: = Painted[ x, y] = 0 ;
end ;
function TRobotField. CellIsPainted( x, y: integer ) : boolean ;
begin
CheckTaskCall;
CellIsPainted: = Painted[ x, y] < > 0 ;
end ;
function TRobotField. WallFromLeft: boolean ;
begin
Result : = WallFromLeft( RobotX, RobotY) ;
end ;
function TRobotField. WallFromRight: boolean ;
begin
Result : = WallFromRight( RobotX, RobotY) ;
end ;
function TRobotField. WallFromUp: boolean ;
begin
Result : = WallFromUp( RobotX, RobotY) ;
end ;
function TRobotField. WallFromDown: boolean ;
begin
Result : = WallFromDown( RobotX, RobotY) ;
end ;
function TRobotField. CellIsFree: boolean ;
begin
Result : = CellIsFree( RobotX, RobotY) ;
end ;
function TRobotField. CellIsPainted: boolean ;
begin
Result : = CellIsPainted( RobotX, RobotY) ;
end ;
procedure TRobotField. CheckTaskCall;
begin
if not TaskIsCalled then
2015-12-28 14:25:15 +03:00
RobotError( 'Процедура Task вызова задания должна быть первой' , 'Выполнение программы прервано' ) ;
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. Right;
begin
CheckTaskCall;
if not WallFromRight then
MoveRobot( RobotX+ 1 , RobotY)
2015-12-28 14:25:15 +03:00
else RobotError( 'Робот: врезался в правую стену' ) ;
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. Left;
begin
CheckTaskCall;
if not WallFromLeft then
MoveRobot( RobotX- 1 , RobotY)
2015-12-28 14:25:15 +03:00
else RobotError( 'Робот: врезался в левую стену' ) ;
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. Up;
begin
CheckTaskCall;
if not WallFromUp then
MoveRobot( RobotX, RobotY- 1 )
2015-12-28 14:25:15 +03:00
else RobotError( 'Робот: врезался в верхнюю стену' ) ;
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. Down;
begin
CheckTaskCall;
if not WallFromDown then
MoveRobot( RobotX, RobotY+ 1 )
2015-12-28 14:25:15 +03:00
else RobotError( 'Робот: врезался в нижнюю стену' ) ;
2015-05-14 22:35:07 +03:00
end ;
procedure TRobotField. Paint;
begin
CheckTaskCall;
Inc( movenum) ;
2015-12-28 14:25:15 +03:00
SetSafeLabelStepText( 'Шаг: ' + IntToStr( movenum) ) ;
// labelStep.Text := 'Шаг: ' + IntToStr(movenum);
2015-05-14 22:35:07 +03:00
SetPaintUser( RobotX, RobotY) ;
DrawCell( RobotX, RobotY) ;
end ;
procedure TRobotField. Pause;
begin
Sleep( Interval) ;
end ;
procedure TRobotField. SetDim( DX, DY, CellSz: integer ) ;
begin
Clear;
DimX : = DX;
DimY : = DY;
CellSize : = CellSz;
HorizWall( 1 , 0 , DimX) ;
HorizWall( 1 , DimY, DimX) ;
VertWall( 0 , 1 , DimY) ;
VertWall( DimX, 1 , DimY) ;
// DrawCentered;
end ;
procedure TRobotField. HorizWall( x, y, len: integer ) ;
begin
2017-06-26 21:22:27 +03:00
for var xx: = x to x+ len- 1 do
2015-05-14 22:35:07 +03:00
HorizWalls[ xx, y] : = True ;
end ;
procedure TRobotField. VertWall( x, y, len: integer ) ;
begin
2017-06-26 21:22:27 +03:00
for var yy: = y to y+ len- 1 do
2015-05-14 22:35:07 +03:00
VertWalls[ x, yy] : = True ;
end ;
procedure TRobotField. TaskText( s: string ) ;
begin
//labelZad.Text := s;
//labelZad.Invoke(SetSafeText,s);
SetSafeLabelZadText( s) ;
end ;
procedure TRobotField. SetSpeed( speed: integer ) ;
begin
if speed< 0 then speed : = 0 ;
case speed of
0 : Interval : = 2 * 1 0 2 4 ;
1 : Interval : = 2 * 5 1 2 ;
2 : Interval : = 2 * 2 5 6 ;
3 : Interval : = 2 * 1 2 8 ;
4 : Interval : = 2 * 6 4 ;
5 : Interval : = 2 * 3 2 ;
6 : Interval : = 2 * 1 6 ;
7 : Interval : = 2 * 8 ;
8 : Interval : = 2 * 4 ;
9 : Interval : = 2 * 2 ;
1 0 : Interval : = 2 * 1 ;
1 0 0 0 : Interval : = 0 ;
end ;
if speed> 1 0 then speed : = 1 0 ;
SetSafeTrackBarSpeedValue( speed) ;
end ;
procedure TRobotField. Stop;
begin
2015-12-28 14:25:15 +03:00
buttonStart. Text : = 'Пуск (Enter)' ;
2015-05-14 22:35:07 +03:00
buttonStep. Enabled : = True ;
t. Suspend;
end ;
procedure TRobotField. Start;
begin
2015-12-28 14:25:15 +03:00
buttonStart. Text : = 'Стоп (Enter)' ;
2015-05-14 22:35:07 +03:00
buttonStep. Enabled : = False ;
t. Resume;
end ;
procedure TRobotField. Clear;
begin
2017-06-26 21:22:27 +03:00
for var x: = 1 to Max_DimX do
for var y: = 0 to Max_DimY do
2015-05-14 22:35:07 +03:00
HorizWalls[ x, y] : = False ;
2017-06-26 21:22:27 +03:00
for var x: = 0 to Max_DimX do
for var y: = 1 to Max_DimY do
2015-05-14 22:35:07 +03:00
VertWalls[ x, y] : = False ;
2017-06-26 21:22:27 +03:00
for var x: = 1 to Max_DimX do
for var y: = 1 to Max_DimY do
2015-05-14 22:35:07 +03:00
begin
Painted[ x, y] : = 0 ;
Tags[ x, y] : = False ;
end ;
LastRobotX: = 1 ;
LastRobotY: = 1 ;
{ HorizWall( 1 , 0 , DimX) ;
HorizWall( 1 , DimY, DimX) ;
VertWall( 0 , 1 , DimY) ;
VertWall( DimX, 1 , DimY) ; }
end ;
function TRobotField. IsSolution: boolean ;
label 1 ;
begin
2017-06-26 21:22:27 +03:00
var ID: = True ;
for var x: = 1 to DimX do
for var y: = 1 to DimY do
2015-05-14 22:35:07 +03:00
begin
//ID := ID and (((Tags[x,y]=True) and ((Painted[x,y]=1) or (Painted[x,y]=2))) or ((Tags[x,y]=False) and ((Painted[x,y]=0) or (Painted[x,y]=2))));
ID : = ID and ( ( ( Tags[ x, y] = True ) and ( Painted[ x, y] in [ 1 , 2 ] ) ) or ( ( Tags[ x, y] = False ) and ( Painted[ x, y] in [ 0 , 2 ] ) ) ) ;
if not ID then goto 1 ;
end ;
ID : = ID and ( RobotX= LastRobotX) and ( RobotY= LastRobotY) ;
1 :
Result : = ID;
end ;
2015-12-28 14:25:15 +03:00
//--------- Интерфейс и обработчики
2015-05-14 22:35:07 +03:00
procedure LoadIni( var settings: IniSettings) ;
begin
2017-06-26 21:22:27 +03:00
var Ini : = new TIniFile( IniFileName) ;
2019-01-28 03:30:18 +03:00
settings. Width : = Ini. ReadInteger( 'RobotWindow' , 'Width' , Round( 6 7 9 * ScreenScale) ) ;
settings. Height : = Ini. ReadInteger( 'RobotWindow' , 'Height' , Round( 4 9 0 * ScreenScale) ) ;
2015-05-14 22:35:07 +03:00
settings. Left : = Ini. ReadInteger( 'RobotWindow' , 'Left' , ( Screen. PrimaryScreen. Bounds. Width- settings. Width) div 2 ) ;
settings. Top : = Ini. ReadInteger( 'RobotWindow' , 'Top' , ( Screen. PrimaryScreen. Bounds. Height- settings. Height) div 2 ) ;
2019-01-28 03:30:18 +03:00
if settings. Width> ScreenSize. Width then
settings. Width : = ScreenSize. Width;
2015-05-14 22:35:07 +03:00
2019-01-28 03:30:18 +03:00
if settings. Height> ScreenSize. Height then
settings. Height : = ScreenSize. Height;
2015-05-14 22:35:07 +03:00
if settings. Left < 0 then
settings. Left : = 0 ;
if settings. Top < 0 then
settings. Top : = 0 ;
2019-01-28 03:30:18 +03:00
if ( settings. Left > ScreenSize. Width - 1 0 ) or
( settings. Top > ScreenSize. Height - 1 0 ) then
2015-05-14 22:35:07 +03:00
begin
settings. Left : = 0 ;
settings. Top : = 0 ;
end ;
settings. Speed : = Ini. ReadInteger( 'RobotWindow' , 'Speed' , 3 ) ;
Ini : = nil ;
end ;
procedure SaveIni;
begin
if ( MainForm. Left< 0 ) or ( MainForm. Top< 0 ) then
exit;
2017-06-26 21:22:27 +03:00
var Ini : = new TIniFile( IniFileName) ;
2015-05-14 22:35:07 +03:00
Ini. WriteInteger( 'RobotWindow' , 'Width' , MainForm. Width) ;
Ini. WriteInteger( 'RobotWindow' , 'Height' , MainForm. Height) ;
Ini. WriteInteger( 'RobotWindow' , 'Left' , MainForm. Left) ;
Ini. WriteInteger( 'RobotWindow' , 'Top' , MainForm. Top) ;
Ini. WriteInteger( 'RobotWindow' , 'Speed' , trackBarSpeed. Value) ;
Ini. Save;
end ;
procedure buttonExitClick( o: Object ; e: EventArgs) ;
begin
SaveIni;
halt;
end ;
2017-06-26 21:22:27 +03:00
procedure ABCWindowResize( o: Object ; e: EventArgs) : = CorrectWHLT;
2015-05-14 22:35:07 +03:00
2017-06-26 21:22:27 +03:00
procedure MainWindowClose : = SaveIni;
2015-05-14 22:35:07 +03:00
procedure buttonStartClick( o: Object ; e: EventArgs) ;
begin
2019-02-18 10:36:06 +03:00
if t= nil then
exit;
2015-05-14 22:35:07 +03:00
if t. ThreadState = System. Threading. ThreadState. Suspended then
begin
robField. StepFlag : = False ;
2015-12-28 14:25:15 +03:00
labelExState. Text : = 'Робот: Выполняю задание' ;
2015-05-14 22:35:07 +03:00
robField. Start;
end
else
begin
robField. StepFlag : = True ;
2015-12-28 14:25:15 +03:00
labelExState. Text : = 'Робот: Остановился' ;
2015-05-14 22:35:07 +03:00
robField. Stop;
end ;
( GraphABCControl as Control) . Focus;
end ;
procedure buttonStepClick( o: Object ; e: EventArgs) ;
begin
2019-02-18 10:36:06 +03:00
if t= nil then
exit;
2015-05-14 22:35:07 +03:00
robField. StepFlag : = True ;
t. Resume;
( GraphABCControl as Control) . Focus;
2015-12-28 14:25:15 +03:00
labelExState. Text : = 'Робот: Команда выполнена' ;
2015-05-14 22:35:07 +03:00
end ;
procedure buttonHelpClick( o: Object ; e: EventArgs) ;
begin
2017-06-26 21:22:27 +03:00
MessageBox. Show( HelpStr, 'Исполнитель Робот - Справка' ) ;
2015-05-14 22:35:07 +03:00
( GraphABCControl as Control) . Focus;
end ;
procedure trackBarSpeedScroll( o: Object ; e: EventArgs) ;
begin
robField. SetSpeed( trackBarSpeed. Value) ;
end ;
procedure MainWindowKeyDown( o: Object ; e: KeyEventArgs) ;
begin
if ( e. KeyCode = Keys. Return) and buttonStart. Enabled then
buttonStartClick( o, e)
else if e. KeyCode = Keys. Escape then
buttonExitClick( o, e)
else if ( e. KeyCode = Keys. Space) and buttonStep. Enabled then
buttonStepClick( o, e)
else if ( e. KeyCode = Keys. Right) then
robField. SetSpeed( trackBarSpeed. Value+ 1 )
else if ( e. KeyCode = Keys. Left) then
robField. SetSpeed( trackBarSpeed. Value- 1 )
else if ( e. KeyCode = Keys. F1) then
buttonHelpClick( o, e)
end ;
procedure CorrectWHLT;
begin
2022-12-21 00:12:59 +03:00
if RobField = nil then
exit;
if GraphABCControl = nil then
exit;
2015-05-14 22:35:07 +03:00
if ( RobField. DimX= 0 ) or ( RobField. DimY= 0 ) then
exit;
2019-02-18 10:36:06 +03:00
var mw : = ( GraphABCControl. Width - 3 0 ) div RobField. DimX;
var mh : = ( GraphABCControl. Height - 2 0 ) div RobField. DimY;
2015-05-14 22:35:07 +03:00
RobField. CellSize : = min( mw, mh) ;
if RobField. CellSize mod 2 = 1 then
RobField. CellSize : = RobField. CellSize - 1 ;
RobField. DrawCentered;
end ;
procedure SetTaskCall;
begin
TaskIsCalled : = True ;
end ;
procedure InitControls;
begin
BottomPanel : = new Panel( ) ;
panelBottomLeft : = new Panel( ) ;
buttonHelp : = new Button( ) ;
buttonExit : = new Button( ) ;
buttonStep : = new Button( ) ;
buttonStart : = new Button( ) ;
tableLayoutPanelBottom : = new TableLayoutPanel( ) ;
labelExState : = new TLabel( ) ;
groupBoxExState : = new GroupBox( ) ;
tableLayoutPanel1 : = new TableLayoutPanel( ) ;
labelState : = new TLabel( ) ;
labelStep : = new TLabel( ) ;
trackBarSpeed : = new TrackBar( ) ;
labelSpeed : = new TLabel( ) ;
tableLayoutPanelTop : = new TableLayoutPanel( ) ;
labelZad : = new TLabel( ) ;
// CenterPanel := new Panel();
BottomPanel. SuspendLayout( ) ;
panelBottomLeft. SuspendLayout( ) ;
tableLayoutPanelBottom. SuspendLayout( ) ;
groupBoxExState. SuspendLayout( ) ;
tableLayoutPanelTop. SuspendLayout( ) ;
MainForm. SuspendLayout( ) ;
//
// BottomPanel
//
BottomPanel. Controls. Add( panelBottomLeft) ;
BottomPanel. Controls. Add( groupBoxExState) ;
BottomPanel. Dock : = DockStyle. Bottom;
BottomPanel. Location : = new Point( 0 , 4 0 7 ) ;
2019-01-28 03:30:18 +03:00
BottomPanel. Size : = new Size( 6 7 9 , 8 3 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
//
// panelBottomLeft
//
panelBottomLeft. Anchor : = ( ( System. Windows. Forms. AnchorStyles) ( ( integer( System. Windows. Forms. AnchorStyles. Bottom) or integer( System. Windows. Forms. AnchorStyles. Left) ) ) ) ;
panelBottomLeft. Controls. Add( buttonHelp) ;
panelBottomLeft. Controls. Add( buttonExit) ;
panelBottomLeft. Controls. Add( buttonStep) ;
panelBottomLeft. Controls. Add( buttonStart) ;
panelBottomLeft. Controls. Add( tableLayoutPanelBottom) ;
panelBottomLeft. Location : = new Point( 0 , 0 ) ;
2019-01-28 03:30:18 +03:00
panelBottomLeft. Size : = new Size( 4 7 4 , 8 3 ) * ScreenScale;
var x : = 1 0 ;
var h : = 1 1 6 ;
2015-05-14 22:35:07 +03:00
//
2019-01-28 03:30:18 +03:00
// buttonStart
2015-05-14 22:35:07 +03:00
//
2019-01-28 03:30:18 +03:00
//buttonStart.FlatStyle := FlatStyle.System;
buttonStart. Location : = new Point( x, 1 4 ) * ScreenScale;
buttonStart. Size : = new Size( 1 0 7 , 2 4 ) * ScreenScale;
buttonStart. TabStop : = false ;
buttonStart. Text : = 'Пуск (Enter)' ;
// buttonStart.UseVisualStyleBackColor := true;
x + = h;
2015-05-14 22:35:07 +03:00
//
// buttonStep
//
2019-01-28 03:30:18 +03:00
//buttonStep.FlatStyle := FlatStyle.System;
buttonStep. Location : = new Point( x, 1 4 ) * ScreenScale;
buttonStep. Size : = new Size( 1 0 7 , 2 4 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
buttonStep. TabStop : = false ;
2015-12-28 14:25:15 +03:00
buttonStep. Text : = 'Шаг (Space)' ;
2015-05-14 22:35:07 +03:00
// buttonStep.UseVisualStyleBackColor := true;
2019-01-28 03:30:18 +03:00
x + = h;
2015-05-14 22:35:07 +03:00
//
2019-01-28 03:30:18 +03:00
// buttonExit
2015-05-14 22:35:07 +03:00
//
2019-01-28 03:30:18 +03:00
//buttonExit.FlatStyle := System.Windows.Forms.FlatStyle.System;
buttonExit. Location : = new System. Drawing. Point( x, 1 4 ) * ScreenScale;
buttonExit. Size : = new System. Drawing. Size( 1 0 7 , 2 4 ) * ScreenScale;
buttonExit. TabStop : = false ;
buttonExit. Text : = 'Выход (Esc)' ;
// buttonExit.UseVisualStyleBackColor := true;
x + = h;
//
// buttonHelp
//
//buttonHelp.FlatStyle := System.Windows.Forms.FlatStyle.System;
buttonHelp. Location : = new Point( x, 1 4 ) * ScreenScale;
buttonHelp. Size : = new Size( 1 0 7 , 2 4 ) * ScreenScale;
buttonHelp. TabStop : = false ;
buttonHelp. Text : = 'Справка (F1)' ;
// buttonHelp.UseVisualStyleBackColor := true;
2015-05-14 22:35:07 +03:00
//
// tableLayoutPanelBottom
//
tableLayoutPanelBottom. BackColor : = LabelReadyColor;
tableLayoutPanelBottom. CellBorderStyle : = System. Windows. Forms. TableLayoutPanelCellBorderStyle. Outset;
tableLayoutPanelBottom. ColumnCount : = 1 ;
tableLayoutPanelBottom. ColumnStyles. Add( new ColumnStyle( SizeType. Percent, 5 0 ) ) ;
tableLayoutPanelBottom. Controls. Add( labelExState) ;
tableLayoutPanelBottom. ForeColor : = System. Drawing. Color. White;
2019-01-28 03:30:18 +03:00
tableLayoutPanelBottom. Location : = new Point( 9 , 4 9 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
tableLayoutPanelBottom. RowCount : = 1 ;
tableLayoutPanelBottom. RowStyles. Add( new RowStyle( SizeType. Percent, 5 0 ) ) ;
2019-01-28 03:30:18 +03:00
tableLayoutPanelBottom. Size : = new Size( 4 5 7 , 2 3 ) * ScreenScale;
//tableLayoutPanelBottom.AutoSize := True;
2015-05-14 22:35:07 +03:00
//
// labelExState
//
labelExState. AutoEllipsis : = true ;
labelExState. AutoSize : = true ;
labelExState. Dock : = DockStyle. Fill;
2019-01-28 03:30:18 +03:00
//labelExState.FlatStyle := FlatStyle.System;
labelExState. Font : = new System. Drawing. Font( 'Microsoft Sans Serif' , 8 , System. Drawing. FontStyle. Bold{, System.Drawing.GraphicsUnit.Point, ((byte)(204))} ) ;
2015-05-14 22:35:07 +03:00
labelExState. Location : = new Point( 5 , 2 ) ;
2019-01-28 03:30:18 +03:00
labelExState. Margin : = new Padding( 3 , 3 , 3 , 3 ) ;
labelExState. Size : = new Size( 4 5 3 , 1 5 ) * ScreenScale;
2015-12-28 14:25:15 +03:00
labelExState. Text : = 'Робот: Готов' ;
2015-05-14 22:35:07 +03:00
labelExState. TextAlign : = ContentAlignment. MiddleCenter;
//
// groupBoxExState
//
groupBoxExState. Controls. Add( tableLayoutPanel1) ;
groupBoxExState. Controls. Add( labelState) ;
groupBoxExState. Controls. Add( labelStep) ;
groupBoxExState. Controls. Add( trackBarSpeed) ;
groupBoxExState. Controls. Add( labelSpeed) ;
groupBoxExState. Dock : = DockStyle. Right;
2019-01-28 03:30:18 +03:00
groupBoxExState. Location : = new Point( 4 7 5 , 0 ) * ScreenScale;
groupBoxExState. Size : = new Size( 2 0 4 , 8 3 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
groupBoxExState. TabStop : = false ;
//
// tableLayoutPanel1
//
tableLayoutPanel1. BackColor : = LabelDoColor;
tableLayoutPanel1. CellBorderStyle : = TableLayoutPanelCellBorderStyle. Outset;
tableLayoutPanel1. ColumnCount : = 1 ;
tableLayoutPanel1. ColumnStyles. Add( new ColumnStyle( System. Windows. Forms. SizeType. Percent, 5 0 ) ) ;
2019-01-28 03:30:18 +03:00
tableLayoutPanel1. Location : = new Point( 7 8 , 5 0 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
tableLayoutPanel1. RowCount : = 1 ;
tableLayoutPanel1. RowStyles. Add( new RowStyle( System. Windows. Forms. SizeType. Percent, 5 0 ) ) ;
2019-01-28 03:30:18 +03:00
tableLayoutPanel1. Size : = new Size( 2 2 , 2 2 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
//
// labelState
//
labelState. AutoSize : = true ;
2019-01-28 03:30:18 +03:00
labelState. Location : = new Point( 6 , 5 4 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
labelState. Margin : = new Padding( 0 ) ;
2019-01-28 03:30:18 +03:00
labelState. Size : = new Size( 8 3 , 1 7 ) * ScreenScale;
2015-12-28 14:25:15 +03:00
labelState. Text : = 'Состояние:' ;
2015-05-14 22:35:07 +03:00
//
// labelStep
//
labelStep. BackColor : = SystemColors. Control;
2019-01-28 03:30:18 +03:00
//labelStep.Font := new System.Drawing.Font('Microsoft Sans Serif', 8, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
2015-05-14 22:35:07 +03:00
labelStep. ForeColor : = System. Drawing. Color. Black;
2019-01-28 03:30:18 +03:00
labelStep. Location : = new Point( 1 3 0 , 5 4 ) * ScreenScale;
labelStep. Size : = new Size( 6 6 , 1 8 ) * ScreenScale;
2015-12-28 14:25:15 +03:00
labelStep. Text : = 'Шаг: 0' ;
2019-01-28 03:30:18 +03:00
//labelStep.TextAlign := ContentAlignment.MiddleLeft;
2015-05-14 22:35:07 +03:00
//
// trackBarSpeed
//
trackBarSpeed. CausesValidation : = false ;
trackBarSpeed. LargeChange : = 1 ;
2019-01-28 03:30:18 +03:00
trackBarSpeed. Location : = new Point( 7 2 , 1 1 ) * ScreenScale;
trackBarSpeed. Size : = new Size( 1 2 1 , 5 3 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
trackBarSpeed. TabStop : = false ;
//
// labelSpeed
//
labelSpeed. AutoSize : = true ;
2019-01-28 03:30:18 +03:00
labelSpeed. Location : = new Point( 6 , 1 6 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
labelSpeed. Margin : = new Padding( 0 ) ;
2019-01-28 03:30:18 +03:00
labelSpeed. Size : = new Size( 7 3 , 1 7 ) * ScreenScale;
2015-12-28 14:25:15 +03:00
labelSpeed. Text : = 'Скорость:' ;
2015-05-14 22:35:07 +03:00
//
// tableLayoutPanelTop
//
tableLayoutPanelTop. BackColor : = System. Drawing. Color. FromArgb( 2 3 8 , 2 3 8 , 2 3 8 ) ;
tableLayoutPanelTop. CellBorderStyle : = TableLayoutPanelCellBorderStyle. Outset;
tableLayoutPanelTop. ColumnCount : = 1 ;
tableLayoutPanelTop. ColumnStyles. Add( new ColumnStyle( System. Windows. Forms. SizeType. Percent, 5 0 ) ) ;
tableLayoutPanelTop. Controls. Add( labelZad) ;
tableLayoutPanelTop. Dock : = DockStyle. Top;
tableLayoutPanelTop. Location : = new Point( 0 , 0 ) ;
tableLayoutPanelTop. RowCount : = 1 ;
tableLayoutPanelTop. RowStyles. Add( new RowStyle( System. Windows. Forms. SizeType. Percent, 5 0 ) ) ;
2019-01-28 03:30:18 +03:00
tableLayoutPanelTop. AutoSize : = True ;
tableLayoutPanelTop. Size : = new Size( 6 7 9 , 2 3 ) * ScreenScale;
2015-05-14 22:35:07 +03:00
//
// labelZad
//
labelZad. AutoEllipsis : = true ;
2019-01-28 03:30:18 +03:00
//labelZad.AutoSize := true;
2015-05-14 22:35:07 +03:00
labelZad. Dock : = DockStyle. Fill;
2019-01-28 03:30:18 +03:00
//labelZad.FlatStyle := FlatStyle.System;
labelZad. Font : = new System. Drawing. Font( 'Microsoft Sans Serif' , 8 , System. Drawing. FontStyle. Bold{, System.Drawing.GraphicsUnit.Point, ((byte)(204))} ) ;
2015-05-14 22:35:07 +03:00
labelZad. ForeColor : = SystemColors. HotTrack;
labelZad. Location : = new Point( 6 , 3 ) ;
labelZad. Margin : = new Padding( 4 , 1 , 3 , 0 ) ;
2019-01-28 03:30:18 +03:00
labelZad. Size : = new Size( 6 6 8 , 1 4 ) * ScreenScale;
2015-12-28 14:25:15 +03:00
labelZad. Text : = 'Задание' ;
2015-05-14 22:35:07 +03:00
labelZad. TextAlign : = ContentAlignment. MiddleLeft;
//
// ExecutorForm
//
MainForm. BackColor : = SystemColors. Control;
// MainWindow.ClientSize := new Size(679, 490);
MainForm. Controls. Add( tableLayoutPanelTop) ;
MainForm. Controls. Add( BottomPanel) ;
2019-01-28 03:30:18 +03:00
var ssz : = 6 9 2 ;
var sw : = ScreenSize. Width;
var ww : = ssz* ScreenScale;
if ww> sw then
ssz : = Round( sw/ ScreenScale) - 1 0 ;
MainForm. MinimumSize : = new Size( ssz, 2 4 0 ) * ScreenScale; // Уменьшить до размера экрана!!!
2015-12-28 14:25:15 +03:00
MainForm. Text : = 'Исполнитель Робот' ;
2015-05-14 22:35:07 +03:00
BottomPanel. ResumeLayout( false ) ;
panelBottomLeft. ResumeLayout( false ) ;
tableLayoutPanelBottom. ResumeLayout( false ) ;
tableLayoutPanelBottom. PerformLayout( ) ;
groupBoxExState. ResumeLayout( false ) ;
groupBoxExState. PerformLayout( ) ;
tableLayoutPanelTop. ResumeLayout( false ) ;
tableLayoutPanelTop. PerformLayout( ) ;
MainForm. ResumeLayout( false ) ;
MainForm. PerformLayout( ) ;
MainForm. KeyPreview : = True ;
MainForm. KeyDown + = MainWindowKeyDown;
( GraphABCControl as Control) . Resize + = ABCWindowResize;
buttonStart. Click + = buttonStartClick;
buttonStep. Click + = buttonStepClick;
buttonHelp. Click + = buttonHelpClick;
buttonExit. Click + = buttonExitClick;
trackBarSpeed. Scroll + = trackBarSpeedScroll;
end ;
procedure NonSafeRobotError( s: string ) ;
begin
buttonStart. Enabled : = False ;
buttonStep. Enabled : = False ;
tableLayoutPanel1. BackColor : = LabelErrorColor;
labelExState. BackColor : = LabelErrorColor;
labelExState. Text : = s;
tableLayoutPanelBottom. BackColor : = LabelErrorColor;
t. Suspend;
end ;
procedure RobotError( s: string ) ;
begin
buttonStart. Invoke( NonSafeRobotError, s) ;
end ;
procedure RobotError( s, s1: string ) ;
begin
//labelZad.Text := s1;
SetSafeLabelZadText( s1) ;
RobotError( s) ;
end ;
procedure SetWindowBounds( rec: System. Drawing. Rectangle) ;
begin
MainForm. Bounds : = rec;
end ;
2015-12-28 14:25:15 +03:00
// Добавил - М А
2015-05-14 22:35:07 +03:00
procedure ResRB( TaskName: string ) ;
external '%PABCSYSTEM%\PT4\PT4PABC.dll' name 'resrb' ;
//
procedure FinalizeSafe;
begin
buttonStart. Enabled : = False ;
buttonStep. Enabled : = False ;
if ( robField. DimX* robField. DimY= 0 ) then
2015-12-28 14:25:15 +03:00
RobotError( 'Робот: Н е вызвана процедура Task' , 'Задание отсутствует' )
2015-05-14 22:35:07 +03:00
else if robField. IsSolution then
begin
tableLayoutPanel1. BackColor : = LabelGoodEndColor;
labelExState. BackColor : = LabelGoodEndColor;
tableLayoutPanelBottom. BackColor : = LabelGoodEndColor;
2015-12-28 14:25:15 +03:00
labelExState. Text : = 'Робот: Задание выполнено' ;
// Добавил - М А
2015-05-14 22:35:07 +03:00
try
ResRB( robField. TaskName) ;
except
end ;
//
end
2017-09-09 17:43:43 +03:00
else
if RobField. TaskName = '' then
labelExState. Text : = 'Робот: Работа окончена'
else
labelExState. Text : = 'Робот: Работа окончена, задание не выполнено' ;
2015-05-14 22:35:07 +03:00
end ;
var
settings: IniSettings;
var __initialized : = false ;
var __finalized : = false ;
procedure __InitModule;
begin
RPaintColor : = RGB( 0 , 2 0 0 , 0 ) ;
RobotColor : = RGB( 2 5 5 , 2 5 5 , 2 2 0 ) ;
RobotColor1 : = RGB( 2 0 0 , 2 5 5 , 2 0 0 ) ;
RBorderColor : = RGB( 1 , 1 , 1 ) ;
BackColor : = MainForm. BackColor;
LabelReadyColor : = RGB( 9 5 , 1 0 9 , 1 5 4 ) ;
LabelDoColor : = RGB( 9 5 , 1 0 9 , 1 5 4 ) ;
LabelStopColor : = RGB( 9 5 , 1 0 9 , 1 5 4 ) ;
LabelErrorColor : = clRed;
LabelBadEndColor : = clBlack;
LabelGoodEndColor: = RGB( 0 , 1 5 6 , 0 ) ;
TaskIsCalled : = False ;
2022-09-17 09:13:04 +03:00
ScreenScale : = GraphABC. ScreenScale;
2015-05-14 22:35:07 +03:00
Brush. Color : = MainForm. BackColor;
FillRectangle( 0 , 0 , 1 2 8 0 , 1 0 2 4 ) ;
2019-02-18 10:36:06 +03:00
Pen. RoundCap : = True ;
2015-05-14 22:35:07 +03:00
2024-07-05 23:04:23 +03:00
try
LoadIni( settings) ;
MainForm. Invoke( SetWindowBounds, new System. Drawing. Rectangle( settings. Left, settings. Top, settings. Width, settings. Height) ) ;
except
end ;
2022-09-17 09:13:04 +03:00
2019-01-28 03:30:18 +03:00
//var (sw,sh) := ScreenSize;
MainForm. Invoke( InitControls) ;
2015-05-14 22:35:07 +03:00
OnClose : = MainWindowClose;
// CenterWindow;
RobField : = new TRobotField( 0 , 0 , 5 0 ) ;
2019-01-28 03:30:18 +03:00
2015-05-14 22:35:07 +03:00
t : = System. Threading. Thread. CurrentThread;
robField. SetSpeed( settings. Speed) ;
//MainWindow.Bounds := new System.Drawing.Rectangle(settings.Left,settings.Top,settings.Width,settings.Height);
2016-07-14 21:35:40 +03:00
var del : procedure : = MainForm. Show;
MainForm. Invoke( del) ;
2015-05-14 22:35:07 +03:00
end ;
procedure __InitModule__;
begin
if not __initialized then
begin
__initialized : = true ;
GraphABC. __InitModule__;
__InitModule;
end ;
end ;
procedure __FinalizeModule;
begin
MainForm. Invoke( FinalizeSafe) ;
end ;
procedure __FinalizeModule__;
begin
if not __finalized then
begin
__finalized : = true ;
__FinalizeModule;
end ;
end ;
initialization
__InitModule;
finalization
__FinalizeModule;
end .