1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
| procedure TForm1.MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i,j: Byte;
xx,yy,xt,yt,sx,sy:Integer;
w:Real;
begin
for i:=1 to k do
if (shapes[i]<>nil) then
if (Sender as TShape).Name = shapes[i].Name Then
begin
A:=shapes[i];
q:=i;
end;
if ((Put.Down) or (Strela.Down)) and (Button=mbLeft) then
begin
Izmenen:=true;
col:=col+1;
x1:=A.Left+15;
y1:=A.Top+15;
if (col=1) then
begin
Canvas.Pen.Mode:=pmNotXor;
xn:=x1;
yn:=y1;
xk:=x1;
yk:=y1;
numbeg:=q;
N:=A;
end;
if (col=2) then
with Canvas do
begin
MoveTo(xn,yn);
LineTo(xk,yk);
numend:=q;
Pen.Mode:=pmCopy;
if (N<>A) then
begin
if (abs(x1-xn)>0) then
begin
if (N.Left<A.Left) then
begin
xx:=round(15/sqrt(1+sqr(y1-yn)/sqr(x1-xn))+xn);
xk:=round(-15/sqrt(1+sqr(yn-y1)/sqr(xn-x1))+x1);
end
else
begin
xx:=round(-15/sqrt(1+sqr(y1-yn)/sqr(x1-xn))+xn);
xk:=round(15/sqrt(1+sqr(yn-y1)/sqr(xn-x1))+x1);
end;
end
else
begin
xx:=x1;
xk:=xn;
end;
if (N.Top<A.Top) then
begin
yy:=round(sqrt(225-sqr(xx-xn)) + yn);
yk:=round(-sqrt(225-sqr(xk-x1)) + y1);
end
else
begin
yy:=round(-sqrt(225-sqr(xx-xn)) + yn);
yk:=round(sqrt(225-sqr(xk-x1)) + y1);
end;
MoveTo(xx,yy);
LineTo(xk,yk);
Form2.ShowModal;
xt:=round((xx+xk)/2);
yt:=round((yy+yk)/2);
Mas[numbeg,numend]:=StrToInt(s);
if Strela.Down then
begin
Mas[numend,numbeg]:=0;
MoveTo(xk,yk);
w:=(yk-yy)/(xk-xx);
if xx<xk then
begin
sx:=round(xk+8*Cos(ArcTan(w)+8*pi/9));
sy:=round(8*Sin(ArcTan(w)+8*pi/9)+yk);
end
else
begin
sx:=round(xk+8*Cos(ArcTan(w)+pi/9));
sy:=round(8*Sin(ArcTan(w)+pi/9)+yk);
end;
LineTo(sx,sy);
MoveTo(xk,yk);
if xx<xk then
begin
sx:=round(xk+8*Cos(ArcTan(w)+10*pi/9));
sy:=round(8*Sin(ArcTan(w)+10*pi/9)+yk);
end
else
begin
sx:=round(xk+8*Cos(ArcTan(w)-pi/9));
sy:=round(8*Sin(ArcTan(w)-pi/9)+yk);
end;
LineTo(sx,sy);
end
else
Mas[numend,numbeg]:=StrToInt(s);
TextOut(xt,yt,s);
end;
col:=0; N:=nil;
end;
end;
if (InsertButton.Down) and (Button=mbLeft) then
begin
if (q=one) or (q=two) then
begin
if (q=one) then
begin
shapes[one].Brush.Color:=clSkyBlue;
one:=two;
two:=0;
end;
if (q=two) then
begin
shapes[two].Brush.Color:=clSkyBlue;
two:=0;
end;
end
else
begin
if (one=0) then
begin
one:=q;
A.Brush.Color:=clRed;
end
else if (two=0) then
begin
two:=q;
A.Brush.Color:=clRed;
end
else
begin
shapes[one].Brush.Color:=clSkyBlue;
shapes[two].Brush.Color:=clSkyBlue;
one:=q;
A.Brush.Color:=clRed;
two:=0;
end;
end;
for i:=1 to k do
for j:=1 to k do
begin
AlgD[i,j]:=0;
AlgF[i,j]:=0;
end;
Invalidate();
end;
if (Del.Down) and (Button=mbLeft) then
begin
if (one=0) and (two=0) then
begin
Izmenen:=true;
ObnovClick(Sender);
shapes[q].Free;
shapes[q]:=nil;
for i:=1 to k do
begin
Mas[i,q]:=0;
Mas[q,i]:=0;
end;
Poradok();
A:=nil;
end
else MessageBox(Handle,'Снимите выделение!','Ошибка',MB_OK+MB_ICONWARNING);
end;
if (Per.Down) and (Button=mbLeft) then
begin
Izmenen:=true;
FMouseState:= msDragging;
OldPos:= Point(X, Y);
Screen.Cursor:=crDrag;
Circ:=TShape.Create(Self);
Circ.Shape:=stCircle;
Circ.Width:=30;
Circ.Height:=30;
Circ.Left:=A.Left;
Circ.Top:=A.Top;
Circ.Brush.Color:=A.Brush.Color;
Circ.Pen.Width:=2;
Circ.Parent:=Form1;
Circ.OnMouseMove:=MouseMove;
Circ.OnMouseUp:=MouseUp;
mycolor:=A.Brush.Color;
A.Brush.Color:=clAqua;
end;
end; |