mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Update MsgView.axaml.cs
This commit is contained in:
parent
c3ab3532fb
commit
6a4a35bffe
1 changed files with 13 additions and 4 deletions
|
@ -10,12 +10,13 @@ namespace v2rayN.Desktop.Views;
|
||||||
|
|
||||||
public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
||||||
{
|
{
|
||||||
private readonly ScrollViewer _scrollViewer;
|
private const int MaxLines = 500;
|
||||||
|
|
||||||
public MsgView()
|
public MsgView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_scrollViewer = this.FindControl<ScrollViewer>("msgScrollViewer");
|
|
||||||
|
txtMsg.Options.AllowScrollBelowDocument = false;
|
||||||
|
|
||||||
ViewModel = new MsgViewModel(UpdateViewHandler);
|
ViewModel = new MsgViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
@ -44,12 +45,20 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
||||||
|
|
||||||
private void ShowMsg(object msg)
|
private void ShowMsg(object msg)
|
||||||
{
|
{
|
||||||
// txtMsg.Text = msg.ToString();
|
|
||||||
txtMsg.AppendText(msg.ToString());
|
txtMsg.AppendText(msg.ToString());
|
||||||
|
|
||||||
|
var doc = txtMsg.Document;
|
||||||
|
if (doc.LineCount > MaxLines)
|
||||||
|
{
|
||||||
|
int removeCount = doc.LineCount - MaxLines;
|
||||||
|
var line = doc.GetLineByNumber(removeCount);
|
||||||
|
int removeUpTo = line.EndOffset;
|
||||||
|
doc.Remove(0, removeUpTo);
|
||||||
|
}
|
||||||
|
|
||||||
if (togScrollToEnd.IsChecked ?? true)
|
if (togScrollToEnd.IsChecked ?? true)
|
||||||
{
|
{
|
||||||
txtMsg.ScrollToEnd();
|
txtMsg.ScrollToEnd();
|
||||||
_scrollViewer?.ScrollToEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue