public static Image appendImageToMsgBox(frm_group frmGroup, string name, DateTime time, byte[] imageData) { var image = Image.FromStream(new MemoryStream(imageData)); if (!frmGroup.IsHandleCreated) { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.InsertImage(image); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); } else { frmGroup.Invoke(new Action(() => { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.InsertImage(image); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); })); } return(image); }
public static void appendFileToMsgBox(frm_group frmGroup, string name, DateTime time, string fileName, long objId) { if (!frmGroup.IsHandleCreated) { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.AppendText(fileName); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.InsertLink("下载文件[" + objId + "]"); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); } else { frmGroup.Invoke(new Action(() => { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.AppendText(fileName); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.InsertLink("下载文件[" + objId + "]"); frmGroup.rtxt_message.AppendText("\n"); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); })); } }
public static void appendSysMsgToMsgBox(frm_group frmGroup, string content, DateTime time) { if (!frmGroup.IsHandleCreated) { frmGroup.rtxt_message.AppendRichText("[系统消息]" + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Blue); frmGroup.rtxt_message.AppendText(content + "\r\n"); frmGroup.rtxt_message.ForeColor = Color.Black; frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); } else { frmGroup.Invoke(new Action(() => { frmGroup.rtxt_message.AppendRichText("[系统消息]" + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Blue); frmGroup.rtxt_message.AppendText(content + "\r\n"); frmGroup.rtxt_message.ForeColor = Color.Black; frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); })); } }
public static void appendRtfToMsgBox(frm_group frmGroup, string name, DateTime time, string content) { if (!frmGroup.IsHandleCreated) { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.AppendRtf(content); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); } else { frmGroup.Invoke(new Action(() => { frmGroup.rtxt_message.AppendRichText(name + " " + time.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n", new Font(frmGroup.Font, FontStyle.Regular), Color.Green); frmGroup.rtxt_message.AppendRtf(content); frmGroup.rtxt_message.Select(frmGroup.rtxt_message.Text.Length, 0); frmGroup.rtxt_message.ScrollToCaret(); frmGroup.rtxt_send.Focus(); })); } }