Esempio n. 1
0
 private void Connect_Port_Click(object sender, EventArgs e)
 {
     try
     {
         if (Connect_Port.Text == "Connect")
         {
             GateCom.PortName = SelectCom.Text;
             GateCom.BaudRate = Int32.Parse(SelectBaurate.Text);
             GateCom.DataBits = Int32.Parse(DataBit.Text);
             GateCom.StopBits = StopBits.One;
             GateCom.Parity   = Parity.None;
             GateCom.Open();
             Connect_Port.Text = "Disconnect";
         }
         else
         {
             GateCom.Close();
             Connect_Port.Text = "Connect";
         }
         if (timer1.Enabled == false)
         {
             timer1.Enabled = true;
             timer1.Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(Convert.ToString("you have to choose a comport!"));
     }
 }
Esempio n. 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (GateCom.IsOpen)
     {
         GateCom.Write("Scan#");
         List_SSID.Items.Clear();
     }
 }
Esempio n. 3
0
 private void Connect_Wifi_Click(object sender, EventArgs e)
 {
     if (GateCom.IsOpen)
     {
         GateCom.Write("(" + SSID_Name.Text + ")");
         GateCom.Write("[" + Password_Text.Text + "]" + "#");
     }
     else
     {
         ErrorText_WifiStatus.Text = "Please choose the COMPORT";
     }
 }
Esempio n. 4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (GateCom.IsOpen)
     {
         s_InputData = GateCom.ReadExisting();
     }
     if (s_InputData != "")
     {
         if ((s_InputData[0] == '$'))
         {
             s_InputData = s_InputData.Remove(0, 1);
             ErrorText_WifiStatus.Text = s_InputData;
             if (s_InputData == "Connected")
             {
                 Error2_Text.Text      = "Connected";
                 Error2_Text.BackColor = Color.Green;
             }
             else if (s_InputData == "Cant Connected")
             {
                 Error2_Text.Text      = "DisConnected";
                 Error2_Text.BackColor = Color.Red;
             }
         }
         else
         {
             SSID_List[0] = s_InputData;
             List_SSID.Items.AddRange(SSID_List);
             List_SSID.Update();
         }
     }
     if (Check_SSID.CheckState == CheckState.Checked)
     {
         if (List_SSID.Text != "")
         {
             SSID_Name.Text = List_SSID.Text.Remove(0, 3);
             SSID_Name.Text = SSID_Name.Text.Remove(SSID_Name.Text.IndexOf('(') - 1);
         }
     }
 }