<Window x:Class="StandardScene.Fass2Simulator.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="FASS2 车体模拟器"
        Height="720"
        Width="1080"
        MinHeight="560"
        MinWidth="900"
        Background="White"
        WindowStartupLocation="CenterScreen">
    <Grid Margin="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0" Margin="0,0,0,12">
            <StackPanel DockPanel.Dock="Left" Orientation="Horizontal" VerticalAlignment="Center">
                <TextBlock Text="FASS2 车体模拟器" FontSize="22" FontWeight="SemiBold" Foreground="#111827"/>
                <Border Margin="16,0,0,0" Padding="10,4" CornerRadius="12" Background="#E5E7EB">
                    <TextBlock x:Name="RunStateText" Text="已停止" FontWeight="SemiBold" Foreground="#6B7280"/>
                </Border>
            </StackPanel>
            <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button x:Name="StartButton" Content="启动模拟" Width="110" Height="36" Margin="0,0,8,0"
                        Background="#2563EB" Foreground="White" BorderThickness="0" FontWeight="SemiBold" Click="StartButton_Click"/>
                <Button x:Name="StopButton" Content="停止" Width="90" Height="36" Margin="0,0,8,0"
                        IsEnabled="False" Click="StopButton_Click"/>
                <Button x:Name="ClearLogButton" Content="清空界面" Width="90" Height="36" Margin="0,0,8,0" Click="ClearLogButton_Click"/>
                <Button x:Name="OpenLogFolderButton" Content="打开日志目录" Width="110" Height="36" Click="OpenLogFolderButton_Click"/>
            </StackPanel>
        </DockPanel>

        <Grid Grid.Row="1" Margin="0,0,0,12">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="320"/>
                <ColumnDefinition Width="16"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Border Grid.Column="0" Background="{StaticResource PanelBrush}" BorderBrush="{StaticResource BorderBrush}"
                    BorderThickness="1" CornerRadius="8" Padding="14">
                <StackPanel>
                    <TextBlock Text="联调参数" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,12"/>
                    <TextBlock Text="车号" Margin="0,0,0,4"/>
                    <TextBox x:Name="VehicleCodeBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="车体监听地址" Margin="0,0,0,4"/>
                    <TextBox x:Name="ListenAddressBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="车体监听端口" Margin="0,0,0,4"/>
                    <TextBox x:Name="ListenPortBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="调度地址" Margin="0,0,0,4"/>
                    <TextBox x:Name="SchedulerHostBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="调度监听端口" Margin="0,0,0,4"/>
                    <TextBox x:Name="SchedulerPortBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="上报周期 (ms)" Margin="0,0,0,4"/>
                    <TextBox x:Name="ReportIntervalBox" Height="28" Margin="0,0,0,10"/>
                    <TextBlock Text="初始节点" Margin="0,0,0,4"/>
                    <TextBox x:Name="InitialNodeBox" Height="28" Margin="0,0,0,10"/>
                    <CheckBox x:Name="AutoContinueBox" Content="途经站自动续跑" Margin="0,0,0,6"/>
                    <CheckBox x:Name="AutoCompleteBox" Content="到站自动补全动作" Margin="0,0,0,6"/>
                    <CheckBox x:Name="LogRawFramesBox" Content="记录原始报文"/>
                </StackPanel>
            </Border>

            <Border Grid.Column="2" Background="{StaticResource PanelBrush}" BorderBrush="{StaticResource BorderBrush}"
                    BorderThickness="1" CornerRadius="8" Padding="14">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="车体状态" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,12"/>
                    <UniformGrid Grid.Row="1" Columns="4" Rows="4">
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="上报节点" Foreground="#6B7280"/><TextBlock x:Name="NodeText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="目标节点" Foreground="#6B7280"/><TextBlock x:Name="TargetNodeText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="行驶距离 (mm)" Foreground="#6B7280"/><TextBlock x:Name="DistanceText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="车体状态" Foreground="#6B7280"/><TextBlock x:Name="StateText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="任务号" Foreground="#6B7280"/><TextBlock x:Name="TaskText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="StartStop" Foreground="#6B7280"/><TextBlock x:Name="StartStopText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="Lift" Foreground="#6B7280"/><TextBlock x:Name="LiftText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="电量" Foreground="#6B7280"/><TextBlock x:Name="BatteryText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="待动作" Foreground="#6B7280"/><TextBlock x:Name="PendingText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="状态上报" Foreground="#6B7280"/><TextBlock x:Name="ReportsText" Text="0" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="收令次数" Foreground="#6B7280"/><TextBlock x:Name="CommandsText" Text="0" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="0x10 应答" Foreground="#6B7280"/><TextBlock x:Name="AckText" Text="0" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                        <StackPanel Margin="0,0,12,10"><TextBlock Text="最近应答" Foreground="#6B7280"/><TextBlock x:Name="LastAckText" Text="-" FontSize="18" FontWeight="SemiBold"/></StackPanel>
                    </UniformGrid>
                </Grid>
            </Border>
        </Grid>

        <Border Grid.Row="2" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" CornerRadius="8" Padding="10">
            <DockPanel>
                <StackPanel DockPanel.Dock="Top" Margin="0,0,0,8">
                    <TextBlock Text="运行日志（界面仅保留最近 800 行，完整日志写入本地文件）" FontSize="16" FontWeight="SemiBold"/>
                    <TextBlock x:Name="LogFilePathText" Text="日志文件: -" FontSize="12" Foreground="#6B7280" Margin="0,4,0,0" TextWrapping="Wrap"/>
                </StackPanel>
                <TextBox x:Name="LogTextBox"
                         IsReadOnly="True"
                         TextWrapping="NoWrap"
                         VerticalScrollBarVisibility="Auto"
                         HorizontalScrollBarVisibility="Auto"
                         FontFamily="Consolas"
                         FontSize="12"
                         Background="#FAFAFA"
                         BorderThickness="0"/>
            </DockPanel>
        </Border>
    </Grid>
</Window>
