2017-05-06 12:54:57 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace 软件系统客户端模版.UIControls
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class OnlineChatRender : UserControl
|
|
|
|
|
|
{
|
2017-05-18 17:13:42 +08:00
|
|
|
|
public OnlineChatRender(Action<string> send)
|
2017-05-06 12:54:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2017-05-18 17:13:42 +08:00
|
|
|
|
SendString = send;
|
2017-05-06 12:54:57 +08:00
|
|
|
|
}
|
2017-05-18 17:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
private Action<string> SendString = null;
|
|
|
|
|
|
|
2017-05-13 23:00:15 +08:00
|
|
|
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
//按下Enter键后进行发送数据到服务器
|
2017-05-18 17:13:42 +08:00
|
|
|
|
if(!string.IsNullOrEmpty(textBox1.Text))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
SendString?.Invoke(textBox1.Text);
|
|
|
|
|
|
textBox1.Text = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-05-13 23:00:15 +08:00
|
|
|
|
}
|
2017-05-17 22:20:52 +08:00
|
|
|
|
|
|
|
|
|
|
private void OnlineChatRender_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-05-18 17:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
public void DealwithReceive(string str)
|
|
|
|
|
|
{
|
|
|
|
|
|
richTextBox1.AppendText(str + Environment.NewLine);
|
|
|
|
|
|
}
|
2017-06-20 11:26:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新增聊天的历史记录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="str"></param>
|
|
|
|
|
|
public void AddChatsHistory(string str)
|
|
|
|
|
|
{
|
|
|
|
|
|
richTextBox1.Text = str;
|
|
|
|
|
|
}
|
2017-05-18 17:13:42 +08:00
|
|
|
|
|
|
|
|
|
|
public void InputFocus()
|
|
|
|
|
|
{
|
|
|
|
|
|
textBox1.Focus();
|
|
|
|
|
|
}
|
2017-05-06 12:54:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|