<Page x:Class="头罩视野.Views.PageTest"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:hc="https://handyorg.github.io/handycontrol"
      xmlns:local="clr-namespace:头罩视野.Views"
      mc:Ignorable="d" 
      Background="#F5F7FA"
      d:DesignHeight="768" d:DesignWidth="1024"
      Title="PageTest" Loaded="Page_Loaded" Unloaded="Page_Unloaded" >
    <Page.Resources>
        <!-- 标题样式 -->
        <Style x:Key="MainTitleStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="28"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Foreground" Value="#2C3E50"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0,15,0,15"/>
        </Style>
        <Style x:Key="LabelStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="16"/>
            <Setter Property="Foreground" Value="#5D6D7E"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0,0,10,0"/>
            <Setter Property="Margin" Value="0,0,10,0"/>
            <Setter Property="Width" Value="115"/>
        </Style>

        <Style x:Key="UnitStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Foreground" Value="#7F8C8D"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="10,0,0,0"/>
            <Setter Property="FontStyle" Value="Italic"/>
        </Style>

        <Style x:Key="TextBoxStyle" TargetType="TextBox">
            <Setter Property="Height" Value="35"/>
            <Setter Property="Width" Value="200"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="BorderBrush" Value="#D5D8DC"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Background" Value="#FFFFFF"/>
            <Setter Property="Foreground" Value="#2C3E50"/>
            <Setter Property="Padding" Value="10,5"/>
            <Style.Triggers>
                <Trigger Property="IsFocused" Value="True">
                    <Setter Property="BorderBrush" Value="#3498DB"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="TabButtonStyle" TargetType="Button">
            <Setter Property="Background" Value="#3498DB"/>
            <Setter Property="FontSize" Value="20"/>
            <Setter Property="Foreground" Value="#fff"/>
            <Setter Property="Height" Value="70"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="BorderBrush" Value="#fff"/>
        </Style>
        <!--<Style x:Key="ActButtonStyle" TargetType="Button">
            <Setter Property="Background" Value="#8AB1EB"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Foreground" Value="#fff"/>
            <Setter Property="Height" Value="60"/>
            <Setter Property="Width" Value="120"/>
        </Style>-->

    </Page.Resources>
    <Grid Margin="10,0,0,0 ">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" MinHeight="227"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- 顶部标题栏 -->
        <Grid Grid.Row="0" Margin="0,0,0,10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <!--<ColumnDefinition Width="Auto"/>-->
            </Grid.ColumnDefinitions>
            <!-- 测试界面标题 -->
            <TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="测试界面" 
           HorizontalAlignment="Center" VerticalAlignment="Center"/>


        </Grid>

        <!-- 第二行：参数显示区 -->
        <Grid Grid.Row="1" Margin="0,0,0,10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <!--<ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>-->
            </Grid.ColumnDefinitions>
            <Border Grid.Row="0"   Background="#FFFFFF" CornerRadius="10" 
                        BorderBrush="#E5E8E8" BorderThickness="1" 
                        Padding="25,20" Margin="0,0,0,25"  >
                <StackPanel Cursor="" Grid.Column="0">
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
                        <TextBlock Text="分辨角度：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="fbspeed"  Text="" Style="{StaticResource TextBoxStyle}" GotFocus="fbspeed_GotFocus"/>
                        <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="当前角度：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="dqangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="dqangle_GotFocus"/>
                        <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <TextBlock Text="转动速度：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="zdangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="zdangle_GotFocus"/>
                        <TextBlock Text="°/S" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>
                </StackPanel>
            </Border>
            <Button Grid.Column="2" Content="打印" Margin="356,11,0,0" VerticalAlignment="Top" Height="42" Width="75" Click="Button_Click_Print" FontSize="18" RenderTransformOrigin="0.330,-0.63" HorizontalAlignment="Left"/>
            <ToggleButton x:Name="tbTest" 
              FontSize="18" 
              Width="111" Height="40"
              Background="LightGray"
              Checked="TbTest_Checked"      
                Unchecked="TbTest_Unchecked" Grid.Column="1" HorizontalAlignment="Left" Margin="131,8,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2">
                <!-- 关键：用Style去掉边框 -->
                <ToggleButton.Template>
                    <ControlTemplate TargetType="ToggleButton">
                        <!-- 自定义外观，去掉所有默认hover效果 -->
                        <Border x:Name="border"
                    CornerRadius="3"
                    Background="{TemplateBinding Background}"
                    BorderThickness="0">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <!-- 去掉默认的hover/点击效果触发器 -->
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="border" Property="Background" Value="LightGray"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </ToggleButton.Template>

                空白测试
            </ToggleButton>
            <TextBlock x:Name="当前模式" Grid.Column="1" HorizontalAlignment="Left" Margin="39,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-6.776,-2.381" Width="116"><Run Text="当前模式"/><Run Language="zh-cn" Text="："/></TextBlock>
            <StackPanel Grid.Column="2"  Orientation="Horizontal" HorizontalAlignment="Left" Margin="121,48,0,53" Width="181">
                <!-- 左灯：BL_0 (M-104) -->
                <Ellipse x:Name="led0" 
             Width="50" Height="50" 
             Margin="10"
             Fill="LightGray"
             Stroke="LightGray" StrokeThickness="1" >
                    <Ellipse.Effect>
                        <DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
                    </Ellipse.Effect>
                </Ellipse>

                <!-- 右灯：BL_1 (M-105) -->
                <Ellipse x:Name="led1" 
             Width="50" Height="50" 
             Margin="30"
             Fill="LightGray"
             Stroke="LightGray" StrokeThickness="1">
                    <Ellipse.Effect>
                        <DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
                    </Ellipse.Effect>
                </Ellipse>
            </StackPanel>
        </Grid>

        <!-- 第三行：视野数据区 -->
        <Grid Grid.Row="1" Margin="-2,200,2,41" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <!--<ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>-->
            </Grid.ColumnDefinitions>
            <Border Grid.Row="0" Grid.Column="0" Background="#FFFFFF" CornerRadius="10" 
                BorderBrush="#E5E8E8" BorderThickness="1" 
                Padding="25,20" Margin="0,0,447,-32" Grid.ColumnSpan="2"  >
                <StackPanel Cursor="">
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
                        <TextBlock Text="左目视野面积：" Style="{StaticResource LabelStyle}"  />
                        <TextBox Name="zmsyarea"  Text="" Style="{StaticResource TextBoxStyle}"   />
                        <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="双目视野面积：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="smsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <TextBlock Text="空白视野面积：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="kbsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <TextBlock Text="总视野面积：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="zsyareaNum" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                </StackPanel>
            </Border>

            <Border Grid.Column="1" Background="#FFFFFF" CornerRadius="10" 
     BorderBrush="#E5E8E8" BorderThickness="1" 
     Padding="25,20" Margin="422,0,19,-32"  >
                <StackPanel Cursor="">
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
                        <TextBlock Text="右目视野面积：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="ymsyarea"  Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="下方视野：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="xfsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <TextBlock Text="双目视野保存率：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="sybhl" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="%" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                        <TextBlock Text="总视野保存率：" Style="{StaticResource LabelStyle}"/>
                        <TextBox Name="zsysaveSum" Text="" Style="{StaticResource TextBoxStyle}"/>
                        <TextBlock Text="%" Style="{StaticResource UnitStyle}"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </Grid>

        <!-- 第四行：控制按钮区 -->
        <Grid Grid.Row="3" Margin="0,10,0,25">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!-- 复位 -->
            <Button Grid.Row="0"  Grid.Column="0" Grid.RowSpan="2" Content="复位" FontSize="18"
                    Width="120" Height="40" Background="#FF87CEFA"  Foreground="White"  Margin="5"  Click="Button_Click_Reset" />

            <!-- 左眼开 -->
            <Button Grid.Row="0" Name="btnLeft"  Grid.Column="1" Content="左眼开" FontSize="18"
                    Width="120" Height="40" Background="#FF87CEFA"  Foreground="White"   Margin="5"  Click="Button_Click_left" />

            <!-- 反转 -->
            <Button Grid.Row="0" Grid.Column="2" Content="反转" FontSize="18"
                    Width="120" Height="40" Background="#FF87CEFA"  Foreground="White"   Margin="5"  PreviewMouseLeftButtonDown="Button_Click_ResDown" 
    PreviewMouseLeftButtonUp="Button_Click_ResUp" />

            <!-- 右眼开 -->
            <Button Grid.Row="1" Name="btnRight" Grid.Column="1" Content="右眼开" FontSize="18"
                    Width="120" Height="40" Background="#FF87CEFA"  Foreground="White"   Margin="5"  Click="Button_Click_Right" />

            <!-- 正转 -->
            <Button Grid.Row="1" Grid.Column="2" Content="正转" FontSize="18"
                    Width="120" Height="40" Background="#FF87CEFA"  Foreground="White"   Margin="5"  PreviewMouseLeftButtonDown="Button_Click_ForDown" 
PreviewMouseLeftButtonUp="Button_Click_ForUp" />
            <!-- 测试 -->
            <Button Grid.Row="0" Grid.Column="4" Name="ButtonTest" Grid.RowSpan="2" Content="测试" FontSize="18"
                    Width="120" Height="40" Background="LightGray"  Foreground="White"   Margin="5" Click="Button_Click_Test"/>

            <!-- 停止 -->
            <Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Content="停止" FontSize="18"
                    Width="120" Height="40" Background="red"  Foreground="White"  Margin="5" Click="Button_Click_Stop" />
        </Grid>

        <!-- 底部导航栏 -->
        <Grid Grid.Row="4" Margin="0,0,0,10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <!--<ColumnDefinition Width="*"/>-->
            </Grid.ColumnDefinitions>
            <Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页" 
           Click="GoHome" />
            <Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
          Click="GoTest" />
            <!--<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
          Click="GoRecord" />-->
            <Button Style="{StaticResource TabButtonStyle}"  Grid.Column="2" Content="记录画面" 
        Click="GoView" />
        </Grid>
    </Grid>
</Page>
