예제 #1
0
파일: MainForm.cs 프로젝트: thinhils/Teach
        private void ReceievePrivateMessage(PrivateChatRequest message)
        {
            var request = message.ToChatMessage();

            GlobalVariable.AddNewChat(request);
            OpenOrCreateChatForm(request, true);
        }
예제 #2
0
파일: ChatForm.cs 프로젝트: thinhils/Teach
        //private void ChatForm_Paint(object sender, PaintEventArgs e)
        //{
        //    Graphics g = e.Graphics;
        //    g.SmoothingMode = SmoothingMode.HighQuality;
        //    //  this.chatBox_history.BackColor = Color.WhiteSmoke;
        //    ////全屏蒙浓遮罩层
        //    //g.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), new Rectangle(0, 0, this.Width, this.chatBox_history.Top));
        //    //g.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), new Rectangle(0, this.chatBox_history.Top, this.chatBox_history.Width + this.chatBox_history.Left, this.Height - this.chatBox_history.Top));

        //    //线条
        //    // g.DrawLine(new Pen(Color.FromArgb(180, 198, 221)), new Point(0, this.chatBox_history.Top - 1), new Point(chatBox_history.Right, this.chatBox_history.Top - 1));
        //    //   g.DrawLine(new Pen(Color.FromArgb(180, 198, 221)), new Point(0, this.chatBox_history.Bottom), new Point(chatBox_history.Right, this.chatBox_history.Bottom));
        //}


        /// <summary>
        /// 发送聊天信息
        /// </summary>
        /// <param name="receieveUserName"></param>
        /// <param name="msg"></param>
        private bool SendMessageCommand(ChatMessage chatMessage)
        {
            var chatType = GlobalVariable.GetChatType(chatMessage.ReceieveUserName);

            if (chatType == ChatType.PrivateChat)
            {
                if (!GlobalVariable.LoginUserInfo.AllowPrivateChat)
                {
                    GlobalVariable.ShowError("您不允许发送私聊信息");
                    return(false);
                }
                PrivateChatRequest request = new PrivateChatRequest();
                request.guid            = Guid.NewGuid().ToString();
                request.msg             = chatMessage.Message;
                request.receivename     = chatMessage.ReceieveUserName;
                request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName;
                request.SendUserName    = GlobalVariable.LoginUserInfo.UserName;
                request.clientRole      = GlobalVariable.LoginUserInfo.UserType;
                // if (chatMessage.MessageType != MessageType.String)
                //  {
                request.MessageType     = chatMessage.MessageType;
                request.DownloadFileUrl = chatMessage.DownloadFileUrl;
                // }
                GlobalVariable.client.Send_PrivateChat(request);
            }
            else if (chatType == ChatType.TeamChat)
            {
                if (!GlobalVariable.LoginUserInfo.AllowTeamChat)
                {
                    GlobalVariable.ShowError("您不允许发送群聊信息");
                    return(false);
                }
                var             chat    = GlobalVariable.GetChatStoreByUserName(chatMessage.ReceieveUserName);
                TeamChatRequest request = new TeamChatRequest();
                request.groupname       = chat.ChatDisplayName;
                request.groupuserList   = chat.GetUserNames();
                request.msg             = chatMessage.Message;
                request.username        = GlobalVariable.LoginUserInfo.UserName;
                request.groupid         = chatMessage.ReceieveUserName;
                request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName;
                request.clientRole      = GlobalVariable.LoginUserInfo.UserType;
                request.MessageType     = chatMessage.MessageType;
                request.DownloadFileUrl = chatMessage.DownloadFileUrl;
                GlobalVariable.client.Send_TeamChat(request);
                //  GlobalVariable.client.SendMessage(request, CommandType.TeamChat);
            }
            else if (chatType == ChatType.GroupChat)
            {
                var request = new GroupChatRequest();
                request.msg             = chatMessage.Message;
                request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName;
                request.SendUserName    = groupId;
                request.clientRole      = GlobalVariable.LoginUserInfo.UserType;
                request.MessageType     = chatMessage.MessageType;
                request.DownloadFileUrl = chatMessage.DownloadFileUrl;
                GlobalVariable.client.Send_GroupChat(request);
            }
            //   GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg);
            return(true);
        }
예제 #3
0
        public void Send_PrivateChat(PrivateChatRequest request)
        {
            SendMessage <PrivateChatRequest> message = new SendMessage <PrivateChatRequest>();

            message.Action = (int)CommandType.PrivateChat;
            message.Data   = request;
            Task.Run(async() =>
            {
                await this.SendMessage(message);
            });
        }
