public void rev_text(SKMsgInfoText t) { Action <SKMsgInfoText> rich1act = (x) => { if (x.text_pack.text == "\\抖一抖") { if (richTextBox1.Text != string.Empty) { richTextBox1.AppendText("\r\n"); } add_text_rich1("你被他抖了一抖!", Color.Blue); shake(); return; } if (richTextBox1.Text != string.Empty) { richTextBox1.AppendText("\r\n"); } int c1 = richTextBox1.Text.Length; richTextBox1.AppendText(t.text_pack.name + " " + t.timestamp.ToString() + "\r\n" + t.text_pack.text); richTextBox1.Select(c1, richTextBox1.Text.Length - c1); richTextBox1.SelectionColor = Color.Green; richTextBox1.Select(0, 0); label1.Text = friend.show_name + "(" + friend.stu_num + ")"; label2.Text = friend.comment; richTextBox1.SelectionStart = richTextBox1.Text.Length; richTextBox1.ScrollToCaret(); //friend.name = t.text_pack.name; }; richTextBox1.Invoke(rich1act, t); }
public void send_text(string target_stu_num, string text) { master.refresh(); IPAddress tar_ip = find_ip(target_stu_num); if (tar_ip != null) { SKMsgInfoText sit = new SKMsgInfoText(); sit.stu_num = my_stu_num; sit.text_pack.text = text; sit.text_pack.name = master.get_name(); sit.id = random.Next(0, 65535); sit.type = SKMsgInfoBase.mestype.TEXT; sit.timestamp = DateTime.Now; clients.SendNotFile(sit, tar_ip, target_stu_num); } }