Added chat functionality (broken)

This commit is contained in:
2015-10-17 21:47:04 +02:00
parent 09a23d48f3
commit 42e9b18ab5
5 changed files with 17 additions and 6 deletions
@@ -159,7 +159,7 @@ namespace ErgometerApplication
ParseValueSet(command); ParseValueSet(command);
break; break;
case NetCommand.CommandType.CHAT: case NetCommand.CommandType.CHAT:
Chat.Add(new ChatMessage(Name, command.ChatMessage)); Chat.Add(new ChatMessage(Name, command.ChatMessage, true));
Client.chat.AddChatItem(command.ChatMessage); Client.chat.AddChatItem(command.ChatMessage);
break; break;
case NetCommand.CommandType.RESPONSE: case NetCommand.CommandType.RESPONSE:
@@ -139,26 +139,28 @@ namespace ErgometerApplication
this.Location = new System.Drawing.Point(0, 0); this.Location = new System.Drawing.Point(0, 0);
this.Name = "container"; this.Name = "container";
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseWheel); this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseWheel);
Form.CheckForIllegalCrossThreadCalls = false;
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
if (richTextBox1.TextLength > 1) if (richTextBox1.TextLength > 1)
{ {
AddChatItem(richTextBox1.Text, DateTime.Now.ToString("h:mm:ss tt"), false); AddChatItem(richTextBox1.Text, Helper.MillisecondsToTime(Helper.Now), false);
MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, MainClient.Session)); MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, MainClient.Session));
richTextBox1.ResetText(); richTextBox1.ResetText();
} }
} }
public void AddChatItem(string chatmessage) public void AddChatItem(string text)
{ {
flowLayoutPanel1.Controls.Add(new ChatItem(text, Helper.MillisecondsToTime(Helper.Now), true));
} }
public void AddChatItem(string text, bool isDoctor) public void AddChatItem(string text, bool isDoctor)
{ {
flowLayoutPanel1.Controls.Add(new ChatItem(text, DateTime.Now.ToString("h:mm:ss tt"), isDoctor)); flowLayoutPanel1.Controls.Add(new ChatItem(text, Helper.MillisecondsToTime(Helper.Now), isDoctor));
} }
public void AddChatItem(string text, string time, bool isDoctor) public void AddChatItem(string text, string time, bool isDoctor)
@@ -81,6 +81,7 @@ namespace ErgometerApplication
this.textBoxPassword.PasswordChar = '*'; this.textBoxPassword.PasswordChar = '*';
this.textBoxPassword.Size = new System.Drawing.Size(167, 20); this.textBoxPassword.Size = new System.Drawing.Size(167, 20);
this.textBoxPassword.TabIndex = 2; this.textBoxPassword.TabIndex = 2;
this.textBoxPassword.KeyDown += TextBoxPassword_KeyDown;
// //
// textBoxUsername // textBoxUsername
// //
@@ -138,6 +139,14 @@ namespace ErgometerApplication
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBike)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBike)).EndInit();
} }
private void TextBoxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
buttonLogin_Click(this, new EventArgs());
}
}
public void buttonLogin_Click(object sender, EventArgs e) public void buttonLogin_Click(object sender, EventArgs e)
{ {
string username = textBoxUsername.Text; string username = textBoxUsername.Text;