Ejemplo n.º 1
0
 public Collegamento(Form1 F, int numm)
 {
     InitializeComponent();
     receivingUdpClient = F.receivingUdpClient;
     i      = 0;
     this.F = F;
     if (numm == 1)
     {
         M = new CModulo(1);
         M = F.M1;
     }
     else if (numm == 2)
     {
         M = new CModulo(2);
         M = F.M2;
     }
     MessageBox.Show(M.getIP());
     listView1.View = View.Details;
     // Allow the user to edit item text.
     listView1.LabelEdit = true;
     // Allow the user to rearrange columns.
     listView1.AllowColumnReorder = true;
     // Select the item and subitems when selection is made.
     listView1.FullRowSelect = true;
     // Display grid lines.
     listView1.GridLines = true;
     listView1.Columns.Add("Nome rete d'area", -2, HorizontalAlignment.Left);
     porte = SerialPort.GetPortNames();
     comboBox1.Items.AddRange(porte);
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool      ricevi    = true;
            UdpClient udpClient = new UdpClient(M1.getIP(), 82);

            Byte[] sendBytes = Encoding.ASCII.GetBytes("b");
            udpClient.Send(sendBytes, sendBytes.Length);
            while (ricevi)
            {
                Byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
                string s            = System.Text.Encoding.UTF8.GetString(receiveBytes);
                //MessageBox.Show(s);
                if (s == "s")
                {
                    button3.Enabled   = true;
                    label12.ForeColor = Color.Green;
                    M1.setConn();
                    ricevi = false;
                }
                MessageBox.Show("Primo fatto");
                //Thread.Sleep(4000);
                //UdpClient udpClient2 = new UdpClient(M2.getIP(), 82);
                //udpClient2.Send(sendBytes, sendBytes.Length);
                //while (ricevi)
                //{
                //    Byte[] receiveBytes2 = receivingUdpClient.Receive(ref RemoteIpEndPoint);
                //    s = System.Text.Encoding.UTF8.GetString(receiveBytes2);
                //    //MessageBox.Show(s);
                //    if (s == "s")
                //    {
                //        button3.Enabled = true;
                //        label13.ForeColor = Color.Green;
                //        M2.setConn();
                //        ricevi = false;
                //    }
                //    //Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
                //}
            }
        }