コード例 #1
0
        public override bool SendMessage(string word)
        {
            long   time = Time.Now();
            string url  = WxApi.SendMessageUrl +
                          "?sid=" + CurrentUser.WxSid +
                          "&skey=" + CurrentUser.Skey +
                          "&pass_ticket=" + CurrentUser.PassTicket +
                          "&r=" + time;

            JObject jsonObj = new JObject();

            jsonObj.Add("BaseRequest", JObject.FromObject(CurrentUser.BaseRequest));
            SendMsg msg = new SendMsg();

            msg.FromUserName = CurrentUser.Me.UserName;
            msg.ToUserName   = user.UserName;
            msg.Type         = 1;
            msg.Content      = word;
            msg.ClientMsgId  = time;
            msg.LocalID      = time;
            TB_SendBox.Clear();
            jsonObj.Add("Msg", JObject.FromObject(msg));

            WxSendMsg wxsendmsg = HttpRequest.PostJsonSync <WxSendMsg>(url, jsonObj);

            TB_Receive.Text += "我:\n" + msg.Content + "\n";

            return(true);
        }
コード例 #2
0
 private void TB_SendBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter && (Keyboard.Modifiers & (ModifierKeys.Control)) == (ModifierKeys.Control))
     {
         // 添加一个换行字符
         TB_SendBox.SelectedText = Environment.NewLine;
         // 光标向前移动一位
         TB_SendBox.Select(TB_SendBox.SelectionStart + 1, 0);
         e.Handled = true;
     }
     else if (e.Key == Key.Enter)
     {
         L_Send_OnMouseDown(null, null);
         e.Handled = true;
     }
 }