示例#1
0
        private void OpenCOM_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!ComPort.ComisOpen())
                {
                    string strcom = comboBox.Items[comboBox.SelectedIndex].ToString();
                    if (strcom != "")
                    {
                        if (ComPort.OpenCOM(strcom))
                        {
                            OpenCOM.Content    = "CloseCOM";
                            comboBox.IsEnabled = false;
                            bBegin.IsEnabled   = true;
                            bEnd.IsEnabled     = true;
                            bBlink.IsEnabled   = true;
                            bInit.IsEnabled    = true;
                            radiate.IsEnabled  = true;
                            bindb.IsEnabled    = true;
                            wificon.IsEnabled  = true;
                        }
                        else
                        {
                            MessageBox.Show("Can not Open");
                        }
                    }
                }
                else
                {
                    ComPort.CloseCOM();
                    radiate.IsEnabled  = false;
                    OpenCOM.Content    = "OpenCOM";
                    comboBox.IsEnabled = true;
                    bBegin.IsEnabled   = false;
                    bEnd.IsEnabled     = false;
                    bBlink.IsEnabled   = false;
                    bInit.IsEnabled    = false;

                    bindname.IsEnabled = true;
                    bindb.Content      = "Bind";

                    radiate.Content   = "Radiate";
                    bindb.IsEnabled   = false;
                    wificon.IsEnabled = false;
                    RF_DataAnalysis.Stop_RadioSend();
                }
            }
            catch
            {
                MessageBox.Show("Can not Open");
            }
        }