예제 #4
0
파일: ChatForm.cs 프로젝트: thinhils/Teach
        private void SendMessage(string msg)
        {
            PrivateChatRequest request = new PrivateChatRequest();

            request.guid        = Guid.NewGuid().ToString();
            request.msg         = msg;
            request.receivename = _userName;
            request.sendname    = GlobalVariable.LoginUserInfo.DisplayName;

            GlobalVariable.client.Send_PrivateChat(request);
            //   GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg);
        }
예제 #5
0
파일: ChatForm.cs 프로젝트: thinhils/Teach
        public void AddReceivedMsg(PrivateChatRequest response)
        {
            ChatBoxContent content  = new ChatBoxContent(response.msg, messageFont, Color.Black);
            var            showTime = DateTime.Now.ToLongTimeString();

            this.chatBox_history.AppendRichText(string.Format("{0}  {1}\n", response.sendname, showTime),
                                                new Font(this.messageFont, FontStyle.Regular), Color.Blue);
            content.Text = "    " + content.Text.Replace("\n", "\n    ");
            this.chatBox_history.AppendChatBoxContent(content);
            this.chatBox_history.AppendText("\n");
            this.chatBox_history.Select(this.chatBox_history.Text.Length, 0);
            this.chatBox_history.ScrollToCaret();
        }
예제 #6
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            PrivateChatRequest q = new PrivateChatRequest();

            q.clientRole      = ClientRole.Teacher;
            q.guid            = Guid.NewGuid().ToString();
            q.MessageType     = MessageType.String;
            q.msg             = DateTime.Now.Ticks.ToString();
            q.receivename     = "stu001";
            q.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName;
            q.SendUserName    = GlobalVariable.LoginUserInfo.UserName;

            GlobalVariable.client.Send_PrivateChat(q);
        }
예제 #7
0
        //public static AddChatRequest ToAddChatRequest(this PrivateChatRequest response)
        //{
        //    AddChatRequest request = new AddChatRequest();
        //    request.UserName = response.SendUserName;
        //    request.DisplayName = response.SendDisplayName;
        //    request.ChatType = ChatType.PrivateChat;
        //    request.Message = response.msg;
        //    request.UserType = response.clientRole;
        //    return request;
        //}

        public static ChatMessage ToChatMessage(this PrivateChatRequest response)
        {
            ChatMessage request = new ChatMessage();

            request.SendUserName     = response.SendUserName;
            request.SendDisplayName  = response.SendDisplayName;
            request.ChatType         = ChatType.PrivateChat;
            request.Message          = response.msg;
            request.UserType         = response.clientRole;
            request.DownloadFileUrl  = response.DownloadFileUrl;
            request.MessageType      = response.MessageType;
            request.ReceieveUserName = response.receivename;

            return(request);
        }
예제 #8
0
        /// <summary>
        /// 接收到私聊信息
        /// </summary>
        /// <param name="privateChatResponse"></param>
        private void AppendToPrivateForm(PrivateChatRequest privateChatResponse)
        {
            AddChatRequest request = privateChatResponse.ToAddChatRequest();

            GlobalVariable.AddNewChat(request);
            if (CheckChatFormIsOpen())
            {
                //   chatForm.DoReveieveMessage(request);
                OpenOrCreateChatForm(request, true);
            }
            else
            {
                OpenOrCreateChatForm(request, true);
                // ShowNotify(request);
            }
        }
예제 #9
0
        private void SendPrivateMsg()
        {
            string msg = PrivateContentRtb.Text.Trim();

            if (msg != "")
            {
                PrivateChatRequest request = new PrivateChatRequest();
                request.guid            = Guid.NewGuid().ToString();
                request.msg             = msg;
                request.receivename     = _userName;
                request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName;
                request.SendUserName    = GlobalVariable.LoginUserInfo.UserName;
                GlobalVariable.client.Send_PrivateChat(request);
                //  GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg);
                PrivateContentRtb.Text = "";
                PrivateHistRtb.AppendText(request.SendDisplayName + " "
                                          + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n" + request.msg + "\r\n\r\n");
            }
        }
예제 #10
0
 /// <summary>
 /// 私聊
 /// </summary>
 /// <param name="request"></param>
 public void Send_PrivateChat(PrivateChatRequest request)
 {
     SendMessage(request, CommandType.PrivateChat);
 }