Skip to content

Commit ad88e92

Browse files
committed
add: 搞几个包数据展示的效果,具体待定
1 parent 903a28f commit ad88e92

File tree

11 files changed

+338
-38
lines changed

11 files changed

+338
-38
lines changed

llcomNext/LLCOM/App.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public override void OnFrameworkInitializationCompleted()
2828
collection.AddSingleton<ToolsPageViewModel>();
2929
collection.AddSingleton<ScriptPageViewModel>();
3030
collection.AddSingleton<OnlinePageViewModel>();
31+
collection.AddSingleton<LogPageViewModel>();
3132
collection.AddSingleton<SettingPageViewModel>();
3233

3334
collection.AddSingleton<PacketDataViewModel>();

llcomNext/LLCOM/LLCOM.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
<ItemGroup>
1515
<Folder Include="Assets\Images\" />
16-
<Folder Include="Models\" />
1716
<AvaloniaResource Include="Assets\**" />
1817
</ItemGroup>
1918

@@ -71,5 +70,9 @@
7170
<DependentUpon>PacketDataView.axaml</DependentUpon>
7271
<SubType>Code</SubType>
7372
</Compile>
73+
<Compile Update="Views\Pages\LogPageView.axaml.cs">
74+
<DependentUpon>LogPageView.axaml</DependentUpon>
75+
<SubType>Code</SubType>
76+
</Compile>
7477
</ItemGroup>
7578
</Project>

llcomNext/LLCOM/Models/PacketData.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
3+
namespace LLCOM.Models;
4+
5+
public class PacketData
6+
{
7+
/// <summary>
8+
/// 此包收到的时间
9+
/// </summary>
10+
public DateTime Time { get; set; } = DateTime.Now;
11+
12+
/// <summary>
13+
/// 包内的原始数据
14+
/// </summary>
15+
public byte[] Data { get; set; } = [];
16+
17+
/// <summary>
18+
/// 包的额外信息
19+
/// </summary>
20+
public string? Extra { get; set; } = null;
21+
22+
/// <summary>
23+
/// 该包的字符串表示
24+
/// </summary>
25+
public string String { get; set; } = string.Empty;
26+
27+
/// <summary>
28+
/// 数据包的方向
29+
/// </summary>
30+
public MessageWay Way { get; set; } = MessageWay.Unknown;
31+
32+
/// <summary>
33+
/// 消息通道类型
34+
/// </summary>
35+
public string Channel { get; set; } = string.Empty;
36+
}
37+
38+
public enum MessageWay
39+
{
40+
Unknown,
41+
/// <summary>
42+
/// 从该软件发出的数据包
43+
/// </summary>
44+
Send,
45+
/// <summary>
46+
/// 从外部发到该软件的数据包
47+
/// </summary>
48+
Receive
49+
}

llcomNext/LLCOM/Styles/MainStyle.axaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
22
<Design.PreviewWith>
3-
<StackPanel>
3+
<StackPanel Width="200">
44
<Button Classes="IconButton Tertiary" Content="&#xEB56;" />
55
<Button Classes="IconButtonActive Tertiary" Content="&#xEB56;" />
66
</StackPanel>
@@ -33,4 +33,6 @@
3333
<Setter Property="Theme" Value="{DynamicResource LightButton}" />
3434
<Setter Property="Foreground" Value="{DynamicResource SemiColorSecondary}" />
3535
</Style>
36+
37+
3638
</Styles>

llcomNext/LLCOM/ViewModels/MainViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public partial class MainViewModel : ViewModelBase
1919
nameof(IsToolsPageActive),
2020
nameof(IsScriptPageActive),
2121
nameof(IsOnlinePageActive),
22+
nameof(IsLogPageActive),
2223
nameof(IsSettingPageActive)
2324
)]
2425
private ViewModelBase _currentPage;
@@ -27,6 +28,7 @@ public partial class MainViewModel : ViewModelBase
2728
public bool IsToolsPageActive => CurrentPage is ToolsPageViewModel;
2829
public bool IsScriptPageActive => CurrentPage is ScriptPageViewModel;
2930
public bool IsOnlinePageActive => CurrentPage is OnlinePageViewModel;
31+
public bool IsLogPageActive => CurrentPage is LogPageViewModel;
3032
public bool IsSettingPageActive => CurrentPage is SettingPageViewModel;
3133

3234
//用于设计时预览,正式代码中无效
@@ -48,6 +50,8 @@ public MainViewModel(Func<Type, ViewModelBase> getService)
4850
[RelayCommand]
4951
private void OnlinePageButton() => CurrentPage = _getService(typeof(OnlinePageViewModel));
5052
[RelayCommand]
53+
private void LogPageButton() => CurrentPage = _getService(typeof(LogPageViewModel));
54+
[RelayCommand]
5155
private void SettingPageButton() => CurrentPage = _getService(typeof(SettingPageViewModel));
5256

