-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyForm.h
743 lines (723 loc) · 47.7 KB
/
MyForm.h
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
// çàãîëîâíèé ôàéë äëÿ ðåàë³çàö³¿ ³íòåðôåéñó ãîëîâíîãî â³êíà
#include "calc.h"
#include "InvForm.h"
#pragma once
namespace IP54_Chyzh {
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 System::IO;
using namespace msclr::interop;
using namespace System::Diagnostics;
/// <summary>
/// Ñâîäêà äëÿ MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form {
public:
MyForm(void) {
InitializeComponent();
//TODO: äîáàâüòå êîä êîíñòðóêòîðà
}
protected:
~MyForm() { // Îñâîáîäèòü âñå èñïîëüçóåìûå ðåñóðñû.
if (components) {
delete components;
}
}
protected:
// ãîëîâíå ìåíþ
private: System::Windows::Forms::MenuStrip^ menuStripGlav;
// ïóíêòè ãîëîâíîãî ìåíþ (ç ï³äïóíêòàìè)
private: System::Windows::Forms::ToolStripMenuItem^ mFile;
private: System::Windows::Forms::ToolStripMenuItem^ mNewTask;
private: System::Windows::Forms::ToolStripMenuItem^ mOpen;
private: System::Windows::Forms::ToolStripMenuItem^ mRandom;
private: System::Windows::Forms::ToolStripMenuItem^ mCalc;
private: System::Windows::Forms::ToolStripMenuItem^ mHelp;
private: System::Windows::Forms::ToolStripMenuItem^ mAutor;
private: System::Windows::Forms::ToolStripMenuItem^ mRegulations;
private: System::Windows::Forms::ToolStripMenuItem^ mExit;
// êíîïêè ä³é
private: System::Windows::Forms::Button^ bNewTask;
private: System::Windows::Forms::Button^ bRandom;
private: System::Windows::Forms::Button^ bOpen;
private: System::Windows::Forms::Button^ bCalc;
// øàð (ë³âèé), ùî îá'ºäíóº âñ³ êíîïêè ä³é
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanelLeft;
// GroupBox ç äâîì RadioButton-íàìè âèáîðó ìåòîäó îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³
private: System::Windows::Forms::GroupBox^ groupBoxMetod;
private: System::Windows::Forms::RadioButton^ radioShulc;
private: System::Windows::Forms::RadioButton^ radioGaus;
// øàð, ùî îá'ºäíóº íàïèñ ³ NumericUpDown äëÿ ââåäåííÿ ðîçì³ðíîñò³ ìàòðèö³
private: System::Windows::Forms::Label^ labelSize;
private: System::Windows::Forms::NumericUpDown^ matrixSize;
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanelMatrixSize;
private: System::Windows::Forms::DataGridView^ matrix_table;
// DataGridView äëÿ ââåäåííÿ çíà÷åíü åëåìåíò³â âõ³äíî¿ ìàòðèö³
// øàð (ïðàâèé), ùî îá'ºäíóº øàðè GroupBox, tableLayoutPanelMatrixSize òà DataGridView
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanelRigth;
// øàð, ùî îá'ºäíóº ë³âèé ³ ïðàâèé øàðè
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutGlav;
private: System::Windows::Forms::ToolStripMenuItem^ mSaveTask;
private: System::ComponentModel::IContainer^ components;
#pragma region Windows Form Designer generated code
// ------------ Îáÿçàòåëüíûé ìåòîä äëÿ ïîääåðæêè êîíñòðóêòîðà (íå èçìåíÿéòå ñîäåðæèìîå äàííîãî ìåòîäà ïðè ïîìîùè ðåäàêòîðà êîäà) ------------
void InitializeComponent(void) {
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
this->menuStripGlav = (gcnew System::Windows::Forms::MenuStrip());
this->mFile = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mNewTask = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mOpen = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mRandom = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mCalc = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mSaveTask = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mHelp = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mAutor = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mRegulations = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->mExit = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->bRandom = (gcnew System::Windows::Forms::Button());
this->bOpen = (gcnew System::Windows::Forms::Button());
this->bNewTask = (gcnew System::Windows::Forms::Button());
this->bCalc = (gcnew System::Windows::Forms::Button());
this->tableLayoutPanelLeft = (gcnew System::Windows::Forms::TableLayoutPanel());
this->groupBoxMetod = (gcnew System::Windows::Forms::GroupBox());
this->radioShulc = (gcnew System::Windows::Forms::RadioButton());
this->radioGaus = (gcnew System::Windows::Forms::RadioButton());
this->tableLayoutPanelMatrixSize = (gcnew System::Windows::Forms::TableLayoutPanel());
this->labelSize = (gcnew System::Windows::Forms::Label());
this->matrixSize = (gcnew System::Windows::Forms::NumericUpDown());
this->tableLayoutGlav = (gcnew System::Windows::Forms::TableLayoutPanel());
this->tableLayoutPanelRigth = (gcnew System::Windows::Forms::TableLayoutPanel());
this->matrix_table = (gcnew System::Windows::Forms::DataGridView());
this->menuStripGlav->SuspendLayout();
this->tableLayoutPanelLeft->SuspendLayout();
this->groupBoxMetod->SuspendLayout();
this->tableLayoutPanelMatrixSize->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrixSize))->BeginInit();
this->tableLayoutGlav->SuspendLayout();
this->tableLayoutPanelRigth->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrix_table))->BeginInit();
this->SuspendLayout();
//
// menuStripGlav
//
this->menuStripGlav->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {
this->mFile, this->mHelp,
this->mExit
});
this->menuStripGlav->Location = System::Drawing::Point(0, 0);
this->menuStripGlav->Name = L"menuStripGlav";
this->menuStripGlav->Size = System::Drawing::Size(804, 27);
this->menuStripGlav->TabIndex = 3;
this->menuStripGlav->Text = L"menuStrip1";
//
// mFile
//
this->mFile->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {
this->mNewTask, this->mOpen,
this->mRandom, this->mCalc, this->mSaveTask
});
this->mFile->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->mFile->Name = L"mFile";
this->mFile->Size = System::Drawing::Size(61, 23);
this->mFile->Text = L"&Ôàéë";
//
// mNewTask
//
this->mNewTask->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mNewTask.Image")));
this->mNewTask->Name = L"mNewTask";
this->mNewTask->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::N));
this->mNewTask->Size = System::Drawing::Size(379, 24);
this->mNewTask->Text = L"Íîâå çàâäàííÿ";
this->mNewTask->Click += gcnew System::EventHandler(this, &MyForm::NewTask_Click);
//
// mOpen
//
this->mOpen->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mOpen.Image")));
this->mOpen->Name = L"mOpen";
this->mOpen->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::O));
this->mOpen->Size = System::Drawing::Size(379, 24);
this->mOpen->Text = L"³äêðèòè ôàéë ç óìîâîþ";
this->mOpen->Click += gcnew System::EventHandler(this, &MyForm::open_Click);
//
// mRandom
//
this->mRandom->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mRandom.Image")));
this->mRandom->Name = L"mRandom";
this->mRandom->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::R));
this->mRandom->Size = System::Drawing::Size(379, 24);
this->mRandom->Text = L"Çàïîâíèòè âèïàäêîâèìè ÷èñëàìè";
this->mRandom->Click += gcnew System::EventHandler(this, &MyForm::random_Click);
//
// mCalc
//
this->mCalc->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mCalc.Image")));
this->mCalc->Name = L"mCalc";
this->mCalc->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::M));
this->mCalc->Size = System::Drawing::Size(379, 24);
this->mCalc->Text = L"Îá÷èñëèòè îáåðíåíó ìàòðèöþ";
this->mCalc->Click += gcnew System::EventHandler(this, &MyForm::Calc_Click);
//
// mSaveTask
//
this->mSaveTask->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mSaveTask.Image")));
this->mSaveTask->Name = L"mSaveTask";
this->mSaveTask->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::S));
this->mSaveTask->Size = System::Drawing::Size(379, 24);
this->mSaveTask->Text = L"Çáåðåãòè óìîâó äî ...";
this->mSaveTask->Click += gcnew System::EventHandler(this, &MyForm::SaveTask_Click);
//
// mHelp
//
this->mHelp->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) { this->mAutor, this->mRegulations });
this->mHelp->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->mHelp->Name = L"mHelp";
this->mHelp->Size = System::Drawing::Size(78, 23);
this->mHelp->Text = L"&Äîâ³äêà";
//
// mAutor
//
this->mAutor->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mAutor.Image")));
this->mAutor->Name = L"mAutor";
this->mAutor->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::I));
this->mAutor->Size = System::Drawing::Size(272, 24);
this->mAutor->Text = L"Ïðî &àâòîðà";
this->mAutor->Click += gcnew System::EventHandler(this, &MyForm::Autor_Click);
//
// mRegulations
//
this->mRegulations->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"mRegulations.Image")));
this->mRegulations->Name = L"mRegulations";
this->mRegulations->ShortcutKeys = System::Windows::Forms::Keys::F1;
this->mRegulations->Size = System::Drawing::Size(272, 24);
this->mRegulations->Text = L"Ïðàâèëà &êîðèñòóâàííÿ";
this->mRegulations->Click += gcnew System::EventHandler(this, &MyForm::Regulations_Click);
//
// mExit
//
this->mExit->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->mExit->Name = L"mExit";
this->mExit->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::X));
this->mExit->Size = System::Drawing::Size(61, 23);
this->mExit->Text = L"Âè&õ³ä";
this->mExit->Click += gcnew System::EventHandler(this, &MyForm::Exit_Click);
//
// bRandom
//
this->bRandom->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->bRandom->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->bRandom->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->bRandom->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bRandom.Image")));
this->bRandom->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bRandom->Location = System::Drawing::Point(3, 154);
this->bRandom->MinimumSize = System::Drawing::Size(80, 70);
this->bRandom->Name = L"bRandom";
this->bRandom->Size = System::Drawing::Size(154, 70);
this->bRandom->TabIndex = 1;
this->bRandom->Text = L"Çàïîâíèòè\r\nâèïàäêîâèìè\r\n&÷èñëàìè";
this->bRandom->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bRandom->UseVisualStyleBackColor = true;
this->bRandom->Click += gcnew System::EventHandler(this, &MyForm::random_Click);
//
// bOpen
//
this->bOpen->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->bOpen->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->bOpen->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bOpen.Image")));
this->bOpen->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bOpen->Location = System::Drawing::Point(3, 239);
this->bOpen->MinimumSize = System::Drawing::Size(80, 70);
this->bOpen->Name = L"bOpen";
this->bOpen->Size = System::Drawing::Size(154, 70);
this->bOpen->TabIndex = 2;
this->bOpen->Text = L"&³äêðèòè\r\n ôàéë \r\nç óìîâîþ";
this->bOpen->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bOpen->UseVisualStyleBackColor = true;
this->bOpen->Click += gcnew System::EventHandler(this, &MyForm::open_Click);
//
// bNewTask
//
this->bNewTask->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->bNewTask->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->bNewTask->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->bNewTask->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bNewTask.Image")));
this->bNewTask->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bNewTask->Location = System::Drawing::Point(3, 68);
this->bNewTask->MinimumSize = System::Drawing::Size(80, 70);
this->bNewTask->Name = L"bNewTask";
this->bNewTask->RightToLeft = System::Windows::Forms::RightToLeft::No;
this->bNewTask->Size = System::Drawing::Size(154, 70);
this->bNewTask->TabIndex = 0;
this->bNewTask->Text = L"&Íîâå\r\nçàâäàííÿ";
this->bNewTask->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bNewTask->UseVisualStyleBackColor = true;
this->bNewTask->Click += gcnew System::EventHandler(this, &MyForm::NewTask_Click);
//
// bCalc
//
this->bCalc->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->bCalc->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->bCalc->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bCalc.Image")));
this->bCalc->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bCalc->Location = System::Drawing::Point(3, 412);
this->bCalc->MinimumSize = System::Drawing::Size(80, 70);
this->bCalc->Name = L"bCalc";
this->bCalc->Size = System::Drawing::Size(154, 70);
this->bCalc->TabIndex = 3;
this->bCalc->Text = L"&Îá÷èñëèòè\r\nîáåðíåíó\r\nìàòðèöþ";
this->bCalc->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bCalc->UseVisualStyleBackColor = true;
this->bCalc->Click += gcnew System::EventHandler(this, &MyForm::Calc_Click);
//
// tableLayoutPanelLeft
//
this->tableLayoutPanelLeft->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left));
this->tableLayoutPanelLeft->AutoScroll = true;
this->tableLayoutPanelLeft->AutoSize = true;
this->tableLayoutPanelLeft->ColumnCount = 1;
this->tableLayoutPanelLeft->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent,
100)));
this->tableLayoutPanelLeft->Controls->Add(this->bRandom, 0, 3);
this->tableLayoutPanelLeft->Controls->Add(this->bCalc, 0, 7);
this->tableLayoutPanelLeft->Controls->Add(this->bOpen, 0, 5);
this->tableLayoutPanelLeft->Controls->Add(this->bNewTask, 0, 1);
this->tableLayoutPanelLeft->Location = System::Drawing::Point(3, 3);
this->tableLayoutPanelLeft->MinimumSize = System::Drawing::Size(160, 380);
this->tableLayoutPanelLeft->Name = L"tableLayoutPanelLeft";
this->tableLayoutPanelLeft->RowCount = 8;
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute,
65)));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute,
10)));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute,
9)));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute,
20)));
this->tableLayoutPanelLeft->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelLeft->Size = System::Drawing::Size(160, 485);
this->tableLayoutPanelLeft->TabIndex = 4;
//
// groupBoxMetod
//
this->groupBoxMetod->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->groupBoxMetod->Controls->Add(this->radioShulc);
this->groupBoxMetod->Controls->Add(this->radioGaus);
this->groupBoxMetod->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->groupBoxMetod->Location = System::Drawing::Point(3, 3);
this->groupBoxMetod->MinimumSize = System::Drawing::Size(0, 50);
this->groupBoxMetod->Name = L"groupBoxMetod";
this->groupBoxMetod->Size = System::Drawing::Size(613, 61);
this->groupBoxMetod->TabIndex = 4;
this->groupBoxMetod->TabStop = false;
this->groupBoxMetod->Text = L"Âèá³ð ìåòîäó îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³";
//
// radioShulc
//
this->radioShulc->AutoSize = true;
this->radioShulc->Location = System::Drawing::Point(368, 25);
this->radioShulc->Name = L"radioShulc";
this->radioShulc->Size = System::Drawing::Size(134, 23);
this->radioShulc->TabIndex = 6;
this->radioShulc->Text = L"ìåòîä &Øóëüöà";
this->radioShulc->UseVisualStyleBackColor = true;
//
// radioGaus
//
this->radioGaus->AutoSize = true;
this->radioGaus->Checked = true;
this->radioGaus->Location = System::Drawing::Point(66, 25);
this->radioGaus->Name = L"radioGaus";
this->radioGaus->Size = System::Drawing::Size(182, 23);
this->radioGaus->TabIndex = 5;
this->radioGaus->TabStop = true;
this->radioGaus->Text = L"ìåòîä &Æîðäàíà-Ãàóñà";
this->radioGaus->UseVisualStyleBackColor = true;
//
// tableLayoutPanelMatrixSize
//
this->tableLayoutPanelMatrixSize->ColumnCount = 4;
this->tableLayoutPanelMatrixSize->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutPanelMatrixSize->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutPanelMatrixSize->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
199)));
this->tableLayoutPanelMatrixSize->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
116)));
this->tableLayoutPanelMatrixSize->Controls->Add(this->labelSize, 0, 0);
this->tableLayoutPanelMatrixSize->Controls->Add(this->matrixSize, 1, 0);
this->tableLayoutPanelMatrixSize->Location = System::Drawing::Point(3, 70);
this->tableLayoutPanelMatrixSize->Name = L"tableLayoutPanelMatrixSize";
this->tableLayoutPanelMatrixSize->RowCount = 1;
this->tableLayoutPanelMatrixSize->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent,
100)));
this->tableLayoutPanelMatrixSize->Size = System::Drawing::Size(613, 37);
this->tableLayoutPanelMatrixSize->TabIndex = 7;
//
// labelSize
//
this->labelSize->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Left | System::Windows::Forms::AnchorStyles::Right));
this->labelSize->AutoSize = true;
this->labelSize->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->labelSize->Location = System::Drawing::Point(3, 9);
this->labelSize->Name = L"labelSize";
this->labelSize->Size = System::Drawing::Size(211, 19);
this->labelSize->TabIndex = 1;
this->labelSize->Text = L"Ðîçì³ðí³ñòü âõ³äíî¿ ìàòðèö³:";
//
// matrixSize
//
this->matrixSize->Anchor = System::Windows::Forms::AnchorStyles::None;
this->matrixSize->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->matrixSize->Location = System::Drawing::Point(220, 5);
this->matrixSize->Maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 32000, 0, 0, 0 });
this->matrixSize->Minimum = System::Decimal(gcnew cli::array< System::Int32 >(4) { 2, 0, 0, 0 });
this->matrixSize->Name = L"matrixSize";
this->matrixSize->Size = System::Drawing::Size(75, 26);
this->matrixSize->TabIndex = 7;
this->matrixSize->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
this->matrixSize->Value = System::Decimal(gcnew cli::array< System::Int32 >(4) { 3, 0, 0, 0 });
this->matrixSize->ValueChanged += gcnew System::EventHandler(this, &MyForm::matrixSizeValueChanged);
this->matrixSize->Leave += gcnew System::EventHandler(this, &MyForm::matrixSizeValueChanged);
//
// tableLayoutGlav
//
this->tableLayoutGlav->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->tableLayoutGlav->AutoSize = true;
this->tableLayoutGlav->ColumnCount = 3;
this->tableLayoutGlav->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutGlav->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent,
100)));
this->tableLayoutGlav->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
20)));
this->tableLayoutGlav->Controls->Add(this->tableLayoutPanelLeft, 0, 0);
this->tableLayoutGlav->Controls->Add(this->tableLayoutPanelRigth, 1, 0);
this->tableLayoutGlav->Location = System::Drawing::Point(0, 27);
this->tableLayoutGlav->MinimumSize = System::Drawing::Size(700, 480);
this->tableLayoutGlav->Name = L"tableLayoutGlav";
this->tableLayoutGlav->RowCount = 2;
this->tableLayoutGlav->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 100)));
this->tableLayoutGlav->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, 20)));
this->tableLayoutGlav->Size = System::Drawing::Size(810, 511);
this->tableLayoutGlav->TabIndex = 6;
//
// tableLayoutPanelRigth
//
this->tableLayoutPanelRigth->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->tableLayoutPanelRigth->AutoSize = true;
this->tableLayoutPanelRigth->ColumnCount = 1;
this->tableLayoutPanelRigth->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutPanelRigth->Controls->Add(this->tableLayoutPanelMatrixSize, 0, 1);
this->tableLayoutPanelRigth->Controls->Add(this->groupBoxMetod, 0, 0);
this->tableLayoutPanelRigth->Controls->Add(this->matrix_table, 0, 2);
this->tableLayoutPanelRigth->Location = System::Drawing::Point(169, 3);
this->tableLayoutPanelRigth->Name = L"tableLayoutPanelRigth";
this->tableLayoutPanelRigth->RowCount = 3;
this->tableLayoutPanelRigth->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelRigth->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelRigth->RowStyles->Add((gcnew System::Windows::Forms::RowStyle()));
this->tableLayoutPanelRigth->Size = System::Drawing::Size(618, 485);
this->tableLayoutPanelRigth->TabIndex = 0;
//
// matrix_table
//
this->matrix_table->AllowUserToAddRows = false;
this->matrix_table->AllowUserToDeleteRows = false;
this->matrix_table->AllowUserToResizeColumns = false;
this->matrix_table->AllowUserToResizeRows = false;
this->matrix_table->Anchor = System::Windows::Forms::AnchorStyles::Right;
this->matrix_table->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->matrix_table->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::Sunken;
this->matrix_table->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::Sunken;
dataGridViewCellStyle1->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
dataGridViewCellStyle1->BackColor = System::Drawing::Color::Gold;
dataGridViewCellStyle1->Font = (gcnew System::Drawing::Font(L"Times New Roman", 10, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
dataGridViewCellStyle1->ForeColor = System::Drawing::SystemColors::WindowText;
dataGridViewCellStyle1->SelectionBackColor = System::Drawing::SystemColors::Highlight;
dataGridViewCellStyle1->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
dataGridViewCellStyle1->WrapMode = System::Windows::Forms::DataGridViewTriState::True;
this->matrix_table->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this->matrix_table->ColumnHeadersVisible = false;
dataGridViewCellStyle2->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleLeft;
dataGridViewCellStyle2->BackColor = System::Drawing::SystemColors::Window;
dataGridViewCellStyle2->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
dataGridViewCellStyle2->ForeColor = System::Drawing::SystemColors::ControlText;
dataGridViewCellStyle2->SelectionBackColor = System::Drawing::SystemColors::Highlight;
dataGridViewCellStyle2->SelectionForeColor = System::Drawing::SystemColors::HighlightText;
dataGridViewCellStyle2->WrapMode = System::Windows::Forms::DataGridViewTriState::False;
this->matrix_table->DefaultCellStyle = dataGridViewCellStyle2;
this->matrix_table->Location = System::Drawing::Point(3, 113);
this->matrix_table->Name = L"matrix_table";
this->matrix_table->RowHeadersVisible = false;
this->matrix_table->RowHeadersWidth = 10;
this->matrix_table->Size = System::Drawing::Size(613, 369);
this->matrix_table->TabIndex = 8;
this->matrix_table->CellContentClick += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::matrix_table_CellContentClick);
this->matrix_table->CellStateChanged += gcnew System::Windows::Forms::DataGridViewCellStateChangedEventHandler(this, &MyForm::matrix_table_CellStateChanged);
this->matrix_table->CellValueChanged += gcnew System::Windows::Forms::DataGridViewCellEventHandler(this, &MyForm::matrix_table_CellValueChanged);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(804, 532);
this->Controls->Add(this->tableLayoutGlav);
this->Controls->Add(this->menuStripGlav);
this->KeyPreview = true;
this->MainMenuStrip = this->menuStripGlav;
this->MinimumSize = System::Drawing::Size(820, 570);
this->Name = L"MyForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"Îáåðíåííÿ ìàòðèö³";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::MyForm_KeyPress);
this->menuStripGlav->ResumeLayout(false);
this->menuStripGlav->PerformLayout();
this->tableLayoutPanelLeft->ResumeLayout(false);
this->groupBoxMetod->ResumeLayout(false);
this->groupBoxMetod->PerformLayout();
this->tableLayoutPanelMatrixSize->ResumeLayout(false);
this->tableLayoutPanelMatrixSize->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrixSize))->EndInit();
this->tableLayoutGlav->ResumeLayout(false);
this->tableLayoutGlav->PerformLayout();
this->tableLayoutPanelRigth->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrix_table))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
/*
Ýëåìåíòû óïðàâëåíèÿ äëÿ èñïîëüçîâàíèÿ â ôîðìàõ Windows Forms
https://msdn.microsoft.com/ru-ru/library/3xdhey7w%28v=vs.110%29.aspx
MessageBox::
https://msdn.microsoft.com/ru-ru/library/ydf69t86%28v=vs.110%29.aspx
OpenFileDialog
https://msdn.microsoft.com/ru-ru/library/61097ykx%28v=vs.110%29.aspx
http://victor192007.narod.ru/files/cs13.html
SaveFileDialog
https://msdn.microsoft.com/ru-ru/library/w6sh4y16%28v=vs.110%29.aspx
http://metanit.com/sharp/windowsforms/4.20.php
Windows Forms (ôîðóì)
http://www.programmersforum.ru/archive/index.php/f-104.html
Îòâåòû íà 7 ñàìûõ ÷àñòûõ âîïðîñà ïî WinForms
http://www.cyberforum.ru/windows-forms/thread110436.html
*/
// ================== äîäàòêîâ³ ñåðâ³ñí³ ôóíêö³¿ ===============================
// ---------- ï³äïðîãðàìà ïåðåâ³ðêè íà êîðåêòí³ñòü âì³ñòó Grid-a ³ çàïèñó éîãî åëåìåíò³â â ìàòðèöþ ----------------
private: double** GridToMatrix(int N) {
bool err = false; // ïðàïîðåöü ïîìèëêè (ïîìèëêà â³äñóòíÿ)
double **matrix = new double*[N]; // ñòâîðèòè íîâó ìàòðèöþ
for (int i = 0; i < N && !err; i++) { // öèêë ïî ðÿäêàõ ìàòðèö³
matrix[i] = new double[N]; // ñòâîðåííÿ íîâîãî ðÿäêà ìàòðèö³
for (int j = 0; j < N && !err; j++) {
err = !Double::TryParse(Convert::ToString(matrix_table->Rows[i]->Cells[j]->Value), matrix[i][j]); // êîíâåðòóâàòè åëåìåíò â double ³ ïåðåâ³ðèòè ïðàâèëüí³ñòü
if (err) { // ÿêùî ïðè êîíâåðòàö³¿ âèíèêëà ïîìèëêà, ïîâ³äîìèòè ïðî öå ³ ïðèïèíèòè êîíâåðòàö³þ (âèéòè ³ç öèêëó)
System::String ^st1 = gcnew System::String("Åëåìåíò ["); // ñôîðìóâàòè òåêñò ïîâ³äîìëåííÿ ïðî ïîìèëêó
st1 = st1->Concat(st1->Concat(st1->Concat(st1->Concat(st1, Convert::ToString(i)), "]["), Convert::ToString(j)), "] ì³ñòèòü íåêîðåêòíå çíà÷åííÿ");
MessageBox::Show(st1, "Ïîìèëêà", MessageBoxButtons::OK, MessageBoxIcon::Warning);
}
}
}
return (err) ? NULL : matrix; // ïîâåðíóòè: NULL, ÿêùî âèíèêëà ïîìèëêà, ³íàêøå, àäðåñó ìàòðèö³ À
}
// ---------- ï³äïðîãðàìà çàïèñó ìàòðèö³ ðîçì³ðíîñò³ N äî Gr³d-a ----------------
private: System::Void MatrixToGrid(double** matrix, int N) {
matrixSize->Value = N; // çàïèñàòè ðîçì³ðí³ñòü â matrixSize
for (int i = 0; i < N; i++) // öèêë ïî âñ³õ åëåìåíòàõ ìàòðèö³
for (int j = 0; j < N; j++)
matrix_table->Rows[i]->Cells[j]->Value = matrix[i][j]; // çàïèñàòè â [i][j]-èé åëåìåíò Gr³d-a çíà÷åííÿ ç âõ³äíî¿ ìàòðèö³
matrix_table->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
}
// ---------- ï³äïðîãðàìà çàïèñó ìàòðèö³ ðîçì³ðíîñò³ N äî âêàçàíîãî ôàéëó file ----------------
private: System::Void SaveTo(double ** matrix, String ^file, int N) {
System::String ^st1 = gcnew System::String(""); // ðÿäîê äëÿ çàïèñó ÷èëåë
System::IO::StreamWriter ^streamWrite = gcnew System::IO::StreamWriter(file, false); // â³äêðèòè ïîò³ê (ôàéë) äëÿ çàïèñó (ÿêùî ôàéë âæå ³ñíóº - ïåðåçàïèñàòè éîãî)
streamWrite->WriteLine(Convert::ToString(N)); // çàïèñàòè ó ôàéë ðîçì³ðí³ñòü ìàòðèö³ À
for (int i = 0; i < N; i++) { // öèêë ïî N-ðÿäêàõ ìàòðèö³ À
st1 = ""; // î÷èñòèòè ðÿäîê
for (int j = 0; j < N; j++) { // côîðìóâàòè ³ çàïèñàòè âñ³ ðÿäêè ìàòðèö³
st1 = st1->Concat(st1, Convert::ToString(matrix[i][j])); // äîáàâèòè äî ðÿäêà íàñòóïíèé åëåìåíò ìàòðèö³
st1 += (j < N - 1) ? " " : ""; // äîáàâèòè ïðîì³æîê ï³ñëÿ êîæíîãî çíà÷åííÿìè (êð³ì îñòàííüîãî)
}
streamWrite->WriteLine(st1->Replace(",", ".")); // çàïèñàòè ñôîðìîâàíèé ðÿäîê ó ôàéë (ïîò³ê)
}
streamWrite->Close(); // çàêðèòè ïîò³ê (ôàéë)
MessageBox::Show("Çàïèñ óìîâè äî ôàéëó âèêîíàíî âäàëî.", "Óñï³õ", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
// ========================================================================================
// ---------- ï³äïðîãðàìà ïî䳿 ïî÷àòêîâîãî çàâàíòàæåííÿ ãîëîâíî¿ ôîðìè ----------------
// (ïî÷àòêîâèé ñòàí ãîëîâíî¿ ôîðìè, ï³äãîòîâêà îá'ºêò³â äî íîâîãî çàâäàííÿ)
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
NewTask_Click(sender, e);
}
// ---------- ï³äïðîãðàìà ïî䳿 çì³íè çíà÷åííÿ â ïîë³ ë³÷èëüíèêà matrixSize ----------------
private: System::Void matrixSizeValueChanged(System::Object^ sender, System::EventArgs^ e) {
matrix_table->ColumnCount = Convert::ToInt32(matrixSize->Value); // âñòàíîâèòè ê-ñòü êîëîíîê â Grid-³ òàáëèö³ (âõ³äíî¿ ìàòðèö³) çã³äíî ³ç çíà÷åííÿì â ïîë³ matrixSize
matrix_table->RowCount = Convert::ToInt32(matrixSize->Value); // ----//---- ðÿäê³â â Grid-³ ----//----
matrix_table->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
}
// ---------- ï³äïðîãðàìà ïåðåõîïëåííÿ íàòèñíóòî¿ êëà³âø³ ³ çàì³íè '.' íà ',' ----------------
private: System::Void MyForm_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
if (e->KeyChar == '.')
e->KeyChar = ',';
}
// ---------- ï³äïðîãðàìà ïî䳿 çì³íè çíà÷åííÿ â êë³òèí³ Grid-a ----------------
private: System::Void matrix_table_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
matrix_table->Tag = 1; // ÿêùî çíà÷åííÿ â êë³òèí³ çì³íèëîñü, çàãíàòè â Tag 1
}
// ---------- ï³äïðîãðàìà ïî䳿 ïåðåõîäó äî ³íøî¿ êë³òèíè Grid-ó ----------------
private: System::Void matrix_table_CellStateChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellStateChangedEventArgs^ e) {
if (matrix_table->Tag) { // ÿêùî Tag !=0 (çíà÷åííÿ â êë³òèí³ áóëî çì³íåíî)
matrix_table->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
matrix_table->Tag = Convert::ToInt32(0); // çàãíàòè â Tag 0 (çì³í íå áóëî)
}
}
// ---------- ï³äïðîãðàìà ïî䳿 âèáîðó ïóíêòó ìåíþ "Ïðî àâòîðà" (âèâåäåííÿ ïîâ³äîìëåííÿ) ----------------
private: System::Void Autor_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("\t Êóðñîâà ðîáîòà íà òåìó\n\"Îáåðíåííÿ ìàòðèö³ (ìåòîäàìè Æàðäàíà-Ãàóñà òà Øóëüöà)\"\n\tÂèêîíàëà ñòóäåíòêà ãðóïè ²Ï-54\n\t\tôàêóëüòåòó - Ô²ÎÒ\n\t\t ÍÒÓÓ\"Êϲ\"\n\t ×èæ Þë³ÿ Ìèõàéë³âíà\n\n\te-mail: [email protected]\n òåëåôîí: +3(098) 322 00 48, +3(095) 043 75 77" , "Ïðî àâòîðà", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
// ---------- ï³äïðîãðàìà ïî䳿 âèáîðó ïóíêòó ìåíþ "Ïðàâèëà êîðèñòóâàííÿ"----------------
private: System::Void Regulations_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("\tÄëÿ îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³ íåîáõ³äíî çàïîâíèòè ÷èñëàìè òàáëèöþ ìàòðèö³. Ïåðåä óâåäåííÿì ÷èñëà ç êëàâ³àòóðè àáî çàïîâíåííÿ ìàòðèö³ âèïàäêîâèìè ÷èñëàìè ïîòð³áíî âñòàíîâèòè ðîçì³ðí³ñòü âõ³äíî¿ ìàòðèö³. Çàïîâíåííÿ âèïàäêîâèìè ÷èñëàìè âèêîíóºòüñÿ ç ïðîì³æêó[0
100]. Çàäëÿ çðó÷íîñò³ ïî êîì³ðêàì òàáëèö³ ìîæíà ðóõàòèñÿ çà äîïîìîãîþ êëàâ³ø Tab àáî Enter. Äëÿ çàïîâíåííÿ ìàòðèö³ ÷èñëàìè, çáåðåæåíèìè ó ôàéë³, ïîòð³áíî âèáðàòè ïóíêò «Â³äêðèòè ôàéë ç óìîâîþ» ç ìåíþ «Ôàéë» àáî íàòèñíóòè â³äïîâ³äíó êíîïêó â ë³â³é ïàíåë³, çíàéòè ³ âèáðàòè ïîòð³áíèé ôàéë.\n"
"\tÄëÿ çáåðåæåííÿ çíà÷åíü åëåìåíò³â âõ³äíî¿ ìàòðèö³ ó ôàéë³ ïîòð³áíî âèáðàòè ïóíêò «Çáåðåãòè óìîâó äî
» ç ìåíþ «Ôàéë», ÿêèé â³äêðèº ä³àëîãîâå â³êíî âèáîðó êîðèñòóâà÷åì ôàéëó(çà çàìîâ÷óâàííÿì ôàéë ç ðîçøèðåííÿì *.tsk). ßêùî âêàçàíèé ôàéë âæå ³ñíóº â îáðàí³é ïàïö³, éîãî áóäå ïåðåçàïèñàíî.\n"
"\tÄëÿ îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³ âèêîíàâåöü ïîâèíåí âèáðàòè ìåòîä îá÷èñëåííÿ òà îáðàòè ïóíêò «Îá÷èñëèòè îáåðíåíó ìàòðèöþ» ç ìåíþ «Ôàéë» àáî íàòèñíóòè â³äïîâ³äíó êíîïêó â ë³â³é ïàíåë³.ßêùî âñ³ åëåìåíòè ìàòðèö³ çàïîâíåí³ ³ º êîðåêòíèìè ÷èñëàìè, òî íà åêðàí áóäå âèâåäåíî äîäàòêîâå â³êíî ³ç ðåçóëüòàòîì îá÷èñëåííÿ.Äëÿ çáåðåæåííÿ ðåçóëüòàò³â îá÷èñëåííÿ ïîòð³áíî íàòèñíóòè êíîïêó «Çáåðåãòè îáåðíåíó ìàòðèöþ ó ôàéë³», ÿêà â³äêðèº ä³àëîãîâå â³êíî âèáîðó êîðèñòóâà÷åì ôàéëó(çà çàìîâ÷óâàííÿì ôàéë ç ðîçøèðåííÿì *.res). ßêùî âêàçàíèé ôàéë âæå ³ñíóº â îáðàí³é ïàïö³, éîãî áóäå ïåðåçàïèñàíî.\n"
"\tϳñëÿ íàòèñêó êíîïêè «Âèõ³ä» ó â³êí³ ç ðåçóëüòàòîì îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³ âèêîíàºòüñÿ çàêðèòòÿ ïîòî÷íîãî ìîäàëüíîãî â³êíà ³ ïåðåäà÷à óïðàâë³ííÿ ãîëîâíîìó â³íêó ïðîãðàìè.\n"
"\tÄëÿ îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³ çà ³íøîþ óìîâîþ äîðå÷íî îáðàòè ïóíêò «Íîâå çàâäàííÿ» ç ìåíþ «Ôàéë» àáî íàòèñíóòè â³äïîâ³äíó êíîïêó â ë³â³é ïàíåë³.  ðåçóëüòàò³, ðîçì³ðí³ñòü âõ³äíî¿ ìàòðèö³ áóäå çì³íåíî íà 2õ2 òà î÷èùåíî ¿¿ â³ä äàíèõ.\n\n"
"Ó ïðîãðàì³ íàÿâí³ íàñòóïí³ «ãàðÿ÷³ êëàâ³ø³»:\n - Alt + Ô ìåíþ «Ôàéë»;\n - Alt + Ä ìåíþ «Äîâ³äêà»;\n - Ctrl + N àáî Alt + Í(êèðèëèöÿ) íîâå çàâäàííÿ;\n - Ctrl + O àáî Alt + Â(êèðèëèöÿ) â³äêðèòè ôàéë ç óìîâîþ;\n - Ctrl + R àáî Alt + Ç çàïîâíèòè âèïàäêîâèìè ÷èñëàìè;\n - Ctrl + M àáî Alt + Î(êèðèëèöÿ) îá÷èñëèòè îáåðíåíó ìàòðèöþ;\n - Ctrl + S çáåðåãòè óìîâó äî
;\n - Alt + Ç çáåðåãòè îáåðíåíó ìàòðèöþ ó ôàéë³; \n - Ctrl + I ïðî àâòîðà;\n - F1 ïðàâèëà êîðèñòóâàííÿ;\n - Ctrl + Õ àáî Alt + Õ(êèðèëèöÿ) çàêðèòè ïîòî÷íå â³êíî(âèõ³ä)",
"Ïðàâèëà êîðèñòóâàííÿ ïðîãðàìîþ", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
// ---------- ï³äïðîãðàìà ïî䳿 âèáîðó ïóíêòó ìåíþ àáî êíîïêè "Íîâå çàâäàííÿ" (ï³äãîòîâêà îá'ºêò³â äî íîâîãî çàâäàííÿ) ------
private: System::Void NewTask_Click(System::Object^ sender, System::EventArgs^ NewTask_Click) {
matrix_table->ColumnCount = 0; // âñòàíîâèòè ðîçì³ðí³ñòü Grid-à òàáëèö³ (âõ³äíî¿ ìàòðèö³)
matrix_table->RowCount = 0; // ê-ñòü ðÿäê³â Grid-a
matrix_table->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
if (Convert::ToInt32(matrixSize->Value) == 2) // ÿêùî â ïîë³ ë³÷èëüèêà ðîçì³ðíîñò³ Grid-a çàïèñàíî 2, òî
matrixSizeValueChanged(sender, NewTask_Click); // ïðèìóñîâî îíîâèòè ñòàí Grid-a äëÿ íîâîãî çíà÷åííÿ ðîçì³ðíîñò³
else matrixSize->Value = 2; // ³íàêøå âñòàíîâèòè ðîçì³ðí³ñòü Grid-a "2"
ActiveControl = matrixSize;
}
// ---------- ï³äïðîãðàìà ïî䳿 âèáîðó ïóíêòó ìåíþ àáî êíîïêè "Çàïîâíèòè âèïàäêîâèìè ÷èñëàìè" --------------
private: System::Void random_Click(System::Object^ sender, System::EventArgs^ e) {
int N = Convert::ToInt32(matrixSize->Value); // îòðèìàòè ðîçì³ðí³ñòü Grid-a çà çíà÷åííÿì ë³÷èëüíèêà matrixSize
Random^ randObj = gcnew Random; // ³í³öèàë³çàö³ÿ ãåíåðàòîðà âèïàäêîâèõ ÷èñåë
for (int i = 0; i < N; i++) { // öèêë ïî âñ³õ åëåìåíòàõ Grid-à
for (int j = 0; j < N; j++)
matrix_table->Rows[i]->Cells[j]->Value = randObj->Next(0, 100); // ùîá áóëè äåñÿòêîâ³ äðîáè: + randObj->Next(0, 100)/100.0
}
matrix_table->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
}
// ---------- ä³àëîã âèáîðó ôàéëó ³ç çàâäàííÿì ³ ç÷èòóâàííÿ ç íüîãî ³íôîðìàö³¿ ----------------
private: System::Void open_Click(System::Object^ sender, System::EventArgs^ e) {
OpenFileDialog ^openFileDialog = gcnew System::Windows::Forms::OpenFileDialog();
openFileDialog->Title = "³äêðèòè ôàéë ³ç âõ³äíîþ ìàòðèöåþ"; // âñòàíîâèòè çàãîëîâîê â³êíà
openFileDialog->InitialDirectory = Path::Combine(Application::StartupPath, "\Task"); // âñòàíîâèòè ïî÷àòêîâó ïàïêó äëÿ ÷èòàííÿ (ïàïêà Task ïîâèííà áóòè â ïàïö³ ³ç exe-ôàéëîì)
openFileDialog->Filter = "Ôàéëè ³ç çàâäàííÿì|*.tsk|Âñ³ ôàéëè (*.*)|*.*"; // âñòàíîâèòè äâà ô³ëüòðè
openFileDialog->FilterIndex = 1; // âñòàíîâèòè ïåðøèé ô³ëüòð îñíîâíèì (ïîòî÷íèì)
if (openFileDialog->ShowDialog() == System::Windows::Forms::DialogResult::OK) { // ÿêùî â ä³àëîç³ ÷èòàííÿ âèáðàíî ôàéë ³ íàòèñíóòî Îê
System::IO::StreamReader ^ sreamRead = gcnew System::IO::StreamReader(openFileDialog->FileName); // â³äêðèòè ïîò³ê ÷èòàííÿ ç ôàéëó
System::String ^str = gcnew System::String(sreamRead->ReadLine()); // ïðî÷èòàòè ïåðøèé ðÿäîê (òàì çàïèñàíî îäíå ÷èñëî - ðîçðÿäí³ñòü ìàòðèö³ (Grid-a))
int N = Convert::ToInt32(str); // êîíâåðòóâàòè öåé ðÿäîê â ÷èñëî
if (N >= 2) { // ÿêùî ïðî÷èòàíà ðîçì³ðí³ñòü >= 2
str = sreamRead->ReadToEnd(); // ïðî÷èòàòè ç â³äêðèòîãî ïîòîêó (ôàéëó) ðåøòó çàïèñàíî¿ ³íôîðìàö³¿ (äî ê³íöÿ ôàéëó)
marshal_context ^context = gcnew marshal_context(); // çìè³ííà, ÷åðåç ÿêó âèêîíàºìî êîíâåðòàö³þ ðÿäêà â char*
const char *strChar = context->marshal_as<const char*>(str); // êîíâåðòóâàòè ðÿäîê â ìàñèâ char, îòðèìàòè ïîêàæ÷èê íà íüîãî
double **A = inpMatrixInFile(N, strChar); // ñòâîðèòè ³ çàïîâíèòè äèíàì³÷íó ìàòðèöþ çíà÷åííÿìè ç ñhar* (÷åðåç ÷èòàííÿ ç ïîòîêó)
if (A) // ÿêùî îòðèìàíà àäðåñà not NULL, òî
MatrixToGrid(A, N); // çàíåñòè çíà÷åííÿ åëåìåíò³â ìàñèâó â Grid
else N = 0; // ³íàêøå, îáíóëèòè ðîçì³ðí³ñòü
}
sreamRead->Close(); // çàêðèòè ïîò³ê ÷èòàííÿ
if (!N) // ÿêùî ïðè ÷èòàíí³ ç ôàéëó âèíèêëà ïîìèëêà
MessageBox::Show("Íåêîðåêòí³ âõ³äí³ äàí³", "Ïîìèëêà ÷èòàííÿ ôàéëó", MessageBoxButtons::OK, MessageBoxIcon::Warning);
}
}
// ---------- ä³àëîã âèáîðó ôàéëà äëÿ çàïèñó â íüîãî óìîâè çàâäàííÿ ----------------
private: System::Void SaveTask_Click(System::Object^ sender, System::EventArgs^ e) {
int N = Convert::ToInt32(matrixSize->Value); // êîíâåðòóâàòè ðîçì³ðí³ñòü Grid-a â ÷èñëî
if (GridToMatrix(N)) { // ÿêùî âñ³ åëåìåíòè Grid-a êîðåêòí³ double-÷èñëà, òî çàïèñàòè ¿õ ó ôàéë
SaveFileDialog ^saveFileDialogTo = gcnew System::Windows::Forms::SaveFileDialog();
saveFileDialogTo->Title = "Çáåðåæåííÿ óìîâè äî ôàéëó";
saveFileDialogTo->InitialDirectory = Path::Combine(Application::StartupPath, "\Task"); // âñòàíîâèòè ïî÷àòêîâó ïàïêó äëÿ ÷èòàííÿ (ïàïêà Task ïîâèííà áóòè â ïàïö³ ³ç exe-ôàéëîì)
saveFileDialogTo->Filter = "Ôàéëè ³ç çàâäàííÿ|*.tsk|Ôàéëè ³ç ð³øåííÿì|*.res|Âñ³ ôàéëè|*.*"; // âñòàíîâèòè òðè ô³ëüòðè
saveFileDialogTo->FilterIndex = 1; // âñòàíîâèòè îñíîâíèì (ïîòî÷íèì) ïåðøèé ô³ëüòð
if (saveFileDialogTo->ShowDialog() == System::Windows::Forms::DialogResult::OK && saveFileDialogTo->FileName->Length > 0) {// â³äêðèòè ä³àëîã çàïèñó äî ôàéëó
double **A = GridToMatrix(N); // êîíâåðòóâàòè Gr³d â ìàòðèöþ double
if (A) // ÿêùî êîíâåðòàö³þ ïðîâåäåíî óñï³øíî (A!=NULL)
SaveTo(A, saveFileDialogTo->FileName, Convert::ToInt32(N)); // âèêîíàòè çàïèñ ³íôîðìàö³¿ ç ìàòðèö³ äî ôàéëó
}
else
MessageBox::Show("Óìîâó äî ôàéëó ÍÅ ÇÁÅÐÅÆÅÍÎ!", "Ïîìèëêà", MessageBoxButtons::OK, MessageBoxIcon::Warning);
}
}
// ---------- ï³äïðîãðàìà îá÷èñëåííÿ îáåðíåíî¿ ìàòðèö³ ----------------
private: System::Void Calc_Click(System::Object^ sender, System::EventArgs^ e) {
Stopwatch ^ timePerParse;
int N = Convert::ToInt32(matrixSize->Value); // êîíâåðòóâàòè ðîçì³ðí³ñòü Grid-a â ÷èñëî
/*bool err = !Double::TryParse(Convert::ToString(textBoxEps->Text), EPS);
EPS = (err) ? 1e-5 : EPS;*/
double **A = GridToMatrix(N); // êîíâåðòóâàòè Gr³d â ìàòðèöþ double
if (A) { // ÿêùî êîíâåðòàö³þ ïðîâåäåíî óñï³øíî (A!=NULL)
if (detMatrix(A, N) == 0) // ÿêùî âèçíà÷íèê ìàòðèö³ == 0, òî ìàòðèö³, îáåðíåíî¿ äî äàíî¿, íå ³ñíóº
MessageBox::Show("Âèçíà÷íèê ìàòðèö³ äîð³âíþº íóëþ.\nÌàòðèö³, îáåðíåíî¿ äî äàíî¿, íå ³ñíóº ", "Ïîìèëêà", MessageBoxButtons::OK, MessageBoxIcon::Warning);
else { // ³íàêøå, îá÷èñëèòè îáåðíåíó ìàòðèöþ çà âèáðàíèì ìåòîäîì
timePerParse = Stopwatch::StartNew(); // ñòâîðèòè îá'ºêò äëÿ âèì³ðó âèòðà÷åíîãî íà îá÷èñëåííÿ ÷àñó ³ çàïóñòèòè òàéìåð
double **Inv = (radioShulc->Checked) ? Shulca(A, N) : JordanaGausa(A, N); // ÿêùî äëÿ îá÷èñëåííÿ âèáðàíèé ìåòîä Øóëüöà, îá÷èñëèòè îáåðåíó ìàòðèöþ çà öèì ìåòîäîì, ³íàêøå îá÷èñëèòè îáåðåíó ìàòðèöþ çà ìåòîäîì Æîðäàíà-Ãàóñà
timePerParse->Stop(); // çóïèíèòè òàéìåð
calc_time = timePerParse->ElapsedMilliseconds; // âèçíà÷èòè ÷àñ îá÷èñëåííÿ (çíà÷åííÿ ì³ë³ñåêóíä òàéìåðà)
//Inv = RoundMatrix(Inv, N, 100000);
InvForm_Show(Inv, N, (radioShulc->Checked) ? "Îáåðíåíó ìàòðèöþ ìåòîäîì Øóëüöà\n\tóñï³øíî ñòâîðåíî." : "Îáåðíåíó ìàòðèöþ ìåòîäîì Æîðäàíà-Ãàóñà\n\tóñï³øíî ñòâîðåíî." ); // ñòâîðèòè ³ âèâåñòè â³êíî ç îáåðíåíîþ ìàòðèöåþ
}
}
}
// -------------- ï³äïðîãðàìà ³í³ö³àë³çàö³¿ ³ âèâåäåííÿ îêðåìîãî â³êíà ³ç çíà÷åííÿìè åëåìåíò³â îáåðíåíî¿ ìàòðèö³ -----------------------------
private: System::Void InvForm_Show(double **A, int N, String ^str) {
InvForm ^invForm = gcnew(InvForm); // ñòâîðèòè ôîðìó äëÿ âèâîäó îáåðíåíî¿ ìàòðèö³
invForm->matrix_InvTable->Text = str; // çàïèñàòè â Text Gr³d-a òåñò ïîâ³äîìëåííÿ
invForm->matrix_InvTable->Tag = N; // çàïèñàòè â Tag Gr³d-a ðîçì³ðí³ñòü ìàòðèö³
invForm->matrix_InvTable->ColumnCount = Convert::ToInt32(N); // âñòàíîâèòè ê-ñòü êîëîíîê â Grid-³ (òàáëèö³ îáåðíåíî¿ ìàòðèö³) çã³äíî ³ç ðîçì³ðí³ñòþ âõ³äíî¿ ìàòðèö³
invForm->matrix_InvTable->RowCount = Convert::ToInt32(N); // âñòàíîâèòè ê-ñòü êîëîíîê â Grid-³ (òàáëèö³ îáåðíåíî¿ ìàòðèö³) çã³äíî ³ç ðîçì³ðí³ñòþ âõ³äíî¿ ìàòðèö³
for (int i = 0; i < N; i++) { // öèêë ïî âñ³õ åëåìåíòàõ ìàòðèö³
for (int j = 0; j < N; j++)
invForm->matrix_InvTable->Rows[i]->Cells[j]->Value = A[i][j]; // çàïèñàòè â [i][j]-èé åëåìåíò Gr³d-a çíà÷åííÿ ç îáåðíåíî¿ ìàòðèö³
}
//invForm->Show(); // âèâîä â³êíà invForm, ÿê íåìîäàëüíî¿ ôîðìè
invForm->ShowDialog(); // âèâîä â³êíà invForm, ÿê ìîäàëüíî¿ ôîðìè
}
// ---------- ï³äïðîãðàìà ïî䳿 âèáîðó ïóíêòó ìåíþ "Âèõ³ä" (çàêðèòòÿ ãîëîâíî¿ ôîðìè) ----------------
private: System::Void Exit_Click(System::Object^ sender, System::EventArgs^ e) {
Close(); // çàêðèòè ãîëîâíó ôîðìó (âñþ ïðîãðàìó)
}
private: System::Void matrix_table_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
}
};
}