예제 #1
0
 /// <summary>
 /// Автоматический поиск нужного порта и подключение к ниму.
 /// </summary>
 private void AutoFindPort()
 {
     foreach (var port in SignalPort.GetListPorts())
     {
         if (SignalView.GSMSignaler.PortDevice)
         {
             break;
         }
         if (SignalView.GSMSignaler.NotIsNull())
         {
             SignalView.GSMSignaler.Close();
         }
         if (SignalView.GSMSignaler.Init(port))
         {
             SignalView.GSMSignaler.SendTestSignal();
             SignalView.GSMSignaler.sPort.OnReceived = (data, objPort, sd) =>
             {
                 if (data.Length > 1)
                 {
                     SetPort(objPort.PortName);
                     comboBoxPorts.GuiAsync(() =>
                     {
                         comboBoxPorts.SelectedItem = objPort.PortName;
                     });
                     SignalView.GSMSignaler.PortDevice = true;
                     return;
                 }
             };
         }
         Thread.Sleep(1000);
     }
 }
예제 #2
0
 private void SetCurrentPorts()
 {
     comboBoxPorts.DataSource = null;
     ComboBox.ObjectCollection itemsPorts = new ComboBox.ObjectCollection(comboBoxPorts);
     foreach (var port in SignalPort.GetListPorts())
     {
         itemsPorts.Add(port);
     }
     comboBoxPorts.DataSource    = itemsPorts;
     comboBoxPorts.DropDownStyle = ComboBoxStyle.DropDownList;
 }