// Кнопка Выбрать сигнал(F3) private void button13_Click(object sender, EventArgs e) { try { SignalOutput SO = new SignalOutput(); OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = modelsPath; if (OFD.ShowDialog() == DialogResult.OK) { Messages("Выбран файл: " + OFD.FileName); OutputIR = SO.ConvertingBINARYorXMLtoIRsignal(OFD.FileName); if (OutputIR != null) { label1.Enabled = true; button3.Enabled = true; textBox1.Enabled = true; label4.Enabled = true; button7.Enabled = true; textBox3.Enabled = true; button2.Enabled = true; } } SearchRedRat SR = new SearchRedRat(); RedRat3 = SR.FindRedRat(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Event for ItemActivate private void listView1_ItemActivate(object sender, EventArgs e) { SignalOutput SO = new SignalOutput(); SearchRedRat SR = new SearchRedRat(); RedRat3 = SR.FindRedRat(); string newPath = pathClick + "\\" + listView1.FocusedItem.Text; if (File.Exists(newPath))//Checker is folder or file { //MessageBox.Show("File is choice!"); //Process.Start(pathClick); OutputIR = SO.ConvertingBINARYorXMLtoIRsignal(newPath); if (OutputIR != null) { Messages("Выбран файл: " + listView1.FocusedItem.Text); label1.Enabled = true; button3.Enabled = true; textBox1.Enabled = true; label4.Enabled = true; button7.Enabled = true; textBox3.Enabled = true; button2.Enabled = true; } } else { AddFoldersWithFileFromEnterPath(newPath, false); } }
// Захват сигнала public void CaptureSignal(string fileName = "") { OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = Form1.pathClick; SearchRedRat SRR = new SearchRedRat(); if (SRR.FindRedRat() != null) { RedRat3 = SRR.FindRedRat(); RedRat3.LearningSignalIn += SignalDataHandler; RedRat3.GetModulatedSignal(10000);//Ввод сигнала в RedRat3 осуществляется в течении 10с haveSignal = false; while (!haveSignal) { Thread.Sleep(100); } if (modSignal != null) { var mes = MessageBox.Show("OK - cохранить XML" + Environment.NewLine + "CANCEL - cохранить BIN", "Вариант сохранения файла", MessageBoxButtons.OKCancel); if (mes == DialogResult.OK) { inputName IN = new inputName(); IN.ShowDialog(); RRUtil.SerializePacketToXML(Form1.pathClick + "\\" + IN.name + ".xml", modSignal); tempMessage = "XML файл \"" + IN.name + "\" сохранен."; } else { inputName IN = new inputName(); IN.ShowDialog(); RRUtil.SerializePacketToBinary(Form1.pathClick + "\\" + IN.name + ".bin", modSignal);//SerializePacketToXML //var m = MessageBox.Show("Файл \"" + IN.name + "\" сохранен.", "Прием сигнала", MessageBoxButtons.OK); tempMessage = "BIN файл \"" + IN.name + "\" сохранен."; } } else { MessageBox.Show("Сигнал не был получен. Прием окончен.", "Прием сигнала", MessageBoxButtons.OK); } } }
// Кнопка захвата одиночного сигнала private void button1_Click(object sender, EventArgs e) { try { SearchRedRat SR3 = new SearchRedRat(); RedRat3 = SR3.FindRedRat(); if (RedRat3 != null) { IRsignalTrainingMode IRSTM = new IRsignalTrainingMode(); var FTC = new FormTimerCapture(10, "Подайте сигнал с пульта"); var waitsignal2 = Task.Factory.StartNew(() => { FTC.ShowDialog(); }); var qwe = Task.Factory.StartNew(() => { IRSTM.CaptureSignal(); OutputIR = IRSTM.GetSignal(); if (OutputIR != null) { label1.Enabled = true; button3.Enabled = true; textBox1.Enabled = true; label4.Enabled = true; button7.Enabled = true; textBox3.Enabled = true; button2.Enabled = true; AddFoldersWithFileFromEnterPath(pathClick); FTC.Close(); } }); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }