public void addUcf(Friend f) { UCFriend ucf = new UCFriend(); ucf.Fg = this; ucf.CurFriend = f; ucf.Top = this.FriendList.Controls.Count * ucf.Height; this.FriendList.Controls.Add(ucf); }
private void listen() { UdpClient uc = new UdpClient(9527); while (true) { IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0); byte[] bmsg = uc.Receive(ref ipep); string msg = Encoding.Default.GetString(bmsg); string[] datas = msg.Split('|'); if( datas.Length !=4) { continue; } if(datas[0]=="LOGIN") { Friend friend = new Friend(); int curIndex = Convert.ToInt32(datas[2]); if(curIndex<0||curIndex>this.liHeadImages.Images.Count) { curIndex = 0; } friend.HeadImageINdex = curIndex; friend.NickName = datas[1]; friend.Shuoshuo = datas[3]; UCFriend ucf = new UCFriend(); object[] pars = new object[1]; pars[0] = friend; this.Invoke(new delAddFriend(this.addUcf), pars[0]); } } }