Exemplo n.º 1
0
 private void mnuConnectSer_Click(object sender, EventArgs e)
 {
     bUseSocket = false;
     ConnectDlg dlg = new ConnectDlg(ref comport);
     dlg.ShowDialog();
     if(dlg.DialogResult==DialogResult.OK){
         dlg.Dispose();
         showLangSelect(ref comport, ref btport);
     }
     else
         dlg.Dispose();
 }
Exemplo n.º 2
0
        //private System.Net.Sockets.NetworkStream connectBT(byte[] ba)
        //{
        //    Cursor.Current = Cursors.WaitCursor;
        //    System.Net.Sockets.NetworkStream ns=null;
        //    try
        //    {
        //        BluetoothAddress bda = new BluetoothAddress(ba);
        //        //System.Net.Sockets.Socket socket = new System.Net.Sockets.Socket();
        //        BluetoothClient btClient = new BluetoothClient();
        //        btClient.Connect(new BluetoothEndPoint(bda, BluetoothService.SerialPort));
        //        ns = btClient.GetStream();
        //        return ns;
        //        //    System.IO.StreamWriter sw = new System.IO.StreamWriter(ns);
        //        //    if (sw.BaseStream != null)
        //        //    {
        //        //        if (sw.BaseStream.CanWrite)
        //        //        {
        //        //            //byte[] buf = Encoding.ASCII.GetBytes(fp_text);
        //        //            sw.Write(fp_text); //ns.Write(buf, 0, buf.Length);
        //        //            //ns.Flush();
        //        //            sw.Flush();
        //        //        }
        //        //        sw.Close();
        //        //    }
        //        //    ns.Close();
        //        //    btClient.CloseSocket();
        //        //    btClient.Close();
        //        //    Cursor.Current = Cursors.Default;
        //        //}
        //    }
        //    catch (Exception x)
        //    {
        //        Cursor.Current = Cursors.Default;
        //        MessageBox.Show("Exception :" + x.Message);
        //        return ns;
        //    }
        //}

        private void mnuSerialConnect_Click(object sender, EventArgs e)
        {
            ConnectDlg dlg = new ConnectDlg(ref comport);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (comport.IsOpen)
                {
                    bUseSocket          = false;
                    mnuConnectMain.Text = "Disconnect";
                    enableControls(true);
                }
            }
        }
Exemplo n.º 3
0
        private void mnuConnect_Click(object sender, EventArgs e)
        {
            if (mnuConnect.Text == "Disconnect")
            {
                comport.ReadExisting();
                comport.Close();
                mnuConnect.Text = "Connect";
                return;
            }

            ConnectDlg dlg = new ConnectDlg(ref comport);
            dlg.ShowDialog();
            if (comport.IsOpen)
            {
                mnuConnect.Text = "Disconnect";
                txtReceive.Invoke(new EventHandler(delegate { txtReceive.Text += comport.PortName + " opened\r\n"; }));
            }
            else
                mnuConnect.Text = "Connect";
        }
Exemplo n.º 4
0
        private void mnuConnect_Click(object sender, EventArgs e)
        {
            if (mnuConnect.Text == "Disconnect")
            {
                comport.ReadExisting();
                comport.Close();
                mnuConnect.Text = "Connect";
                return;
            }

            ConnectDlg dlg = new ConnectDlg(ref comport);

            dlg.ShowDialog();
            if (comport.IsOpen)
            {
                mnuConnect.Text = "Disconnect";
                txtReceive.Invoke(new EventHandler(delegate { txtReceive.Text += comport.PortName + " opened\r\n"; }));
            }
            else
            {
                mnuConnect.Text = "Connect";
            }
        }
Exemplo n.º 5
0
        //private System.Net.Sockets.NetworkStream connectBT(byte[] ba)
        //{
        //    Cursor.Current = Cursors.WaitCursor;
        //    System.Net.Sockets.NetworkStream ns=null;
        //    try
        //    {
        //        BluetoothAddress bda = new BluetoothAddress(ba);
        //        //System.Net.Sockets.Socket socket = new System.Net.Sockets.Socket();
        //        BluetoothClient btClient = new BluetoothClient();
        //        btClient.Connect(new BluetoothEndPoint(bda, BluetoothService.SerialPort));
        //        ns = btClient.GetStream();
        //        return ns;
        //        //    System.IO.StreamWriter sw = new System.IO.StreamWriter(ns);
        //        //    if (sw.BaseStream != null)
        //        //    {
        //        //        if (sw.BaseStream.CanWrite)
        //        //        {
        //        //            //byte[] buf = Encoding.ASCII.GetBytes(fp_text);
        //        //            sw.Write(fp_text); //ns.Write(buf, 0, buf.Length);
        //        //            //ns.Flush();
        //        //            sw.Flush();
        //        //        }
        //        //        sw.Close();
        //        //    }
        //        //    ns.Close();
        //        //    btClient.CloseSocket();
        //        //    btClient.Close();
        //        //    Cursor.Current = Cursors.Default;
        //        //}
        //    }
        //    catch (Exception x)
        //    {
        //        Cursor.Current = Cursors.Default;
        //        MessageBox.Show("Exception :" + x.Message);
        //        return ns;
        //    }
        //}

        private void mnuSerialConnect_Click(object sender, EventArgs e)
        {
            ConnectDlg dlg = new ConnectDlg(ref comport);
            if(dlg.ShowDialog()==DialogResult.OK){
                if (comport.IsOpen)
                {
                    bUseSocket = false;
                    mnuConnectMain.Text="Disconnect";
                    enableControls(true);
                }
            }
            
        }