<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="using:NewLife.XCoder.Services"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:NewLife.XCoder.ViewModels"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="750"
x:Class="NewLife.XCoder.Views.MessageDebugWindow"
x:DataType="vm:MessageDebugViewModel"
Title="{loc:Tr 'Message Debugger'}" Width="1000" Height="750"
WindowStartupLocation="CenterOwner">
<Window.Styles>
<Style Selector="TextBox.ConfigTextBox">
<Setter Property="Margin" Value="2"/>
<Setter Property="Height" Value="32"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
</Style>
<Style Selector="Button.ActionButton">
<Setter Property="Height" Value="32"/>
<Setter Property="Padding" Value="12,0"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="Border.GroupBorder">
<Setter Property="Background" Value="{DynamicResource BgSurface2}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="10"/>
<Setter Property="Padding" Value="8"/>
<Setter Property="Margin" Value="0"/>
</Style>
</Window.Styles>
<Grid Margin="16" RowSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 连接配置 -->
<Border Grid.Row="0" Classes="GroupBorder">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{loc:Tr 'Mode'}" VerticalAlignment="Center" Margin="4,2"/>
<ComboBox Grid.Column="1" ItemsSource="{Binding Modes}" SelectedIndex="{Binding SelectedModeIndex}" Height="32" Margin="2"/>
<TextBlock Grid.Column="2" Text="{loc:Tr 'Address'}" VerticalAlignment="Center" Margin="4,2"/>
<TextBox Grid.Column="3" Text="{Binding Address}" Classes="ConfigTextBox"/>
<Button Grid.Column="4" Content="{Binding ConnectButtonText}" Command="{Binding ToggleConnectCommand}" Classes="ActionButton" Width="80"/>
</Grid>
</Border>
<!-- 选项 -->
<Border Grid.Row="1" Classes="GroupBorder" Padding="4">
<Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="12">
<StackPanel Orientation="Horizontal" Spacing="12" VerticalAlignment="Center">
<CheckBox Content="{loc:Tr 'Log'}" IsChecked="{Binding ShowLog}"/>
<CheckBox Content="{loc:Tr 'Network'}" IsChecked="{Binding ShowSocketLog}"/>
<CheckBox Content="{loc:Tr 'Receive string'}" IsChecked="{Binding ShowReceiveString}"/>
<CheckBox Content="{loc:Tr 'Send'}" IsChecked="{Binding ShowSend}"/>
<CheckBox Content="{loc:Tr 'Receive'}" IsChecked="{Binding ShowReceive}"/>
<CheckBox Content="{loc:Tr 'Send HEX'}" IsChecked="{Binding HexSend}"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
<TextBlock Text="{loc:Tr 'Times'}" VerticalAlignment="Center"/>
<TextBox Text="{Binding SendTimes}" Width="64" Classes="ConfigTextBox"/>
<TextBlock Text="{loc:Tr 'Interval'}" VerticalAlignment="Center"/>
<TextBox Text="{Binding SendSleep}" Width="64" Classes="ConfigTextBox"/>
<TextBlock Text="{loc:Tr 'Concurrency'}" VerticalAlignment="Center"/>
<TextBox Text="{Binding SendThreads}" Width="64" Classes="ConfigTextBox"/>
</StackPanel>
</Grid>
</Border>
<!-- 日志 -->
<TextBox Classes="console" Grid.Row="2" Text="{Binding ReceiveLog}" AcceptsReturn="True" AcceptsTab="True"
FontFamily="{DynamicResource FontMono}" FontSize="12" Margin="0,4"
BorderThickness="1" BorderBrush="{DynamicResource BorderDefault}"/>
<!-- 发送 -->
<Border Grid.Row="3" Classes="GroupBorder">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Text="{Binding SendText}" Classes="ConfigTextBox"/>
<Button Grid.Column="1" Content="{loc:Tr 'Send'}" Command="{Binding SendCommand}" Classes="ActionButton" Width="80"/>
<Button Grid.Column="2" Content="{loc:Tr 'Clear'}" Command="{Binding ClearLogCommand}" Classes="ActionButton" Width="60"/>
</Grid>
</Border>
</Grid>
</Window>
|