Fix Auto Scroll
This commit is contained in:
parent
85a0ecc4f4
commit
ed80ab05c1
2
qtc-net-client-2/Forms/Chat.Designer.cs
generated
2
qtc-net-client-2/Forms/Chat.Designer.cs
generated
@ -57,13 +57,13 @@
|
|||||||
//
|
//
|
||||||
// rtxtChat
|
// rtxtChat
|
||||||
//
|
//
|
||||||
|
rtxtChat.HideSelection = false;
|
||||||
rtxtChat.Location = new Point(12, 12);
|
rtxtChat.Location = new Point(12, 12);
|
||||||
rtxtChat.Name = "rtxtChat";
|
rtxtChat.Name = "rtxtChat";
|
||||||
rtxtChat.ReadOnly = true;
|
rtxtChat.ReadOnly = true;
|
||||||
rtxtChat.Size = new Size(593, 250);
|
rtxtChat.Size = new Size(593, 250);
|
||||||
rtxtChat.TabIndex = 3;
|
rtxtChat.TabIndex = 3;
|
||||||
rtxtChat.Text = "";
|
rtxtChat.Text = "";
|
||||||
rtxtChat.TextChanged += rtxtChat_TextChanged;
|
|
||||||
//
|
//
|
||||||
// Chat
|
// Chat
|
||||||
//
|
//
|
||||||
|
@ -68,12 +68,6 @@ namespace qtc_net_client_2.Forms
|
|||||||
btnSend_Click(sender, e);
|
btnSend_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rtxtChat_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
rtxtChat.SelectionStart = rtxtChatbox.Text.Length;
|
|
||||||
rtxtChat.ScrollToCaret();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _gatewayService_OnServerMessageReceived(object? sender, EventArgs e)
|
private void _gatewayService_OnServerMessageReceived(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var msgEventArgs = (ServerMessageEventArgs)e;
|
var msgEventArgs = (ServerMessageEventArgs)e;
|
||||||
@ -85,8 +79,8 @@ namespace qtc_net_client_2.Forms
|
|||||||
private void AddMessage(string message)
|
private void AddMessage(string message)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
Invoke(delegate { rtxtChat.Text += message + "\n"; });
|
Invoke(delegate { rtxtChat.AppendText(message + Environment.NewLine); });
|
||||||
else rtxtChat.Text += message + "\n";
|
else rtxtChat.AppendText(message + Environment.NewLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
qtc-net-client-2/Forms/DirectMessage.Designer.cs
generated
2
qtc-net-client-2/Forms/DirectMessage.Designer.cs
generated
@ -37,6 +37,7 @@
|
|||||||
//
|
//
|
||||||
// rtxtChat
|
// rtxtChat
|
||||||
//
|
//
|
||||||
|
rtxtChat.HideSelection = false;
|
||||||
rtxtChat.Location = new Point(12, 56);
|
rtxtChat.Location = new Point(12, 56);
|
||||||
rtxtChat.Margin = new Padding(4, 3, 4, 3);
|
rtxtChat.Margin = new Padding(4, 3, 4, 3);
|
||||||
rtxtChat.Name = "rtxtChat";
|
rtxtChat.Name = "rtxtChat";
|
||||||
@ -44,7 +45,6 @@
|
|||||||
rtxtChat.Size = new Size(593, 317);
|
rtxtChat.Size = new Size(593, 317);
|
||||||
rtxtChat.TabIndex = 6;
|
rtxtChat.TabIndex = 6;
|
||||||
rtxtChat.Text = "";
|
rtxtChat.Text = "";
|
||||||
rtxtChat.TextChanged += rtxtChat_TextChanged;
|
|
||||||
//
|
//
|
||||||
// btnSend
|
// btnSend
|
||||||
//
|
//
|
||||||
|
@ -83,12 +83,6 @@ namespace qtc_net_client_2.Forms
|
|||||||
btnSend_Click(sender, e);
|
btnSend_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rtxtChat_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
rtxtChat.SelectionStart = rtxtChatbox.Text.Length;
|
|
||||||
rtxtChat.ScrollToCaret();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 && e.NewItems.Count > 0)
|
if (e.NewItems != null && e.NewItems.Count > 0)
|
||||||
@ -98,14 +92,14 @@ namespace qtc_net_client_2.Forms
|
|||||||
Invoke(delegate ()
|
Invoke(delegate ()
|
||||||
{
|
{
|
||||||
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
||||||
rtxtChat.Text += msg;
|
rtxtChat.AppendText(msg + Environment.NewLine);
|
||||||
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
var msg = e.NewItems.Cast<string>().FirstOrDefault();
|
||||||
rtxtChat.Text += msg;
|
rtxtChat.AppendText(msg + Environment.NewLine);
|
||||||
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
if (!msg!.Contains(_apiService.CurrentUser.Username)) AudioService.PlaySoundEffect("sndMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user