public int RecentSave = 0; //最近一次保存聊天记录的位置 public Friend(string name, string word = "我们可以开始聊天啦", bool IsGroup = false) //新添加好友时首发信息是对话 { if (IsGroup == true) { IsGroupChat = true; } this.Name = name; Random rand = new Random((int)DateTime.Now.Ticks); int i = -1; BasicInfo.LoadPortraitList(); for (int j = 0; j < BasicInfo.PortraitList.Count(); j++) { if (name.Equals(BasicInfo.PortraitList[j].Substring(0, 10))) { i = int.Parse(BasicInfo.PortraitList[j].Substring(11, 1)); break; } } if (IsGroupChat == true)//群聊头像固定为10号 { i = 10; } if (i == -1) { i = rand.Next(1, 10);//随机生成头像信息并记录 string NewString = Name + " " + i.ToString(); BasicInfo.AddPortraitList(NewString); } Tag = new FriendTag(name, word); Tag.SetPortrait(i); PeopleCount++; Tag.setFront1 += new SetFront1(HelpsetFront); //点击标签时弹出相应对话框 InitFlowLayoutPanel(name); //初始化对话框 Bitmap Portrait = Tag.GetPortrait(); SendBox NewSend = new SendBox(word, 0, Portrait, name); string temp = "[" + NewSend.GetTime() + "]" + this.Name + ":" + word; this.WordList.Add(temp); ChatPanel.Controls.Add(NewSend);//对话框显示欢迎信息"我们可以开始聊天啦" }