public ShowForm(deviceInfo info) { InitializeComponent(); if (info.type == netType.TCP) { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { idasEp = new IPEndPoint(IPAddress.Parse(info.ip), int.Parse(info.port)); } catch { MessageBox.Show("IP地址错误"); return; } socket.Connect(idasEp); c = new communication(socket); c.opdh += new onPictureDataHandler(getPictureDate); } else { //ipep = new IPEndPoint(IPAddress.Any, int.Parse(port)); //Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //udpSocket.Bind(ipep); cUdp = new communicationUdp(info.ip, int.Parse(info.port)); cUdp.opdh += new onPictureDataHandler(getPictureDate); } this.label2.Text = info.ip; this.label4.Text = "" + info.port; //this.progressBar1.Value = 100; }
public void setInfo(deviceInfo info) { this.name.Text = info.name; this.ip.Text = info.ip; this.port.Text = info.port; this.type.Text = info.type+""; }
public Boolean isInList(deviceInfo d,List<deviceInfo> list) { if (list.Count == 0) return false; foreach (deviceInfo device in list) { if ((d.ip == device.ip) && (d.type==device.type) && (d.name==device.name) &&(d.port==device.port)) return true; } return false; }
public void addToList(deviceInfo d,List<deviceInfo> list) { if (list.Count == 0) { list.Add(d); } else { foreach(deviceInfo di in list) { if(di.ip==d.ip) { return; } } list.Add(d); } }
public void parseName(byte[] b, string ip) { //System.Text.UnicodeEncoding converter = new System.Text.UnicodeEncoding(); //deviceInfo di = new deviceInfo(Encoding.Default.GetString(b), ip); deviceInfo di = new deviceInfo(ip); di.parseDeviceInfo(b); if (newDeivceList != null) addToList(di, newDeivceList); }