rols-> Add (This-> button1);
this-> Controls-> Add (This-> comboBox1);
this-> Name = L В«Form1В»;
this-> Text = L В«COM КомутнікаторВ»;
this-> Load + = Gcnew System: EventHandler (this, & Form1: Form1_Load);
this-> ResumeLayout (false);
this-> PerformLayout ();
}
# pragma endregion
private: System: Void Form1_Load (System: Object ^ sender, System: EventArgs ^ e) {
array ^ ports = serialPort1-> GetPortNames ();
int i = 0;
comboBox1-> Items-> Clear ();
for (I = 0; i Length; i + +) {
comboBox1-> Items-> Add (Ports [i]);
}
comboBox1-> SelectedIndex = 0;
comboBox2-> SelectedIndex = 7;
}
private: System: Void button2_Click (System: Object ^ sender, System: EventArgs ^ e) {
String ^ portName = (String ^) comboBox1-> SelectedItem;
array ^ buffer = gcnew array (1000);
unsigned int bytesRead = 0;
if (! File: Exists (textBox1-> Text)) {
MessageBox: Show (В«такий файл не існуєВ», В«ПомилкаВ»,
MessageBoxButtons: OK, MessageBoxIcon: Error);
}
else {p> int numBytesRead = 0;
FileStream ^ f = gcnew FileStream (textBox1-> Text, FileMode: Open, FileAccess: Read);
FileInfo ^ fi = gcnew FileInfo (textBox1-> Text);
unsigned int fileSize = fi-> Length;
String ^ fileName = fi-> Name;
String ^ fileSizeStr = «» + fileSize;
// for files only
array ^ b1 = fileName-> ToCharArray ();
label4-> Text = В«Передача файлуВ» + fileName + В»...В»;
serialPort1-> PortName = PortName;
serialPort1-> BaudRate = Int32: Parse (comboBox2-> Text);
serialPort1-> WriteTimeout = 10000;
serialPort1-> Open ();
serialPort1-> WriteLine (fileName);
serialPort1-> WriteLine (fileSizeStr);
while (BytesRead
numBytesRead = F-> Read (buffer, 0,1000);
serialPort1-> Write (Buffer, 0, numBytesRead);
bytesRead + = NumBytesRead;
label4-> Text = «³дісланоВ» + (bytesRead * 100/fileSize) + В«%В»;
progressBar1-> Value = (BytesRead * 100/fileSize);
Update ();
}
serialPort1-> Close ();
f-> Close ();
MessageBox: Show ("Файл" + fileName + В«успішне переданоВ», В«пердачу файлуВ», MessageBoxButtons: OK, MessageBoxIcon: Information);
progressBar1-> Value = 0;
label4-> Text = «»; p> Update ();
}
}
private: System: Void button1_Click (System: Object ^ sender, System: EventArgs ^ e) {
String ^ fileName;
String ^ fileSizeStr;
unsigned int fileSize;
String ^ portName = (String ^) comboBox1-> SelectedItem;
label4-> Text = В«Очікування файлу ...В»;
serialPort1-> PortName = PortName;
serialPort1-> BaudRate = Int32: Parse (comboBox2-> Text);
serialPort1-> ReadTimeout = 10000;
serialPort1-> Open ();
fileName = SerialPort1-> ReadLine ();
fileSizeStr = SerialPort1-> ReadLine ();
fileSize = Int32: Parse (fileSizeStr);
array ^ buffer = gcnew array (1000);
unsigned int bytesRead = 0;
if (! Directory: Exists (В».// FilesВ»)) {
Directory: CreateDirectory (В».// FilesВ»);
}
if (File: Exists (В».// Files//В» + fileName)) {
MessageBox: Show (В«такий файл вже існуєВ», В«ПомилкаВ»,
MessageBoxButtons: OK, MessageBoxIcon: Error);
}
else {p> int numBytesRead = 0;
FileStream ^ w = gcnew FileStream (В«files//В» + fileName, FileMode: OpenOrCreate, FileAccess: Write);
FileInfo ^ fi = gcnew FileInfo (В«files//В» + fileName);
// for files only
label4-> Text = В«Прийом файлуВ» + fileName + В»...В»;
while (BytesRead
numBytesRead = SerialPort1-> Read (buffer, 0,1000);
w-> Write (Buffer, 0, numBytesRead);
bytesRead + = NumBytesRead;
label4-> Text = В«ОТРИМАНОВ» + (bytesRead * 100/fileSize) + В«%В»;
progressBar1-> Value = (BytesRead * 100/fileSize);
Update ();
}
serialPort1-> Close ();
w-> Close ();
MessageBox: Show ("Файл" + fileName + В«успішне Прийнято:В» + fi-> FullName, В«пердачу файлуВ», MessageBoxButtons: OK, MessageBoxIcon: Information);
progressBar1-> Value = 0;
label4-> Text = «»; p> Update ();
serialPort1-> Close ();
}
}
private: System: Void openFileDialog1_FileOk (System: Object ^ sender, System: ComponentModel: CancelEventArgs ^ e) {
}
private: System: Void label1_Click (System: Object ^ sender, System: EventArgs ^ e) {
}
private: System: Void button3_Click (System: Object ^ sender, Syste...