예제 #1
0
 private void btnUser_Click(object sender, EventArgs e)
 {
     try
     {
         FileIndex = 0;
         UDPReceive.receiveQueueForAudio = new Queue <byte[]>();
         CsConst.MyBlnFinish             = false;
         CsConst.isStartUploadFile       = false;
         string MyPath = HDLPF.OpenFileDialog("WAV File|*.wav", "Choose File");
         if (MyPath == null || MyPath == "")
         {
             return;
         }
         FileStream fs = new FileStream(MyPath, FileMode.Open, FileAccess.Read);//创建文件流
         SourceFile = new byte[fs.Length];
         fs.Read(SourceFile, 0, SourceFile.Length);
         fs.Flush();
         fs.Close();
         int    FileLength  = SourceFile.Length;
         string strFileNmae = "share/sounds/linphone/rings/011.wav";
         byte[] arayTmp     = new byte[strFileNmae.Length + 6 + 2];
         int    DataLength  = strFileNmae.Length + 6;
         arayTmp[0] = Convert.ToByte(DataLength / 256);
         arayTmp[1] = Convert.ToByte(DataLength % 256);
         arayTmp[2] = 1;
         byte[] arayName = HDLUDP.StringToByte(strFileNmae);
         arayName.CopyTo(arayTmp, 3);
         arayTmp[strFileNmae.Length + 3] = 13;
         arayTmp[strFileNmae.Length + 4] = Convert.ToByte(FileLength / 256 / 256 / 256);
         arayTmp[strFileNmae.Length + 5] = Convert.ToByte(FileLength / 256 / 256 % 256);
         arayTmp[strFileNmae.Length + 6] = Convert.ToByte(FileLength / 256 % 256);
         arayTmp[strFileNmae.Length + 7] = Convert.ToByte(FileLength % 256);
         if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1364, SubNetID, DevID, true, true, true, false) == true)
         {
             if (CsConst.isStartUploadFile)
             {
                 MyBackGroup                       = new BackgroundWorker();
                 MyBackGroup.DoWork               += new DoWorkEventHandler(calculationWorker_DoWork);
                 MyBackGroup.ProgressChanged      += new ProgressChangedEventHandler(calculationWorker_ProgressChanged);
                 MyBackGroup.WorkerReportsProgress = true;
                 MyBackGroup.RunWorkerCompleted   += new RunWorkerCompletedEventHandler(calculationWorker_RunWorkerCompleted);
                 MyBackGroup.RunWorkerAsync();
                 MyBackGroup.WorkerSupportsCancellation = true;
                 frmProcessTmp = new FrmProcess();
                 frmProcessTmp.ShowDialog();
             }
             else
             {
                 MessageBox.Show(CsConst.mstrINIDefault.IniReadValue("public", "99535", ""));
             }
         }
     }
     catch
     {
     }
 }
예제 #2
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     timer1.Interval   = Convert.ToInt32(txtTime.Text);
     timer1.Enabled    = !timer1.Enabled;
     panel1.Enabled    = !timer1.Enabled;
     NumCount.Enabled  = !timer1.Enabled;
     txtTime.Enabled   = !timer1.Enabled;
     btnStart.Enabled  = !timer1.Enabled;
     btnExport.Enabled = !timer1.Enabled;
     dgvCommands.Text  = "";
     UDPReceive.receiveQueueForSingnal.Clear();
     SendCount = 0;
     frmTmp    = new FrmProcess();
     frmTmp.ShowDialog();
 }