-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvForm.h
374 lines (365 loc) · 22.6 KB
/
InvForm.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
// çàãîëîâíèé ôàéë äëÿ ðåàë³çàö³¿ ³íòåðôåéñó â³êíà îáåðíåíî¿ ìàòðèö³
#include "calc.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;
/// <summary>
/// Ñâîäêà äëÿ InvForm
/// </summary>
public ref class InvForm : public System::Windows::Forms::Form {
public:
InvForm(void) {
InitializeComponent();
//TODO: äîáàâüòå êîä êîíñòðóêòîðà
}
protected:
// Îñâîáîäèòü âñå èñïîëüçóåìûå ðåñóðñû.
~InvForm() {
if (components) {
delete components;
}
}
private:
System::ComponentModel::Container ^components;
protected:
// DataGridView äëÿ â³äîáðàæåííÿ çíà÷åíü åëåìåíò³â îáåðíåíî¿ ìàòðèö³
public: System::Windows::Forms::DataGridView^ matrix_InvTable;
// øàð (âåðõí³é), íà ÿêîìó ðîçì³ùóºòüñÿ matrix_InvTable
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutTop;
// âñ³ êíîïêè ä³é
private: System::Windows::Forms::Button^ bClose;
private: System::Windows::Forms::Button^ bSaveRes;
// øàð (íèæí³é), ùî îá'ºäíóº âñ³ êíîïêè ä³é
private: System::Windows::Forms::TableLayoutPanel^ tableLayoutBottom;
// ñòàòóñ-áàð ç 3-ìà íàïèñàìè ³ 3-ìà ïîëÿìè
private: System::Windows::Forms::ToolStrip^ toolStrip;
private: System::Windows::Forms::ToolStripLabel^ toolStripLabel_Time;
private: System::Windows::Forms::ToolStripTextBox^ toolStripTextBox_Time;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1;
private: System::Windows::Forms::ToolStripLabel^ toolStripLabel_Iterac;
private: System::Windows::Forms::ToolStripTextBox^ toolStripTextBox_Iterac;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator2;
private: System::Windows::Forms::ToolStripLabel^ toolStripLabel_Operand;
private: System::Windows::Forms::ToolStripTextBox^ toolStripTextBox_Operand;
private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator3;
#pragma region Windows Form Designer generated code
// Îáÿçàòåëüíûé ìåòîä äëÿ ïîääåðæêè êîíñòðóêòîðà (íå èçìåíÿéòå ñîäåðæèìîå äàííîãî ìåòîäà ïðè ïîìîùè ðåäàêòîðà êîäà)
void InitializeComponent(void) {
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle1 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::Windows::Forms::DataGridViewCellStyle^ dataGridViewCellStyle2 = (gcnew System::Windows::Forms::DataGridViewCellStyle());
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(InvForm::typeid));
this->tableLayoutTop = (gcnew System::Windows::Forms::TableLayoutPanel());
this->matrix_InvTable = (gcnew System::Windows::Forms::DataGridView());
this->tableLayoutBottom = (gcnew System::Windows::Forms::TableLayoutPanel());
this->bSaveRes = (gcnew System::Windows::Forms::Button());
this->bClose = (gcnew System::Windows::Forms::Button());
this->toolStrip = (gcnew System::Windows::Forms::ToolStrip());
this->toolStripLabel_Time = (gcnew System::Windows::Forms::ToolStripLabel());
this->toolStripTextBox_Time = (gcnew System::Windows::Forms::ToolStripTextBox());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->toolStripLabel_Iterac = (gcnew System::Windows::Forms::ToolStripLabel());
this->toolStripTextBox_Iterac = (gcnew System::Windows::Forms::ToolStripTextBox());
this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->toolStripLabel_Operand = (gcnew System::Windows::Forms::ToolStripLabel());
this->toolStripTextBox_Operand = (gcnew System::Windows::Forms::ToolStripTextBox());
this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator());
this->tableLayoutTop->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrix_InvTable))->BeginInit();
this->tableLayoutBottom->SuspendLayout();
this->toolStrip->SuspendLayout();
this->SuspendLayout();
//
// tableLayoutTop
//
this->tableLayoutTop->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->tableLayoutTop->ColumnCount = 1;
this->tableLayoutTop->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutTop->Controls->Add(this->matrix_InvTable, 0, 0);
this->tableLayoutTop->Controls->Add(this->tableLayoutBottom, 0, 1);
this->tableLayoutTop->Location = System::Drawing::Point(1, 0);
this->tableLayoutTop->Name = L"tableLayoutTop";
this->tableLayoutTop->RowCount = 2;
this->tableLayoutTop->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 100)));
this->tableLayoutTop->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, 80)));
this->tableLayoutTop->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, 20)));
this->tableLayoutTop->Size = System::Drawing::Size(765, 423);
this->tableLayoutTop->TabIndex = 0;
//
// matrix_InvTable
//
this->matrix_InvTable->AllowUserToAddRows = false;
this->matrix_InvTable->AllowUserToDeleteRows = false;
this->matrix_InvTable->AllowUserToResizeColumns = false;
this->matrix_InvTable->AllowUserToResizeRows = false;
this->matrix_InvTable->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->matrix_InvTable->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
this->matrix_InvTable->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::Sunken;
this->matrix_InvTable->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", 12, System::Drawing::FontStyle::Bold, 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_InvTable->ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this->matrix_InvTable->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->matrix_InvTable->ColumnHeadersVisible = false;
dataGridViewCellStyle2->Alignment = System::Windows::Forms::DataGridViewContentAlignment::MiddleCenter;
dataGridViewCellStyle2->BackColor = System::Drawing::SystemColors::Window;
dataGridViewCellStyle2->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, 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_InvTable->DefaultCellStyle = dataGridViewCellStyle2;
this->matrix_InvTable->Location = System::Drawing::Point(3, 3);
this->matrix_InvTable->Name = L"matrix_InvTable";
this->matrix_InvTable->ReadOnly = true;
this->matrix_InvTable->RowHeadersVisible = false;
this->matrix_InvTable->RowHeadersWidth = 10;
this->matrix_InvTable->Size = System::Drawing::Size(761, 337);
this->matrix_InvTable->TabIndex = 0;
//
// tableLayoutBottom
//
this->tableLayoutBottom->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->tableLayoutBottom->ColumnCount = 3;
this->tableLayoutBottom->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
20)));
this->tableLayoutBottom->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutBottom->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle()));
this->tableLayoutBottom->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute,
20)));
this->tableLayoutBottom->Controls->Add(this->bSaveRes, 1, 0);
this->tableLayoutBottom->Controls->Add(this->bClose, 2, 0);
this->tableLayoutBottom->Location = System::Drawing::Point(3, 346);
this->tableLayoutBottom->Name = L"tableLayoutBottom";
this->tableLayoutBottom->RowCount = 1;
this->tableLayoutBottom->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 100)));
this->tableLayoutBottom->Size = System::Drawing::Size(761, 74);
this->tableLayoutBottom->TabIndex = 1;
//
// bSaveRes
//
this->bSaveRes->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bSaveRes.Image")));
this->bSaveRes->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bSaveRes->Location = System::Drawing::Point(23, 3);
this->bSaveRes->Name = L"bSaveRes";
this->bSaveRes->Size = System::Drawing::Size(207, 67);
this->bSaveRes->TabIndex = 0;
this->bSaveRes->Text = L"&Çáåðåãòè îáåðíåíó\r\nìàòðèöþ ó ôàéë³";
this->bSaveRes->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bSaveRes->UseVisualStyleBackColor = true;
this->bSaveRes->Click += gcnew System::EventHandler(this, &InvForm::bSaveRes_Click);
//
// bClose
//
this->bClose->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Right));
this->bClose->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"bClose.Image")));
this->bClose->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;
this->bClose->Location = System::Drawing::Point(601, 3);
this->bClose->Margin = System::Windows::Forms::Padding(3, 3, 23, 3);
this->bClose->Name = L"bClose";
this->bClose->Size = System::Drawing::Size(137, 68);
this->bClose->TabIndex = 1;
this->bClose->Text = L"Âè&õ³ä";
this->bClose->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
this->bClose->UseVisualStyleBackColor = true;
this->bClose->Click += gcnew System::EventHandler(this, &InvForm::bClose_Click);
//
// toolStrip
//
this->toolStrip->Dock = System::Windows::Forms::DockStyle::Bottom;
this->toolStrip->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->toolStrip->GripStyle = System::Windows::Forms::ToolStripGripStyle::Hidden;
this->toolStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(9) {
this->toolStripLabel_Time,
this->toolStripTextBox_Time, this->toolStripSeparator1, this->toolStripLabel_Iterac, this->toolStripTextBox_Iterac, this->toolStripSeparator2,
this->toolStripLabel_Operand, this->toolStripTextBox_Operand, this->toolStripSeparator3
});
this->toolStrip->Location = System::Drawing::Point(0, 426);
this->toolStrip->Name = L"toolStrip";
this->toolStrip->Padding = System::Windows::Forms::Padding(10, 5, 0, 5);
this->toolStrip->RenderMode = System::Windows::Forms::ToolStripRenderMode::System;
this->toolStrip->Size = System::Drawing::Size(774, 36);
this->toolStrip->Stretch = true;
this->toolStrip->TabIndex = 9;
//
// toolStripLabel_Time
//
this->toolStripLabel_Time->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->toolStripLabel_Time->ForeColor = System::Drawing::Color::Maroon;
this->toolStripLabel_Time->Name = L"toolStripLabel_Time";
this->toolStripLabel_Time->Size = System::Drawing::Size(124, 23);
this->toolStripLabel_Time->Text = L"×àñ îá÷èñëåííÿ";
//
// toolStripTextBox_Time
//
this->toolStripTextBox_Time->BackColor = System::Drawing::SystemColors::Window;
this->toolStripTextBox_Time->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204)));
this->toolStripTextBox_Time->ForeColor = System::Drawing::Color::Maroon;
this->toolStripTextBox_Time->Name = L"toolStripTextBox_Time";
this->toolStripTextBox_Time->ReadOnly = true;
this->toolStripTextBox_Time->Size = System::Drawing::Size(100, 26);
this->toolStripTextBox_Time->TextBoxTextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// toolStripSeparator1
//
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(6, 26);
//
// toolStripLabel_Iterac
//
this->toolStripLabel_Iterac->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->toolStripLabel_Iterac->ForeColor = System::Drawing::Color::Maroon;
this->toolStripLabel_Iterac->Name = L"toolStripLabel_Iterac";
this->toolStripLabel_Iterac->Size = System::Drawing::Size(140, 23);
this->toolStripLabel_Iterac->Text = L"ʳëüê³ñòü ³òåðàö³é";
//
// toolStripTextBox_Iterac
//
this->toolStripTextBox_Iterac->BackColor = System::Drawing::SystemColors::Window;
this->toolStripTextBox_Iterac->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204)));
this->toolStripTextBox_Iterac->ForeColor = System::Drawing::Color::Maroon;
this->toolStripTextBox_Iterac->Name = L"toolStripTextBox_Iterac";
this->toolStripTextBox_Iterac->ReadOnly = true;
this->toolStripTextBox_Iterac->Size = System::Drawing::Size(100, 26);
this->toolStripTextBox_Iterac->TextBoxTextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// toolStripSeparator2
//
this->toolStripSeparator2->Name = L"toolStripSeparator2";
this->toolStripSeparator2->Size = System::Drawing::Size(6, 26);
//
// toolStripLabel_Operand
//
this->toolStripLabel_Operand->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->toolStripLabel_Operand->ForeColor = System::Drawing::Color::Maroon;
this->toolStripLabel_Operand->Name = L"toolStripLabel_Operand";
this->toolStripLabel_Operand->Size = System::Drawing::Size(145, 23);
this->toolStripLabel_Operand->Text = L"ʳëüê³ñòü îïåðàö³é";
//
// toolStripTextBox_Operand
//
this->toolStripTextBox_Operand->BackColor = System::Drawing::SystemColors::Window;
this->toolStripTextBox_Operand->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, static_cast<System::Drawing::FontStyle>((System::Drawing::FontStyle::Bold | System::Drawing::FontStyle::Italic)),
System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(204)));
this->toolStripTextBox_Operand->ForeColor = System::Drawing::Color::Maroon;
this->toolStripTextBox_Operand->Name = L"toolStripTextBox_Operand";
this->toolStripTextBox_Operand->ReadOnly = true;
this->toolStripTextBox_Operand->Size = System::Drawing::Size(100, 26);
this->toolStripTextBox_Operand->TextBoxTextAlign = System::Windows::Forms::HorizontalAlignment::Center;
//
// toolStripSeparator3
//
this->toolStripSeparator3->Name = L"toolStripSeparator3";
this->toolStripSeparator3->Size = System::Drawing::Size(6, 26);
//
// InvForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(9, 19);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(774, 462);
this->Controls->Add(this->toolStrip);
this->Controls->Add(this->tableLayoutTop);
this->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->Margin = System::Windows::Forms::Padding(4);
this->MinimumSize = System::Drawing::Size(790, 500);
this->Name = L"InvForm";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;
this->Text = L"Îáåðíåíà ìàòðèöÿ";
this->Load += gcnew System::EventHandler(this, &InvForm::InvForm_Load);
this->Shown += gcnew System::EventHandler(this, &InvForm::InvForm_Shown);
this->tableLayoutTop->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->matrix_InvTable))->EndInit();
this->tableLayoutBottom->ResumeLayout(false);
this->toolStrip->ResumeLayout(false);
this->toolStrip->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
// ---------- ï³äïðîãðàìà ïî䳿 ïî÷àòêîâîãî çàâàíòàæåííÿ ôîðìè ----------------
private: System::Void InvForm_Load(System::Object^ sender, System::EventArgs^ e) {
matrix_InvTable->AutoResizeColumns(); // âèð³âíÿòè êë³òèíè Grid-a
toolStripTextBox_Time->Text = Convert::ToString(calc_time) + " ìëñ"; // êîíâåðòóâàòè çàïèñàòè ÷àñ îá÷èñëåííÿ â ðÿäîê ³ çàïèñàòè éîãî â ñòàòóñáàð
toolStripTextBox_Iterac->Text = Convert::ToString(kolIter); // êîíâåðòóâàòè ê³ëüê³ñòü âèêîíàíèõ â ìåòîä³ ³òåðàö³é â ðÿäîê ³ çàïèñàòè ðåçóëüòàò â ñòàòóñáàð
toolStripTextBox_Operand->Text = Convert::ToString(kolOperation); // êîíâåðòóâàòè ê³ëüê³ñòü âèêîíàíèõ â ìåòîä³ îïåðàö³é (+-*/) â ðÿäîê ³ çàïèñàòè ðåçóëüòàò â ñòàòóñáàð
}
// ---------- ï³äïðîãðàìà ïî䳿 ïîêàçó ôîðìè ----------------
private: System::Void InvForm_Shown(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show(matrix_InvTable->Text, "Óñï³õ", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
// ---------- ï³äïðîãðàìà ïåðåâ³ðêè íà êîðåêòí³ñòü âì³ñòó Grid-a ³ çàïèñó éîãî åëåìåíò³â â ìàòðèöþ ----------------
public: 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_InvTable->Rows[i]->Cells[j]->Value), matrix[i][j]); // êîíâåðòóâàòè åëåìåíò â double ³ ïåðåâ³ðèòè ïðàâèëüí³ñòü
}
return (err) ? NULL : matrix; // ïîâåðíóòè: NULL, ÿêùî âèíèêëà ïîìèëêà, ³íàêøå, àäðåñó ìàòðèö³ À
}
// ---------- ï³äïðîãðàìà çàïèñó ìàòðèö³ ðîçì³ðíîñò³ 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 bSaveRes_Click(System::Object^ sender, System::EventArgs^ e) {
int N = Convert::ToInt32(matrix_InvTable->Tag); // êîíâåðòóâàòè ðîçì³ðí³ñòü Grid-a â ÷èñëî
if (GridToMatrix(N)) { // ÿêùî âñ³ åëåìåíòè Grid-a êîðåêòí³ ÷èñëà, òî çàïèñàòè ¿õ ó ôàéë
SaveFileDialog ^saveFileDialogTo = gcnew System::Windows::Forms::SaveFileDialog();
saveFileDialogTo->Title = "Çáåðåæåííÿ îáåðíåíî¿ ìàòðèö³ äî ôàéëó";
saveFileDialogTo->InitialDirectory = Path::Combine(Application::StartupPath, "\Result"); // âñòàíîâèòè ïî÷àòêîâó ïàïêó äëÿ ÷èòàííÿ (ïàïêà Result ïîâèííà áóòè â ïàïö³ ³ç exe-ôàéëîì)
saveFileDialogTo->Filter = "Ôàéëè ³ç çàâäàííÿ|*.tsk|Ôàéëè ³ç ð³øåííÿì|*.res|Âñ³ ôàéëè|*.*";
saveFileDialogTo->FilterIndex = 2; // âñòàíîâèòè îñíîâíèì (ïîòî÷íèì) äðóãèé ô³ëüòð
if (saveFileDialogTo->ShowDialog() == System::Windows::Forms::DialogResult::OK && saveFileDialogTo->FileName->Length > 0) {// â³äêðèòè ä³àëîã çàïèñó äî ôàéëó
double **A = GridToMatrix(N); // êîíâåðòóâàòè Gr³d â ìàòðèöþ double
SaveTo(A, saveFileDialogTo->FileName, Convert::ToInt32(N)); // âèêîíàòè çàïèñ ³íôîðìàö³¿ ç ìàòðèö³ äî ôàéëó
}
else
MessageBox::Show("Îáåðíåíó ìàòðèöþ äî ôàéëó ÍÅ ÇÁÅÐÅÆÅÍÎ!", "Ïîìèëêà", MessageBoxButtons::OK, MessageBoxIcon::Warning);
}
}
// ---------- ï³äïðîãðàìà çàêðèòòÿ ö³º¿ ôîðìè ----------------
private: System::Void bClose_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
};
}