5357

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace LLCOM.ViewModels;
4+
5+
public partial class LogPageViewModel : ViewModelBase
6+
{
7+
private Func<Type, ViewModelBase> _getService;
8+
9+
//用于设计时预览,正式代码中无效
10+
public LogPageViewModel() {}
11+
12+
public LogPageViewModel(Func<Type, ViewModelBase> getService)
13+
{
14+
_getService = getService;
15+
}
16+
}
Lines changed: 196 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,206 @@
11
<UserControl
2-
d:DesignHeight="757"
3-
d:DesignWidth="762"
4-
mc:Ignorable="d"
52
x:Class="LLCOM.Views.PacketDataView"
6-
x:DataType="vm:PacketDataViewModel"
73
xmlns="https://github.com/avaloniaui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
85
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
96
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
107
xmlns:vm="using:LLCOM.ViewModels"
11-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
8+
d:DesignHeight="757"
9+
d:DesignWidth="762"
10+
x:DataType="vm:PacketDataViewModel"
11+
mc:Ignorable="d">
1212
<Design.DataContext>
1313
<vm:PacketDataViewModel />
1414
</Design.DataContext>
15-
PacketDataView
15+
<UserControl.Resources>
16+
<ResourceDictionary>
17+
<StaticResource x:Key="SendColor" ResourceKey="SemiRed8" />
18+
<StaticResource x:Key="ReceiveColor" ResourceKey="SemiGreen8" />
19+
<StaticResource x:Key="SendBackGround" ResourceKey="SemiRed1" />
20+
<StaticResource x:Key="ReceiveBackGround" ResourceKey="SemiGreen1" />
21+
</ResourceDictionary>
22+
</UserControl.Resources>
23+
<ScrollViewer>
24+
<StackPanel>
25+
<StackPanel Margin="10">
26+
<StackPanel Margin="0,0,0,3">
27+
<StackPanel Orientation="Horizontal">
28+
<TextBlock
29+
Classes="Block"
30+
FontSize="12"
31+
Text="[2025.03.11 11:22:33.123]" />
32+
<TextBlock
33+
Margin="10,0,10,0"
34+
Classes="Block"
35+
FontSize="12"
36+
FontWeight="Bold"
37+
Foreground="{DynamicResource SendColor}"
38+
Text="串口1 ==&gt; 本机" />
39+
</StackPanel>
40+
<SelectableTextBlock
41+
FontSize="16"
42+
Foreground="{DynamicResource SendColor}"
43+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
44+
TextWrapping="Wrap" />
45+
<SelectableTextBlock
46+
Classes="Block"
47+
FontSize="12"
48+
Foreground="{DynamicResource SemiColorText2}"
49+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
50+
TextWrapping="Wrap" />
51+
</StackPanel>
52+
<StackPanel Margin="0,0,0,3">
53+
<StackPanel Orientation="Horizontal">
54+
<TextBlock
55+
Classes="Block"
56+
FontSize="12"
57+
Text="[2025.03.11 11:22:33.123]" />
58+
<TextBlock
59+
Margin="10,0,10,0"
60+
Classes="Block"
61+
FontSize="12"
62+
FontWeight="Bold"
63+
Foreground="{DynamicResource ReceiveColor}"
64+
Text="本机 &lt;== 串口1" />
65+
</StackPanel>
66+
<SelectableTextBlock
67+
Classes="Block"
68+
FontSize="16"
69+
Foreground="{DynamicResource ReceiveColor}"
70+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
71+
TextWrapping="Wrap" />
72+
<SelectableTextBlock
73+
Classes="Block"
74+
FontSize="12"
75+
Foreground="{DynamicResource SemiColorText2}"
76+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
77+
TextWrapping="Wrap" />
78+
</StackPanel>
79+
</StackPanel>
80+
<StackPanel Margin="10">
81+
<Border
82+
Margin="0,0,0,3"
83+
BorderBrush="{DynamicResource SendColor}"
84+
BorderThickness="1">
85+
<StackPanel>
86+
<StackPanel Background="{DynamicResource SendColor}" Orientation="Horizontal">
87+
<TextBlock
88+
Classes="Block"
89+
FontSize="12"
90+
Foreground="{DynamicResource SemiColorHighlight}"
91+
Text="[2025.03.11 11:22:33.123]" />
92+
<TextBlock
93+
Margin="10,0,10,0"
94+
Classes="Block"
95+
FontSize="12"
96+
FontWeight="Bold"
97+
Foreground="{DynamicResource SemiColorHighlight}"
98+
Text="串口1 ==&gt; 本机" />
99+
</StackPanel>
100+
<SelectableTextBlock
101+
Margin="5,5,5,0"
102+
Classes="Block"
103+
FontSize="16"
104+
Foreground="{DynamicResource SendColor}"
105+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
106+
TextWrapping="Wrap" />
107+
<SelectableTextBlock
108+
Margin="5,0,5,5"
109+
Classes="Block"
110+
FontSize="12"
111+
Foreground="{DynamicResource SemiColorText2}"
112+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
113+
TextWrapping="Wrap" />
114+
</StackPanel>
115+
</Border>
116+
<Border
117+
Margin="0,0,0,3"
118+
BorderBrush="{DynamicResource ReceiveColor}"
119+
BorderThickness="1">
120+
<StackPanel>
121+
<StackPanel Background="{DynamicResource ReceiveColor}" Orientation="Horizontal">
122+
<TextBlock
123+
Classes="Block"
124+
FontSize="12"
125+
Foreground="{DynamicResource SemiColorHighlight}"
126+
Text="[2025.03.11 11:22:33.123]" />
127+
<TextBlock
128+
Margin="10,0,10,0"
129+
Classes="Block"
130+
FontSize="12"
131+
FontWeight="Bold"
132+
Foreground="{DynamicResource SemiColorHighlight}"
133+
Text="本机 &lt;== 串口1" />
134+
</StackPanel>
135+
<SelectableTextBlock
136+
Margin="5,5,5,0"
137+
Classes="Block"
138+
FontSize="16"
139+
Foreground="{DynamicResource ReceiveColor}"
140+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
141+
TextWrapping="Wrap" />
142+
<SelectableTextBlock
143+
Margin="5,0,5,5"
144+
Classes="Block"
145+
FontSize="12"
146+
Foreground="{DynamicResource SemiColorText2}"
147+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
148+
TextWrapping="Wrap" />
149+
</StackPanel>
150+
</Border>
151+
</StackPanel>
152+
<StackPanel Margin="10">
153+
<StackPanel Margin="0,0,0,3" Background="{DynamicResource SendBackGround}">
154+
<StackPanel Orientation="Horizontal">
155+
<TextBlock
156+
Classes="Block"
157+
FontSize="12"
158+
Text="[2025.03.11 11:22:33.123]" />
159+
<TextBlock
160+
Margin="10,0,10,0"
161+
Classes="Block"
162+
FontSize="12"
163+
FontWeight="Bold"
164+
Text="串口1 ==&gt; 本机" />
165+
</StackPanel>
166+
<SelectableTextBlock
167+
Classes="Block"
168+
FontSize="16"
169+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
170+
TextWrapping="Wrap" />
171+
<SelectableTextBlock
172+
Classes="Block"
173+
FontSize="12"
174+
Foreground="{DynamicResource SemiColorText2}"
175+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
176+
TextWrapping="Wrap" />
177+
</StackPanel>
178+
<StackPanel Margin="0,0,0,3" Background="{DynamicResource ReceiveBackGround}">
179+
<StackPanel Orientation="Horizontal">
180+
<TextBlock
181+
Classes="Block"
182+
FontSize="12"
183+
Text="[2025.03.11 11:22:33.123]" />
184+
<TextBlock
185+
Margin="10,0,10,0"
186+
Classes="Block"
187+
FontSize="12"
188+
FontWeight="Bold"
189+
Text="本机 &lt;== 串口1" />
190+
</StackPanel>
191+
<SelectableTextBlock
192+
Classes="Block"
193+
FontSize="16"
194+
Text="接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123接收到的xxx数据123123"
195+
TextWrapping="Wrap" />
196+
<SelectableTextBlock
197+
Classes="Block"
198+
FontSize="12"
199+
Foreground="{DynamicResource SemiColorText2}"
200+
Text="11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF"
201+
TextWrapping="Wrap" />
202+
</StackPanel>
203+
</StackPanel>
204+
</StackPanel>
205+
</ScrollViewer>
16206
</UserControl>

