예제 #1
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (serialPort1.IsOpen)
     {
         if (button5.Text == "开始发送")
         {
             if (checkBox1.Checked == true)
             {
                 type            = 1;
                 timer1.Interval = Convert.ToInt32(numericUpDown1.Value) * 1000;
                 timer1.Enabled  = true;
                 button1.Enabled = false;
             }
             else
             {
                 TimerAction.timerAction(this, type);
             }
         }
         else if (button5.Text == "停止发送")
         {
             timer1.Enabled    = false;
             button1.Enabled   = true;
             textBox1.Text     = "";
             groupBox2.Enabled = true;
             button5.Text      = "开始发送";
         }
     }
     else
     {
         timer1.Enabled    = false;
         groupBox2.Enabled = true;
         textBox1.Text     = "";
         button5.Text      = "开始发送";
         MessageBox.Show("请先打开串口 再发送数据");
     }
 }
예제 #2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     TimerAction.timerAction(this, type);
 }