Adjust avaloniaEdit

pull/8031/head
2dust 2025-09-25 19:56:59 +08:00
parent 148d6ef90b
commit 76dc14ee45
7 changed files with 44 additions and 21 deletions

View File

@ -20,6 +20,7 @@
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" /> <PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageVersion Include="ReactiveUI.WPF" Version="20.4.1" /> <PackageVersion Include="ReactiveUI.WPF" Version="20.4.1" />
<PackageVersion Include="Semi.Avalonia" Version="11.2.1.10" /> <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="Semi.Avalonia.DataGrid" Version="11.2.1.10" />
<PackageVersion Include="NLog" Version="6.0.4" /> <PackageVersion Include="NLog" Version="6.0.4" />
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" /> <PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />

View File

@ -1,5 +1,6 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ReactiveUI; using ReactiveUI;
using ReactiveUI.Fody.Helpers; using ReactiveUI.Fody.Helpers;
@ -9,6 +10,7 @@ namespace ServiceLib.ViewModels;
public class MsgViewModel : MyReactiveObject public class MsgViewModel : MyReactiveObject
{ {
private readonly ConcurrentQueue<string> _queueMsg = new(); private readonly ConcurrentQueue<string> _queueMsg = new();
private readonly StringBuilder _msgBuilder = new();
private readonly int _numMaxMsg = 500; private readonly int _numMaxMsg = 500;
private bool _lastMsgFilterNotAvailable; private bool _lastMsgFilterNotAvailable;
private bool _blLockShow = false; private bool _blLockShow = false;
@ -43,11 +45,6 @@ public class MsgViewModel : MyReactiveObject
private async Task AppendQueueMsg(string msg) private async Task AppendQueueMsg(string msg)
{ {
//if (msg == Global.CommandClearMsg)
//{
// ClearMsg();
// return;
//}
if (AutoRefresh == false) if (AutoRefresh == false)
{ {
return; return;
@ -65,9 +62,18 @@ public class MsgViewModel : MyReactiveObject
_blLockShow = true; _blLockShow = true;
await Task.Delay(500); _msgBuilder.Clear();
var txt = string.Join("", _queueMsg.ToArray()); //foreach (var it in _queueMsg)
await _updateView?.Invoke(EViewAction.DispatcherShowMsg, txt); //{
// _msgBuilder.Append(it);
//}
while (_queueMsg.TryDequeue(out var line))
{
_msgBuilder.Append(line);
}
await _updateView?.Invoke(EViewAction.DispatcherShowMsg, _msgBuilder.ToString());
_blLockShow = false; _blLockShow = false;
} }

View File

@ -11,9 +11,9 @@
RequestedThemeVariant="Default"> RequestedThemeVariant="Default">
<Application.Styles> <Application.Styles>
<semi:SemiTheme /> <semi:SemiTheme />
<semi:AvaloniaEditSemiTheme />
<StyleInclude Source="Assets/GlobalStyles.axaml" /> <StyleInclude Source="Assets/GlobalStyles.axaml" />
<StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" /> <StyleInclude Source="avares://Semi.Avalonia.DataGrid/Index.axaml" />
<StyleInclude Source="avares://AvaloniaEdit/Themes/Simple/AvaloniaEdit.xaml" />
<dialogHost:DialogHostStyles /> <dialogHost:DialogHostStyles />
</Application.Styles> </Application.Styles>
<Application.Resources> <Application.Resources>

View File

@ -11,8 +11,6 @@
<x:Double x:Key="IconButtonWidth">32</x:Double> <x:Double x:Key="IconButtonWidth">32</x:Double>
<x:Double x:Key="IconButtonHeight">32</x:Double> <x:Double x:Key="IconButtonHeight">32</x:Double>
<x:Double x:Key="MenuFlyoutMaxHeight">1000</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="Margin2">2</Thickness>
<Thickness x:Key="MarginLr4">4,0</Thickness> <Thickness x:Key="MarginLr4">4,0</Thickness>

View File

@ -71,13 +71,28 @@
Theme="{DynamicResource SimpleToggleSwitch}" /> Theme="{DynamicResource SimpleToggleSwitch}" />
</WrapPanel> </WrapPanel>
<ScrollViewer x:Name="msgScrollViewer" VerticalScrollBarVisibility="Auto">
<avaloniaEdit:TextEditor <avaloniaEdit:TextEditor
Name="txtMsg" Name="txtMsg"
HorizontalScrollBarVisibility="Auto" Margin="{StaticResource Margin8}"
IsReadOnly="True" IsReadOnly="True"
ShowLineNumbers="True" VerticalScrollBarVisibility="Auto">
VerticalScrollBarVisibility="Auto" /> <avaloniaEdit:TextEditor.ContextFlyout>
</ScrollViewer> <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> </DockPanel>
</UserControl> </UserControl>

View File

@ -44,9 +44,11 @@ public partial class MsgView : ReactiveUserControl<MsgViewModel>
private void ShowMsg(object msg) private void ShowMsg(object msg)
{ {
txtMsg.Text = msg.ToString(); // txtMsg.Text = msg.ToString();
txtMsg.AppendText(msg.ToString());
if (togScrollToEnd.IsChecked ?? true) if (togScrollToEnd.IsChecked ?? true)
{ {
txtMsg.ScrollToEnd();
_scrollViewer?.ScrollToEnd(); _scrollViewer?.ScrollToEnd();
} }
} }

View File

@ -18,6 +18,7 @@
<PackageReference Include="Avalonia.ReactiveUI" /> <PackageReference Include="Avalonia.ReactiveUI" />
<PackageReference Include="MessageBox.Avalonia" /> <PackageReference Include="MessageBox.Avalonia" />
<PackageReference Include="Semi.Avalonia" /> <PackageReference Include="Semi.Avalonia" />
<PackageReference Include="Semi.Avalonia.AvaloniaEdit" />
<PackageReference Include="Semi.Avalonia.DataGrid"> <PackageReference Include="Semi.Avalonia.DataGrid">
<TreatAsUsed>true</TreatAsUsed> <TreatAsUsed>true</TreatAsUsed>
</PackageReference> </PackageReference>