You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1038 lines
74 KiB

<reactive:ReactiveUserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactive="using:ReactiveUI.Avalonia"
xmlns:heroicons="clr-namespace:HeroIconsAvalonia.Controls;assembly=HeroIconsAvalonia"
xmlns:converters="using:AuroraDesk.Presentation.Converters"
xmlns:vm="using:AuroraDesk.Presentation.ViewModels.Pages"
mc:Ignorable="d"
d:DesignWidth="1200"
d:DesignHeight="800"
x:Class="AuroraDesk.Presentation.Views.Pages.TcpClientPageView"
x:DataType="vm:TcpClientPageViewModel">
<reactive:ReactiveUserControl.Resources>
<converters:InvertedBoolConverter x:Key="InvertedBoolConverter"/>
<converters:NullToBoolConverter x:Key="NullToBoolConverter"/>
<converters:NullToInverseBoolConverter x:Key="NullToInverseBoolConverter"/>
</reactive:ReactiveUserControl.Resources>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 顶部统计卡片 -->
<Grid Grid.Row="0"
ColumnDefinitions="*,*,*,*"
ColumnSpacing="12"
Margin="0,0,0,16">
<!-- 全局状态 -->
<Border Grid.Column="0"
Background="#6366F1"
CornerRadius="12"
Padding="20">
<StackPanel>
<heroicons:HeroIcon Type="GlobeAlt"
Width="28"
Height="28"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,0,0,8"/>
<TextBlock Text="{Binding GlobalStatusMessage}"
FontSize="13"
FontWeight="SemiBold"
Foreground="White"
TextAlignment="Center"
TextWrapping="Wrap"
Margin="0,0,0,6"/>
<Border Background="White"
CornerRadius="12"
Padding="6,3"
HorizontalAlignment="Center">
<TextBlock Text="TCP 客户端"
FontSize="10"
FontWeight="Bold"
Foreground="#6366F1"/>
</Border>
</StackPanel>
</Border>
<!-- 会话总数 -->
<Border Grid.Column="1"
Background="#2563EB"
CornerRadius="12"
Padding="20">
<StackPanel>
<heroicons:HeroIcon Type="UserGroup"
Width="28"
Height="28"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,0,0,8"/>
<TextBlock Text="{Binding Sessions.Count}"
FontSize="28"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"/>
<TextBlock Text="总会话"
FontSize="12"
Foreground="White"
HorizontalAlignment="Center"
Opacity="0.9"
Margin="0,4,0,0"/>
</StackPanel>
</Border>
<!-- 活动连接 -->
<Border Grid.Column="2"
Background="#22C55E"
CornerRadius="12"
Padding="20">
<StackPanel>
<heroicons:HeroIcon Type="Link"
Width="28"
Height="28"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,0,0,8"/>
<TextBlock Text="{Binding ActiveSessionCount}"
FontSize="28"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"/>
<TextBlock Text="活动连接"
FontSize="12"
Foreground="White"
HorizontalAlignment="Center"
Opacity="0.9"
Margin="0,4,0,0"/>
</StackPanel>
</Border>
<!-- 消息统计 -->
<Border Grid.Column="3"
Background="#F97316"
CornerRadius="12"
Padding="20">
<StackPanel>
<heroicons:HeroIcon Type="Envelope"
Width="28"
Height="28"
Foreground="White"
HorizontalAlignment="Center"
Margin="0,0,0,8"/>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
Spacing="12">
<StackPanel>
<TextBlock Text="{Binding TotalSentMessages}"
FontSize="24"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"/>
<TextBlock Text="发送"
FontSize="11"
Foreground="White"
HorizontalAlignment="Center"
Opacity="0.9"/>
</StackPanel>
<Border Width="1"
Background="#FFFFFF33"/>
<StackPanel>
<TextBlock Text="{Binding TotalReceivedMessages}"
FontSize="24"
FontWeight="Bold"
Foreground="White"
HorizontalAlignment="Center"/>
<TextBlock Text="接收"
FontSize="11"
Foreground="White"
HorizontalAlignment="Center"
Opacity="0.9"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</Grid>
<!-- 主要内容 -->
<Grid Grid.Row="1"
ColumnDefinitions="320,16,*">
<!-- 会话列表 -->
<Border Grid.Column="0"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="0">
<Grid RowDefinitions="Auto,*">
<Border Grid.Row="0"
Background="#F9FAFB"
BorderBrush="#E5E7EB"
BorderThickness="0,0,0,1"
CornerRadius="10,10,0,0"
Padding="16,12">
<Grid ColumnDefinitions="*,Auto,Auto"
ColumnSpacing="8">
<StackPanel Orientation="Horizontal"
Spacing="8"
VerticalAlignment="Center">
<heroicons:HeroIcon Type="RectangleGroup"
Width="18"
Height="18"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<TextBlock Text="会话列表"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<Border Background="#2563EB"
CornerRadius="8"
Padding="4,2"
VerticalAlignment="Center">
<TextBlock Text="{Binding Sessions.Count}"
FontSize="10"
FontWeight="Bold"
Foreground="White"/>
</Border>
</StackPanel>
<Button Grid.Column="1"
Command="{Binding AddSessionCommand}"
Background="#2563EB"
Foreground="White"
BorderThickness="0"
CornerRadius="6"
Padding="12,6"
FontSize="12"
Cursor="Hand">
<StackPanel Orientation="Horizontal"
Spacing="4"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="Plus"
Width="14"
Height="14"
Foreground="White"
VerticalAlignment="Center"/>
<TextBlock Text="新建"
FontSize="12"
FontWeight="SemiBold"
Foreground="White"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#1D4ED8"/>
</Style>
</Button.Styles>
</Button>
<Button Grid.Column="2"
Command="{Binding RemoveSessionCommand}"
CommandParameter="{Binding SelectedSession}"
Background="Transparent"
Foreground="#6B7280"
BorderThickness="1"
BorderBrush="#D1D5DB"
CornerRadius="6"
Padding="12,6"
FontSize="12"
Cursor="Hand"
IsEnabled="{Binding SelectedSession, Converter={StaticResource NullToBoolConverter}}">
<StackPanel Orientation="Horizontal"
Spacing="4"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="Minus"
Width="14"
Height="14"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<TextBlock Text="移除"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#F3F4F6"/>
<Setter Property="Foreground" Value="#1F2937"/>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Foreground" Value="#9CA3AF"/>
<Setter Property="BorderBrush" Value="#E5E7EB"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</Border>
<ScrollViewer Grid.Row="1"
Margin="0"
VerticalScrollBarVisibility="Auto">
<ListBox ItemsSource="{Binding Sessions}"
SelectedItem="{Binding SelectedSession}"
BorderThickness="0"
Background="Transparent"
Padding="0"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Margin" Value="12,8,12,0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:pointerover">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:selected">
<Setter Property="Background" Value="Transparent"/>
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate x:DataType="vm:TcpClientSessionViewModel">
<Border Background="#EFF6FF"
BorderBrush="#DBEAFE"
BorderThickness="1"
CornerRadius="10"
Padding="14"
HorizontalAlignment="Stretch">
<Grid RowDefinitions="Auto,Auto,Auto"
RowSpacing="6">
<Grid Grid.Row="0"
ColumnDefinitions="*,Auto"
ColumnSpacing="8">
<StackPanel Orientation="Horizontal"
Spacing="8">
<heroicons:HeroIcon Type="ComputerDesktop"
Width="18"
Height="18"
Foreground="#1D4ED8"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding SessionName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
</StackPanel>
<Grid Grid.Column="1">
<Border Background="#22C55E"
CornerRadius="10"
Padding="6,2"
IsVisible="{Binding IsConnected}">
<TextBlock Text="已连接"
Foreground="White"
FontSize="11"
FontWeight="Bold"
HorizontalAlignment="Center"/>
</Border>
<Border Background="#DC2626"
CornerRadius="10"
Padding="6,2"
IsVisible="{Binding IsConnected, Converter={StaticResource InvertedBoolConverter}}">
<TextBlock Text="未连接"
Foreground="White"
FontSize="11"
FontWeight="Bold"
HorizontalAlignment="Center"/>
</Border>
</Grid>
</Grid>
<TextBlock Grid.Row="1"
Text="{Binding StatusMessage}"
FontSize="12"
Foreground="#4B5563"
TextWrapping="Wrap"/>
<Grid Grid.Row="2"
ColumnDefinitions="Auto,Auto,Auto"
ColumnSpacing="12">
<StackPanel Orientation="Horizontal"
Spacing="4">
<heroicons:HeroIcon Type="PresentationChartLine"
Width="14"
Height="14"
Foreground="#1D4ED8"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding ServerIp}"
FontSize="11"
Foreground="#1F2937"/>
<TextBlock Text=":"
FontSize="11"
Foreground="#1F2937"/>
<TextBlock Text="{Binding ServerPort}"
FontSize="11"
Foreground="#1F2937"/>
</StackPanel>
<StackPanel Grid.Column="1"
Orientation="Horizontal"
Spacing="4">
<heroicons:HeroIcon Type="ArrowUpTray"
Width="14"
Height="14"
Foreground="#1D4ED8"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding SentMessages.Count}"
FontSize="11"
Foreground="#1F2937"/>
<TextBlock Text="发送"
FontSize="11"
Foreground="#6B7280"/>
</StackPanel>
<StackPanel Grid.Column="2"
Orientation="Horizontal"
Spacing="4">
<heroicons:HeroIcon Type="ArrowDownTray"
Width="14"
Height="14"
Foreground="#1D4ED8"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding ReceivedMessages.Count}"
FontSize="11"
Foreground="#1F2937"/>
<TextBlock Text="接收"
FontSize="11"
Foreground="#6B7280"/>
</StackPanel>
</Grid>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
</Border>
<!-- 会话详情 -->
<Border Grid.Column="2"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="0">
<Grid RowDefinitions="Auto,*">
<Border Grid.Row="0"
Background="#F9FAFB"
BorderBrush="#E5E7EB"
BorderThickness="0,0,0,1"
CornerRadius="10,10,0,0"
Padding="16,12">
<Grid ColumnDefinitions="*,Auto"
ColumnSpacing="12">
<StackPanel Orientation="Horizontal"
Spacing="8"
VerticalAlignment="Center">
<heroicons:HeroIcon Type="CpuChip"
Width="18"
Height="18"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<TextBlock Text="会话详情"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<Border Background="#1F2937"
CornerRadius="8"
Padding="4,2"
VerticalAlignment="Center">
<TextBlock Text="{Binding SelectedSession.SessionName, TargetNullValue='未选择'}"
FontSize="10"
FontWeight="Bold"
Foreground="White"/>
</Border>
</StackPanel>
<StackPanel Grid.Column="1"
Orientation="Horizontal"
Spacing="8"
VerticalAlignment="Center">
<Button Command="{Binding SelectedSession.ReconnectCommand, TargetNullValue={x:Null}}"
Background="#0EA5E9"
Foreground="White"
BorderThickness="0"
CornerRadius="6"
Padding="12,6"
FontSize="12"
Cursor="Hand"
IsVisible="{Binding SelectedSession, Converter={StaticResource NullToBoolConverter}}">
<StackPanel Orientation="Horizontal"
Spacing="4"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="ArrowPath"
Width="14"
Height="14"
Foreground="White"
VerticalAlignment="Center"/>
<TextBlock Text="重连"
FontSize="12"
FontWeight="SemiBold"
Foreground="White"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#0284C7"/>
</Style>
</Button.Styles>
</Button>
</StackPanel>
</Grid>
</Border>
<Grid Grid.Row="1">
<Grid>
<TextBlock Text="请选择或创建一个 TCP 会话以查看详情"
FontSize="13"
Foreground="#6B7280"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="{Binding SelectedSession, Converter={StaticResource NullToInverseBoolConverter}}"/>
</Grid>
<ContentControl x:Name="SessionDetailContent"
Content="{Binding SelectedSession}"
IsVisible="{Binding SelectedSession, Converter={StaticResource NullToBoolConverter}}">
<ContentControl.ContentTemplate>
<DataTemplate x:DataType="vm:TcpClientSessionViewModel">
<ScrollViewer HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<Grid RowDefinitions="Auto,*,Auto"
RowSpacing="16"
Margin="16">
<!-- 连接配置 -->
<Border Grid.Row="0"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="0">
<Expander Header="连接配置"
IsExpanded="True"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch">
<Expander.HeaderTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal"
Spacing="8"
Margin="16,12">
<heroicons:HeroIcon Type="Cog6Tooth"
Width="18"
Height="18"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<TextBlock Text="连接配置"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</DataTemplate>
</Expander.HeaderTemplate>
<Grid Margin="16,0,16,16"
ColumnDefinitions="Auto,220,Auto,200,Auto,160,Auto,*"
RowDefinitions="Auto,Auto"
ColumnSpacing="12"
RowSpacing="12">
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="会话名称"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<TextBox Grid.Row="0"
Grid.Column="1"
Text="{Binding SessionName}"
FontSize="12"
Padding="8,6"
CornerRadius="6"
BorderBrush="#D1D5DB"
Background="#FAFAFA"/>
<TextBlock Grid.Row="0"
Grid.Column="2"
Text="服务器 IP"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<TextBox Grid.Row="0"
Grid.Column="3"
Text="{Binding ServerIp}"
Watermark="127.0.0.1"
FontSize="12"
Padding="8,6"
CornerRadius="6"
BorderBrush="#D1D5DB"
Background="#FAFAFA"/>
<TextBlock Grid.Row="0"
Grid.Column="4"
Text="端口"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<NumericUpDown Grid.Row="0"
Grid.Column="5"
Value="{Binding ServerPort}"
Minimum="1"
Maximum="65535"
FontSize="12"
Padding="8,6"
CornerRadius="6"
BorderBrush="#D1D5DB"
Background="#FAFAFA"/>
<TextBlock Grid.Row="0"
Grid.Column="6"
Text="帧类型"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<NumericUpDown Grid.Row="0"
Grid.Column="7"
Value="{Binding FrameType}"
Minimum="0"
Maximum="32767"
Increment="1"
FontSize="12"
Padding="8,6"
CornerRadius="6"
BorderBrush="#D1D5DB"
Background="#FAFAFA"/>
<TextBlock Grid.Row="1"
Grid.Column="0"
Text="本地端口"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<Border Grid.Row="1"
Grid.Column="1"
Background="#F3F4F6"
CornerRadius="6"
Padding="8,6"
HorizontalAlignment="Stretch">
<TextBlock Text="{Binding LocalPort}"
FontSize="12"
Foreground="#1F2937"
HorizontalAlignment="Center"
TextAlignment="Center"/>
</Border>
<TextBlock Grid.Row="1"
Grid.Column="2"
Text="最新状态"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<Border Grid.Row="1"
Grid.Column="3"
Background="#F3F4F6"
CornerRadius="6"
Padding="8,6"
HorizontalAlignment="Stretch">
<TextBlock Text="{Binding StatusMessage}"
FontSize="12"
Foreground="#1F2937"
TextWrapping="Wrap"/>
</Border>
<CheckBox Grid.Row="1"
Grid.Column="4"
Grid.ColumnSpan="2"
Content="启用 CRC 校验并附加 4 字节"
IsChecked="{Binding EnableCrc}"
FontSize="12"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<StackPanel Grid.Row="1"
Grid.Column="6"
Grid.ColumnSpan="2"
Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="8">
<Button Command="{Binding ConnectCommand}"
Background="#2563EB"
Foreground="White"
BorderThickness="0"
CornerRadius="8"
Padding="20,9"
FontSize="13"
FontWeight="SemiBold"
Cursor="Hand"
IsEnabled="{Binding IsConnected, Converter={StaticResource InvertedBoolConverter}}">
<StackPanel Orientation="Horizontal"
Spacing="6"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="CheckCircle"
Width="16"
Height="16"
Foreground="White"
VerticalAlignment="Center"/>
<TextBlock Text="连接"
FontSize="13"
FontWeight="SemiBold"
Foreground="White"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#1D4ED8"/>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Background" Value="#E5E7EB"/>
<Setter Property="Foreground" Value="#9CA3AF"/>
</Style>
</Button.Styles>
</Button>
<Button Command="{Binding DisconnectCommand}"
Background="#DC2626"
Foreground="White"
BorderThickness="0"
CornerRadius="8"
Padding="20,9"
FontSize="13"
FontWeight="SemiBold"
Cursor="Hand"
IsEnabled="{Binding IsConnected}">
<StackPanel Orientation="Horizontal"
Spacing="6"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="XCircle"
Width="16"
Height="16"
Foreground="White"
VerticalAlignment="Center"/>
<TextBlock Text="断开"
FontSize="13"
FontWeight="SemiBold"
Foreground="White"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#B91C1C"/>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Background" Value="#E5E7EB"/>
<Setter Property="Foreground" Value="#9CA3AF"/>
</Style>
</Button.Styles>
</Button>
</StackPanel>
</Grid>
</Expander>
</Border>
<!-- 消息区域 -->
<Grid Grid.Row="1"
ColumnDefinitions="*,2*"
ColumnSpacing="16">
<!-- 已发送消息 -->
<Border Grid.Column="0"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="0">
<Grid RowDefinitions="Auto,*">
<Border Grid.Row="0"
Background="#F9FAFB"
BorderBrush="#E5E7EB"
BorderThickness="0,0,0,1"
CornerRadius="10,10,0,0"
Padding="16,12">
<Grid>
<StackPanel Orientation="Horizontal"
Spacing="8">
<heroicons:HeroIcon Type="ArrowUpTray"
Width="18"
Height="18"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<TextBlock Text="已发送消息"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<Border Background="#2563EB"
CornerRadius="8"
Padding="4,2"
VerticalAlignment="Center">
<TextBlock Text="{Binding SentMessages.Count}"
FontSize="10"
FontWeight="Bold"
Foreground="White"/>
</Border>
</StackPanel>
<Button Command="{Binding ClearMessagesCommand}"
HorizontalAlignment="Right"
Background="Transparent"
Foreground="#6B7280"
BorderThickness="0"
CornerRadius="6"
Padding="8,4"
FontSize="12"
Cursor="Hand">
<StackPanel Orientation="Horizontal"
Spacing="4">
<heroicons:HeroIcon Type="Trash"
Width="14"
Height="14"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<TextBlock Text="清空"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#F3F4F6"/>
<Setter Property="Foreground" Value="#1F2937"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</Border>
<ScrollViewer Grid.Row="1"
Margin="16"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding SentMessages}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="#FAFAFA"
Padding="14,10"
Margin="0,0,0,1"
BorderBrush="#E5E7EB"
BorderThickness="0,0,0,1">
<TextBlock Text="{Binding}"
TextWrapping="Wrap"
FontSize="12"
Foreground="#1F2937"
LineHeight="18"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
<!-- 接收消息 -->
<Border Grid.Column="1"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="0">
<Grid RowDefinitions="Auto,*">
<Border Grid.Row="0"
Background="#F9FAFB"
BorderBrush="#E5E7EB"
BorderThickness="0,0,0,1"
CornerRadius="10,10,0,0"
Padding="16,12">
<Grid ColumnDefinitions="*,Auto,Auto"
ColumnSpacing="8">
<StackPanel Orientation="Horizontal"
Spacing="8">
<heroicons:HeroIcon Type="ArrowDownTray"
Width="18"
Height="18"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<TextBlock Text="接收消息"
FontSize="14"
FontWeight="SemiBold"
Foreground="#1F2937"
VerticalAlignment="Center"/>
<Border Background="#F97316"
CornerRadius="8"
Padding="4,2"
VerticalAlignment="Center">
<TextBlock Text="{Binding ReceivedMessages.Count}"
FontSize="10"
FontWeight="Bold"
Foreground="White"/>
</Border>
</StackPanel>
<CheckBox Grid.Column="1"
Content="自动置底"
IsChecked="{Binding IsAutoScrollToBottom}"
VerticalAlignment="Center"
FontSize="12"
Foreground="#1F2937"
Margin="12,0"/>
<Button Grid.Column="2"
Command="{Binding ClearMessagesCommand}"
Background="Transparent"
Foreground="#6B7280"
BorderThickness="0"
CornerRadius="6"
Padding="8,4"
FontSize="12"
Cursor="Hand">
<StackPanel Orientation="Horizontal"
Spacing="4">
<heroicons:HeroIcon Type="Trash"
Width="14"
Height="14"
Foreground="#6B7280"
VerticalAlignment="Center"/>
<TextBlock Text="清空"
FontSize="12"
Foreground="#6B7280"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#F3F4F6"/>
<Setter Property="Foreground" Value="#1F2937"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</Border>
<ListBox Grid.Row="1"
x:Name="SessionReceivedMessagesListBox"
ItemsSource="{Binding ReceivedMessages}"
BorderThickness="0"
Background="Transparent"
Padding="0"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="FocusAdorner" Value="{x:Null}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:pointerover">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="ListBoxItem:selected">
<Setter Property="Background" Value="Transparent"/>
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Background="#FEF3C7"
Padding="14,10"
Margin="0,0,0,1"
BorderBrush="#FCD34D"
BorderThickness="0,0,0,1">
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="12">
<Border Background="#FDE68A"
CornerRadius="6"
Padding="8,3"
VerticalAlignment="Top">
<TextBlock Text="{Binding Index}"
FontSize="12"
FontWeight="Bold"
Foreground="#92400E"/>
</Border>
<TextBlock Grid.Column="1"
Text="{Binding DisplayText}"
TextWrapping="Wrap"
FontSize="12"
Foreground="#1F2937"
LineHeight="18"/>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</Grid>
<Border Grid.Row="2"
Background="White"
BorderBrush="#E5E7EB"
BorderThickness="1"
CornerRadius="10"
Padding="16">
<Grid ColumnDefinitions="*,Auto"
ColumnSpacing="12">
<TextBox Grid.Column="0"
Text="{Binding Message}"
Watermark="输入消息..."
AcceptsReturn="True"
TextWrapping="Wrap"
MinHeight="60"
FontSize="12"
Padding="10,8"
CornerRadius="8"
BorderBrush="#D1D5DB"
Background="#FAFAFA"/>
<Button Grid.Column="1"
Command="{Binding SendMessageCommand}"
Background="#22C55E"
Foreground="White"
BorderThickness="0"
CornerRadius="8"
Padding="20,12"
FontSize="13"
FontWeight="SemiBold"
MinWidth="100"
Cursor="Hand"
IsEnabled="{Binding IsConnected}">
<StackPanel Orientation="Horizontal"
Spacing="6"
HorizontalAlignment="Center">
<heroicons:HeroIcon Type="PaperAirplane"
Width="16"
Height="16"
Foreground="White"
VerticalAlignment="Center"/>
<TextBlock Text="发送"
FontSize="13"
FontWeight="SemiBold"
Foreground="White"
VerticalAlignment="Center"/>
</StackPanel>
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="Background" Value="#16A34A"/>
</Style>
<Style Selector="Button:disabled">
<Setter Property="Background" Value="#E5E7EB"/>
<Setter Property="Foreground" Value="#9CA3AF"/>
</Style>
</Button.Styles>
</Button>
</Grid>
</Border>
</Grid>
</ScrollViewer>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</Grid>
</Grid>
</Border>
</Grid>
</Grid>
</reactive:ReactiveUserControl>