llcomNext/LLCOM/Views/MainView.axaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
Command="{Binding OnlinePageButtonCommand}"
4545
Content="&#xE288;"
4646
ToolTip.Tip="在线功能" />
47+
<Button
48+
Classes="IconButton Tertiary"
49+
Classes.IconButtonActive="{Binding IsLogPageActive}"
50+
Command="{Binding LogPageButtonCommand}"
51+
Content="&#xE94E;"
52+
ToolTip.Tip="历史日志" />
4753
</StackPanel>
4854
<Button
4955
Classes="IconButton Tertiary"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<UserControl
2+
d:DesignHeight="800"
3+
d:DesignWidth="381"
4+
mc:Ignorable="d"
5+
x:Class="LLCOM.Views.LogPageView"
6+
x:DataType="vm:LogPageViewModel"
7+
xmlns="https://github.com/avaloniaui"
8+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
xmlns:vm="using:LLCOM.ViewModels"
11+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
12+
<Design.DataContext>
13+
<vm:LogPageViewModel />
14+
</Design.DataContext>
15+
LogPageView
16+
</UserControl>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Avalonia;
2+
using Avalonia.Controls;
3+
using Avalonia.Markup.Xaml;
4+
5+
namespace LLCOM.Views;
6+
7+
public partial class LogPageView : UserControl
8+
{
9+
public LogPageView()
10+
{
11+
InitializeComponent();
12+
}
13+
}

0 commit comments

Comments
 (0)