mirror of https://github.com/2dust/v2rayN
Adjust avaloniaEdit
parent
148d6ef90b
commit
76dc14ee45
|
@ -20,6 +20,7 @@
|
|||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||
<PackageVersion Include="ReactiveUI.WPF" Version="20.4.1" />
|
||||
<PackageVersion Include="Semi.Avalonia" Version="11.2.1.10" />
|
||||
<PackageVersion Include="Semi.Avalonia.AvaloniaEdit" Version="11.2.0.1" />
|
||||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.2.1.10" />
|
||||
<PackageVersion Include="NLog" Version="6.0.4" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
|
@ -9,6 +10,7 @@ namespace ServiceLib.ViewModels;
|
|||
public class MsgViewModel : MyReactiveObject
|
||||
{
|
||||
private readonly ConcurrentQueue<string> _queueMsg = new();
|
||||
private readonly StringBuilder _msgBuilder = new();
|
||||
private readonly int _numMaxMsg = 500;
|
||||
private bool _lastMsgFilterNotAvailable;
|
||||
private bool _blLockShow = false;
|
||||
|
@ -43,11 +45,6 @@ public class MsgViewModel : MyReactiveObject
|
|||
|
||||
private async Task AppendQueueMsg(string msg)
|
||||
{
|
||||
//if (msg == Global.CommandClearMsg)
|
||||
//{
|
||||
// ClearMsg();
|
||||
// return;
|
||||
//}
|
||||
if (AutoRefresh == false)
|
||||
{
|
||||
return;
|
||||
|
@ -65,9 +62,18 @@ public class MsgViewModel : MyReactiveObject
|
|||
|
||||
_blLockShow = true;
|
||||
|
||||
await Task.Delay(500);
|
||||
var txt = string.Join("", _queueMsg.ToArray());
|
||||
await _updateView?.Invoke(EViewAction.DispatcherShowMsg, txt);
|
||||
_msgBuilder.Clear();
|
||||
//foreach (var it in _queueMsg)
|
||||
//{
|
||||
// _msgBuilder.Append(it);
|
||||
//}
|
||||
while (_queueMsg.TryDequeue(out var line))
|
||||
{
|
||||
_msgBuilder.Append(line);
|
||||
}
|
||||
|
||||
|
||||
await _updateView?.Invoke(EViewAction.DispatcherShowMsg, _msgBuilder.ToString());
|
||||
|
||||
_blLockShow = false;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
RequestedThemeVariant="Default">
|
||||
<Application.Styles>
|
||||
<semi:SemiTheme />
|
||||
<semi:AvaloniaEditSemiTheme />
|
||||
<StyleInclude Source="Assets/GlobalStyles.axaml" />
|
||||
<StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" />
|
||||
<StyleInclude Source="avares://AvaloniaEdit/Themes/Simple/AvaloniaEdit.xaml" />
|
||||
<dialogHost:DialogHostStyles />
|
||||
</Application.Styles>
|
||||
<Application.Resources>
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
<x:Double x:Key="IconButtonWidth">32</x:Double>
|
||||
<x:Double x:Key="IconButtonHeight">32</x:Double>
|
||||
<x:Double x:Key="MenuFlyoutMaxHeight">1000</x:Double>
|
||||
<x:Double x:Key="FontSizeNormal">14</x:Double>
|
||||
<FontFamily x:Key="ContentControlThemeFontFamily">Cascadia Code,Consolas,Menlo,Monospace</FontFamily>
|
||||
|
||||
<Thickness x:Key="Margin2">2</Thickness>
|
||||
<Thickness x:Key="MarginLr4">4,0</Thickness>
|
||||
|
|
|
@ -71,13 +71,28 @@
|
|||
Theme="{DynamicResource SimpleToggleSwitch}" />
|
||||
</WrapPanel>
|
||||
|
||||
<ScrollViewer x:Name="msgScrollViewer" VerticalScrollBarVisibility="Auto">
|
||||
<avaloniaEdit:TextEditor
|
||||
Name="txtMsg"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Margin="{StaticResource Margin8}"
|
||||
IsReadOnly="True"
|
||||
ShowLineNumbers="True"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</ScrollViewer>
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<avaloniaEdit:TextEditor.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem
|
||||
x:Name="menuMsgViewCopy"
|
||||
Click="menuMsgViewCopy_Click"
|
||||
Header="{x:Static resx:ResUI.menuMsgViewCopy}" />
|
||||
<MenuItem
|
||||
x:Name="menuMsgViewCopyAll"
|
||||
Click="menuMsgViewCopyAll_Click"
|
||||
Header="{x:Static resx:ResUI.menuMsgViewCopyAll}" />
|
||||
<MenuItem
|
||||
x:Name="menuMsgViewClear"
|
||||
Click="menuMsgViewClear_Click"
|
||||
Header="{x:Static resx:ResUI.menuMsgViewClear}" />
|
||||
</MenuFlyout>
|
||||
</avaloniaEdit:TextEditor.ContextFlyout>
|
||||
</avaloniaEdit:TextEditor>
|
||||
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -44,9 +44,11 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
|
|||
|
||||
private void ShowMsg(object msg)
|
||||
{
|
||||
txtMsg.Text = msg.ToString();
|
||||
// txtMsg.Text = msg.ToString();
|
||||
txtMsg.AppendText(msg.ToString());
|
||||
if (togScrollToEnd.IsChecked ?? true)
|
||||
{
|
||||
txtMsg.ScrollToEnd();
|
||||
_scrollViewer?.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<PackageReference Include="Avalonia.ReactiveUI" />
|
||||
<PackageReference Include="MessageBox.Avalonia" />
|
||||
<PackageReference Include="Semi.Avalonia" />
|
||||
<PackageReference Include="Semi.Avalonia.AvaloniaEdit" />
|
||||
<PackageReference Include="Semi.Avalonia.DataGrid">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
|
|
Loading…
Reference in New Issue