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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
| #pragma once
#include <cmath>
#include "Circle.h"
namespace Circ {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace std;
/// <summary>
/// Сводка для Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
private: System::Windows::Forms::PictureBox^ PCircle;
public:
public:
int count;
Circle *circles;
Form1(void)
{
InitializeComponent();
//
//TODO: добавьте код конструктора
//
}
protected:
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ LX;
protected:
private: System::Windows::Forms::Label^ LY;
private: System::Windows::Forms::ListBox^ ListX;
private: System::Windows::Forms::ListBox^ ListY;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ TX;
private: System::Windows::Forms::TextBox^ TY;
private: System::Windows::Forms::Button^ Send;
private: System::Windows::Forms::Button^ Then;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ TNC;
private: System::Windows::Forms::Button^ Next;
private: System::Windows::Forms::RichTextBox^ Errors;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ Rad;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::ListBox^ ListRad;
private:
/// <summary>
/// Требуется переменная конструктора.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Обязательный метод для поддержки конструктора - не изменяйте
/// содержимое данного метода при помощи редактора кода.
/// </summary>
void InitializeComponent(void)
{
this->LX = (gcnew System::Windows::Forms::Label());
this->LY = (gcnew System::Windows::Forms::Label());
this->ListX = (gcnew System::Windows::Forms::ListBox());
this->ListY = (gcnew System::Windows::Forms::ListBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->TX = (gcnew System::Windows::Forms::TextBox());
this->TY = (gcnew System::Windows::Forms::TextBox());
this->Send = (gcnew System::Windows::Forms::Button());
this->Then = (gcnew System::Windows::Forms::Button());
this->label3 = (gcnew System::Windows::Forms::Label());
this->TNC = (gcnew System::Windows::Forms::TextBox());
this->Next = (gcnew System::Windows::Forms::Button());
this->Errors = (gcnew System::Windows::Forms::RichTextBox());
this->label4 = (gcnew System::Windows::Forms::Label());
this->Rad = (gcnew System::Windows::Forms::TextBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->ListRad = (gcnew System::Windows::Forms::ListBox());
this->PCircle = (gcnew System::Windows::Forms::PictureBox());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->PCircle))->BeginInit();
this->SuspendLayout();
//
// LX
//
this->LX->AutoSize = true;
this->LX->Location = System::Drawing::Point(300, 110);
this->LX->Name = L"LX";
this->LX->Size = System::Drawing::Size(79, 13);
this->LX->TabIndex = 0;
this->LX->Text = L"Координаты Х";
//
// LY
//
this->LY->AutoSize = true;
this->LY->Location = System::Drawing::Point(454, 110);
this->LY->Name = L"LY";
this->LY->Size = System::Drawing::Size(79, 13);
this->LY->TabIndex = 0;
this->LY->Text = L"Координаты Y";
//
// ListX
//
this->ListX->FormattingEnabled = true;
this->ListX->Location = System::Drawing::Point(280, 126);
this->ListX->Name = L"ListX";
this->ListX->Size = System::Drawing::Size(120, 17);
this->ListX->TabIndex = 1;
//
// ListY
//
this->ListY->FormattingEnabled = true;
this->ListY->Location = System::Drawing::Point(428, 126);
this->ListY->Name = L"ListY";
this->ListY->Size = System::Drawing::Size(120, 17);
this->ListY->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(15, 110);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(77, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"Координата Х";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(15, 133);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(77, 13);
this->label2->TabIndex = 0;
this->label2->Text = L"Координата Y";
//
// TX
//
this->TX->Location = System::Drawing::Point(143, 107);
this->TX->Name = L"TX";
this->TX->Size = System::Drawing::Size(100, 20);
this->TX->TabIndex = 2;
//
// TY
//
this->TY->Location = System::Drawing::Point(143, 130);
this->TY->Name = L"TY";
this->TY->Size = System::Drawing::Size(100, 20);
this->TY->TabIndex = 2;
//
// Send
//
this->Send->Location = System::Drawing::Point(72, 179);
this->Send->Name = L"Send";
this->Send->Size = System::Drawing::Size(75, 23);
this->Send->TabIndex = 3;
this->Send->Text = L"Отправить";
this->Send->UseVisualStyleBackColor = true;
this->Send->Click += gcnew System::EventHandler(this, &Form1::Send_Click);
//
// Then
//
this->Then->Location = System::Drawing::Point(446, 153);
this->Then->Name = L"Then";
this->Then->Size = System::Drawing::Size(87, 36);
this->Then->TabIndex = 4;
this->Then->Text = L"Продолжить работу";
this->Then->UseVisualStyleBackColor = true;
this->Then->Click += gcnew System::EventHandler(this, &Form1::Then_Click);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(12, 15);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(135, 13);
this->label3->TabIndex = 5;
this->label3->Text = L"Количество окружностей";
//
// TNC
//
this->TNC->Location = System::Drawing::Point(160, 12);
this->TNC->Name = L"TNC";
this->TNC->Size = System::Drawing::Size(100, 20);
this->TNC->TabIndex = 2;
//
// Next
//
this->Next->Location = System::Drawing::Point(108, 48);
this->Next->Name = L"Next";
this->Next->Size = System::Drawing::Size(75, 23);
this->Next->TabIndex = 6;
this->Next->Text = L"Далее";
this->Next->UseVisualStyleBackColor = true;
this->Next->Click += gcnew System::EventHandler(this, &Form1::Next_Click);
//
// Errors
//
this->Errors->Location = System::Drawing::Point(266, 12);
this->Errors->Name = L"Errors";
this->Errors->Size = System::Drawing::Size(438, 78);
this->Errors->TabIndex = 7;
this->Errors->Text = L"";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(15, 156);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(43, 13);
this->label4->TabIndex = 0;
this->label4->Text = L"Радиус";
//
// Rad
//
this->Rad->Location = System::Drawing::Point(143, 153);
this->Rad->Name = L"Rad";
this->Rad->Size = System::Drawing::Size(100, 20);
this->Rad->TabIndex = 2;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(604, 110);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(51, 13);
this->label5->TabIndex = 0;
this->label5->Text = L"Радиусы";
//
// ListRad
//
this->ListRad->FormattingEnabled = true;
this->ListRad->Location = System::Drawing::Point(578, 126);
this->ListRad->Name = L"ListRad";
this->ListRad->Size = System::Drawing::Size(120, 17);
this->ListRad->TabIndex = 1;
//
// PCircle
//
this->PCircle->Location = System::Drawing::Point(-3, 208);
this->PCircle->Name = L"PCircle";
this->PCircle->Size = System::Drawing::Size(722, 370);
this->PCircle->TabIndex = 8;
this->PCircle->TabStop = false;
this->PCircle->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::PCircle_Paint);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(716, 577);
this->Controls->Add(this->PCircle);
this->Controls->Add(this->Errors);
this->Controls->Add(this->Next);
this->Controls->Add(this->label3);
this->Controls->Add(this->Then);
this->Controls->Add(this->Send);
this->Controls->Add(this->Rad);
this->Controls->Add(this->TY);
this->Controls->Add(this->TNC);
this->Controls->Add(this->TX);
this->Controls->Add(this->ListRad);
this->Controls->Add(this->ListY);
this->Controls->Add(this->ListX);
this->Controls->Add(this->label4);
this->Controls->Add(this->label5);
this->Controls->Add(this->label2);
this->Controls->Add(this->LY);
this->Controls->Add(this->label1);
this->Controls->Add(this->LX);
this->Name = L"Form1";
this->Text = L"Ввод данных";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->PCircle))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Next_Click(System::Object^ sender, System::EventArgs^ e) {
if(TNC->Text->Length==0){
Errors->Text="Введите количество окружностей!";
}
else if(Convert::ToInt32(TNC->Text)>=1){
Errors->Text="";
int numOfCircles=Convert::ToInt32(TNC->Text);
TNC->Enabled=false;
Next->Enabled=false;
LX->Visible=true;
LY->Visible=true;
label5->Visible=true;
ListX->Visible=true;
ListY->Visible=true;
ListRad->Visible=true;
label1->Visible=true;
label2->Visible=true;
label4->Visible=true;
TX->Visible=true;
TY->Visible=true;
Rad->Visible=true;
Send->Visible=true;
Errors->Text="Теперь вводите координаты центра и радиус для каждой окружности (они могут быть дробными числами). После ввода нажмите кнопку 'Отправить'. После этого продолжайте ввод данных для следующих окружностей, пока не появится кнопка 'Продолжить работу'.";
}
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Errors->ReadOnly=true;
LX->Visible=false;
LY->Visible=false;
label5->Visible=false;
ListX->Visible=false;
ListY->Visible=false;
ListRad->Visible=false;
label1->Visible=false;
label2->Visible=false;
label4->Visible=false;
TX->Visible=false;
TY->Visible=false;
Rad->Visible=false;
Send->Visible=false;
Then->Visible=false;
Errors->Text="Количество окружностей не должно быть меньше 1 и не может быть дробным числом!";
}
private: System::Void Send_Click(System::Object^ sender, System::EventArgs^ e) {
if((TX->Text->Length==0)|(TY->Text->Length==0)|(Rad->Text->Length==0)){
Errors->Text="Вы забыли ввести одно или несколько значений.";
}
else if((count<Convert::ToInt32(TNC->Text))&(Convert::ToInt32(TX->Text)>0)&(Convert::ToInt32(TY->Text)>0)&(Convert::ToInt32(Rad->Text)>0)){
count++;
ListX->Items->Add(TX->Text);
ListY->Items->Add(TY->Text);
ListRad->Items->Add(Rad->Text);
}
else{
Errors->Text="Все значения должны быть больше 0.";
}
if(count==Convert::ToInt32(TNC->Text)){
TX->Enabled=false;
TY->Enabled=false;
Rad->Enabled=false;
Send->Enabled=false;
Then->Visible=true;
}
}
private: System::Void Then_Click(System::Object^ sender, System::EventArgs^ e) {
Circle *circles=new Circle[Convert::ToInt32(TNC->Text)];
for(int counter=0;counter<Convert::ToInt32(TNC->Text);counter++){
Circle circ;
ListX->SelectedIndex=counter;
ListY->SelectedIndex=counter;
ListRad->SelectedIndex=counter;
circ.Set_x(Convert::ToDouble(ListX->SelectedItem));
circ.Set_y(Convert::ToDouble(ListY->SelectedItem));
circ.Set_radius(Convert::ToDouble(ListRad->SelectedItem));
circles[counter]=circ;
}
for(int counter=0;counter<Convert::ToInt32(TNC->Text);counter++){
double X=circles[counter].Get_x();
double Y=circles[counter].Get_y();
double RADIUS=circles[counter].Get_radius();
for(int innerCounter=0;innerCounter<Convert::ToInt32(TNC->Text);innerCounter++){
if(counter!=innerCounter){
double inX=circles[innerCounter].Get_x();
double inY=circles[innerCounter].Get_y();
double inRADIUS=circles[innerCounter].Get_radius();
double d=sqrt(pow(X-inX,2)+pow(Y-inY,2));
if(d<abs(RADIUS-inRADIUS)){
circles[counter].Set_cross(true);
break;
}
else if(d>(RADIUS+inRADIUS)){
}
else{
circles[counter].Set_cross(true);
break;
}
}
}
}
Then->Enabled=false;
}
private: System::Void PCircle_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Pen^ pen=gcnew Pen(Color::Black);
e->Graphics->DrawEllipse(pen, 1.45, 8, 8, 8);
}
};
} |