<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"
xmlns:controls="clr-namespace:NewLife.XCoder.Controls"
mc:Ignorable="d" d:DesignWidth="1100" d:DesignHeight="750"
x:Class="NewLife.XCoder.Views.NetworkWindow"
x:DataType="vm:NetworkViewModel"
Title="{loc:Tr 'Network Debugger'}" Width="1100" Height="750"
WindowStartupLocation="CenterOwner">
<Window.Styles>
<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>
<Style Selector="TextBlock.SectionTitle">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="4,3"/>
<Setter Property="FontSize" Value="13"/>
</Style>
<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="Button.SendButton">
<Setter Property="Height" Value="50"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style Selector="TextBox.SmallNumeric">
<Setter Property="Width" Value="60"/>
<Setter Property="Height" Value="26"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Right"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
<Setter Property="Margin" Value="2"/>
</Style>
</Window.Styles>
<Grid Margin="16" RowSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- ============ 左侧:配置面板 ============ -->
<ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" Margin="0,0,4,0">
<StackPanel>
<!-- 工作模式 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Work mode'}" Classes="SectionTitle"/>
<ComboBox ItemsSource="{Binding Modes}" SelectedIndex="{Binding SelectedModeIndex}"
Margin="4,2" Height="32"/>
</StackPanel>
</Border>
<!-- 连接配置 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Connection settings'}" Classes="SectionTitle"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{loc:Tr 'Local'}" VerticalAlignment="Center" Margin="4,2"/>
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding LocalAddresses}"
SelectedItem="{Binding LocalAddress}" Margin="2"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{loc:Tr 'Remote'}" VerticalAlignment="Center" Margin="4,2"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding RemoteAddress}" Classes="ConfigTextBox"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{loc:Tr 'Port'}" VerticalAlignment="Center" Margin="4,2"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Port}" Classes="ConfigTextBox"/>
</Grid>
<Button Content="{Binding ConnectButtonText}" Command="{Binding ToggleConnectCommand}"
Classes="ActionButton" Margin="4,4"/>
</StackPanel>
</Border>
<!-- 日志选项 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Log options'}" Classes="SectionTitle"/>
<CheckBox Content="{loc:Tr 'Business log'}" IsChecked="{Binding ShowLog}" Margin="4,2"/>
<CheckBox Content="{loc:Tr 'Socket log'}" IsChecked="{Binding ShowSocketLog}" Margin="4,2"/>
<CheckBox Content="{loc:Tr 'Show sent'}" IsChecked="{Binding ShowSend}" Margin="4,2"/>
<CheckBox Content="{loc:Tr 'Show received'}" IsChecked="{Binding ShowReceive}" Margin="4,2"/>
<CheckBox Content="{loc:Tr 'Show statistics'}" IsChecked="{Binding ShowStat}" Margin="4,2"/>
<CheckBox Content="{loc:Tr 'Receive string'}" IsChecked="{Binding ShowReceiveString}" Margin="4,2"/>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
<!-- ============ 右侧:收发区 ============ -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 状态栏 -->
<Border Grid.Row="0" BorderBrush="{DynamicResource BorderDefault}" BorderThickness="0,0,0,1" Padding="4,2" Margin="0,0,0,4">
<TextBlock>
<Run Text="{loc:Tr 'Status:'}"/>
<Run Text="{Binding ConnectButtonText}"/>
<Run Text="{loc:Tr ' | Received:'}"/>
<Run Text="{Binding ReceivedBytes}"/>
<Run Text="{loc:Tr ' | Sent:'}"/>
<Run Text="{Binding SentBytes}"/>
<Run Text="{loc:Tr ' | Session:'}"/>
<Run Text="{Binding SessionCount}"/>
</TextBlock>
</Border>
<!-- 发送区 -->
<Border Grid.Row="1" Classes="GroupBorder">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding SendText}" AcceptsReturn="True"
MinHeight="60" FontFamily="{DynamicResource FontMono}" Margin="2"/>
<Button Grid.Column="1" Content="{loc:Tr 'Send'}" Command="{Binding SendCommand}"
Classes="SendButton" Width="100" VerticalAlignment="Top" Margin="2"/>
<StackPanel Grid.Column="2" Margin="4,0">
<CheckBox Content="{loc:Tr 'Send HEX'}" IsChecked="{Binding HexSend}" Margin="2"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{loc:Tr 'Times'}" VerticalAlignment="Center" Margin="2,0"/>
<TextBox Text="{Binding SendTimes}" Classes="SmallNumeric"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{loc:Tr 'Interval'}" VerticalAlignment="Center" Margin="2,0"/>
<TextBox Text="{Binding SendSleep}" Classes="SmallNumeric"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{loc:Tr 'Threads'}" VerticalAlignment="Center" Margin="2,0"/>
<TextBox Text="{Binding SendThreads}" Classes="SmallNumeric"/>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</Border>
<!-- 日志区 -->
<Border Grid.Row="3" Classes="GroupBorder">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{loc:Tr 'Log'}" FontWeight="Bold" Margin="4,2"/>
<Button Grid.Column="1" Content="{loc:Tr 'Clear'}" Command="{Binding ClearReceiveLogCommand}"
Height="32" Margin="2" Padding="8,0"/>
</Grid>
<controls:LogView Grid.Row="2" Entries="{Binding LogEntries}" Margin="2"/>
</Grid>
</Border>
</Grid>
</Grid>
</Window>
|