Implement "Enter To Send"
This commit is contained in:
parent
4ce4fb963e
commit
8b4834822e
5
qtc-net-client-2/Forms/Chat.Designer.cs
generated
5
qtc-net-client-2/Forms/Chat.Designer.cs
generated
@ -41,6 +41,7 @@
|
|||||||
rtxtChatbox.Size = new Size(512, 54);
|
rtxtChatbox.Size = new Size(512, 54);
|
||||||
rtxtChatbox.TabIndex = 1;
|
rtxtChatbox.TabIndex = 1;
|
||||||
rtxtChatbox.Text = "";
|
rtxtChatbox.Text = "";
|
||||||
|
rtxtChatbox.KeyDown += rtxtChatbox_KeyDown;
|
||||||
//
|
//
|
||||||
// btnSend
|
// btnSend
|
||||||
//
|
//
|
||||||
@ -63,7 +64,7 @@
|
|||||||
rtxtChat.TabIndex = 3;
|
rtxtChat.TabIndex = 3;
|
||||||
rtxtChat.Text = "";
|
rtxtChat.Text = "";
|
||||||
//
|
//
|
||||||
// frmChat
|
// Chat
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
@ -75,7 +76,7 @@
|
|||||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
Name = "frmChat";
|
Name = "Chat";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "QtC.NET Client - Chat Room";
|
Text = "QtC.NET Client - Chat Room";
|
||||||
FormClosing += frmChat_FormClosing;
|
FormClosing += frmChat_FormClosing;
|
||||||
|
@ -62,6 +62,12 @@ namespace qtc_net_client_2.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rtxtChatbox_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if(e.KeyCode == Keys.Enter)
|
||||||
|
btnSend_Click(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
private void _gatewayService_OnServerMessageReceived(object? sender, EventArgs e)
|
private void _gatewayService_OnServerMessageReceived(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var msgEventArgs = (ServerMessageEventArgs)e;
|
var msgEventArgs = (ServerMessageEventArgs)e;
|
||||||
|
5
qtc-net-client-2/Forms/DirectMessage.Designer.cs
generated
5
qtc-net-client-2/Forms/DirectMessage.Designer.cs
generated
@ -67,6 +67,7 @@
|
|||||||
rtxtChatbox.Size = new Size(511, 54);
|
rtxtChatbox.Size = new Size(511, 54);
|
||||||
rtxtChatbox.TabIndex = 4;
|
rtxtChatbox.TabIndex = 4;
|
||||||
rtxtChatbox.Text = "";
|
rtxtChatbox.Text = "";
|
||||||
|
rtxtChatbox.KeyDown += rtxtChatbox_KeyPress;
|
||||||
//
|
//
|
||||||
// lblUsername
|
// lblUsername
|
||||||
//
|
//
|
||||||
@ -79,7 +80,7 @@
|
|||||||
lblUsername.TabIndex = 7;
|
lblUsername.TabIndex = 7;
|
||||||
lblUsername.Text = "Username";
|
lblUsername.Text = "Username";
|
||||||
//
|
//
|
||||||
// frmDirectMessage
|
// DirectMessage
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
@ -95,7 +96,7 @@
|
|||||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||||
Margin = new Padding(4, 3, 4, 3);
|
Margin = new Padding(4, 3, 4, 3);
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
Name = "frmDirectMessage";
|
Name = "DirectMessage";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "QtC.NET Client - Direct Message With ${USER}";
|
Text = "QtC.NET Client - Direct Message With ${USER}";
|
||||||
Load += frmDirectMessage_Load;
|
Load += frmDirectMessage_Load;
|
||||||
|
@ -76,22 +76,31 @@ namespace qtc_net_client_2.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rtxtChatbox_KeyPress(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
// mimick clicking send
|
||||||
|
if(e.KeyCode == Keys.Enter)
|
||||||
|
btnSend_Click(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
private void Messages_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
private void Messages_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if(e.NewItems != null)
|
if (e.NewItems != null && e.NewItems.Count > 0)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
{
|
{
|
||||||
Invoke(delegate ()
|
Invoke(delegate ()
|
||||||
{
|
{
|
||||||
rtxtChat.Text += e.NewItems.Cast<string>().FirstOrDefault();
|
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
||||||
AudioService.PlaySoundEffect("sndMessage");
|
rtxtChat.Text += msg;
|
||||||
|
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rtxtChat.Text += e.NewItems.Cast<string>().FirstOrDefault();
|
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
||||||
AudioService.PlaySoundEffect("sndMessage");
|
rtxtChat.Text += msg;
|
||||||
|
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user