/// <summary> /// 发送语音消息 /// </summary> /// <param name="userID"></param> /// <param name="fileName"></param> /// <param name="originTime"></param> /// <param name="FileName"></param> public void AppendVoiceContent(ChromiumWebBrowser browser, string userID, string fileName, DateTime originTime, string MineID, string FriendID, string fontName, string fontSize) { string showTime = DateTime.Now.ToLongTimeString(); #region 添加聊天历史记录 bool isSelf = true; string sendName = MineID; string sendTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (userID == FriendID) { isSelf = false; sendName = FriendID; } if (!string.IsNullOrEmpty(sendName) && sendName.Contains("@")) { sendName = sendName.Substring(0, sendName.IndexOf('@')); } string voicePath = TempFile.FileUploadWebSite + "voice/" + fileName; string id = fileName.Contains(".") ? fileName.Substring(0, fileName.LastIndexOf('.')) : fileName; this.addHistory_VoiceTalk(browser, isSelf, sendName, sendTime, id, voicePath, fontName, fontSize); #endregion if (isSelf && FormObj is ChatFormForWeb) { ChatFormForWeb frm = (ChatFormForWeb)FormObj; ChatBoxContent content = new ChatBoxContent(); content.Text = SysParams.Sys_VoiceMessage + fileName; frm.OPENFIRE_SendMessage(content, FriendID); } }
/// <summary> /// 系统消息处理 /// </summary> /// <param name="form"></param> /// <param name="message"></param> public static void SysMessageManage(ChatFormForWeb form, string userID, string message, ChatBoxContent chatcontent) { switch (message) { case SysParams.Sys_VibrationMessage: //震动消息处理 form.AppendChatBoxContent(true, userID, DateTime.Now, chatcontent, Color.Blue, false); Common.VibrationThread(form); break; } }
//震动方法 public static void Vibration(object cfwObj) { ChatFormForWeb cfw = cfwObj as ChatFormForWeb; if (!Common.isVibrationing) { cfw.Invoke(new Action(() => { isVibrationing = true; Point pOld = cfw.Location; //原来的位置 int radius = 3; //半径 for (int n = 0; n < 3; n++) //旋转圈数 { //右半圆逆时针 for (int i = -radius; i <= radius; i++) { int x = Convert.ToInt32(Math.Sqrt(radius * radius - i * i)); int y = -i; cfw.Location = new Point(pOld.X + x, pOld.Y + y); System.Threading.Thread.Sleep(10); } //左半圆逆时针 for (int j = radius; j >= -radius; j--) { int x = -Convert.ToInt32(Math.Sqrt(radius * radius - j * j)); int y = -j; cfw.Location = new Point(pOld.X + x, pOld.Y + y); System.Threading.Thread.Sleep(10); } } //抖动完成,恢复原来位置 cfw.Location = pOld; isVibrationing = false; })); } }