<Window x:Class="NavisworksTransport.UI.WPF.Views.EditRotationWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:NavisworksTransport.UI.WPF.Converters"
        Title="调整物体" Height="430" Width="480"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize"
        ShowInTaskbar="False"
        Topmost="True"
        Background="White">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/TransportPlugin;component/src/UI/WPF/Resources/NavisworksStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <converters:EditableNumberConverter x:Key="EditableNumberConverter"/>
        </ResourceDictionary>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <!-- 标题栏 -->
        <Border Grid.Row="0" Background="#FFF8FBFF" BorderBrush="#FFD4E7FF" BorderThickness="0,0,0,1" Padding="20,15">
            <StackPanel>
                <TextBlock Text="调整物体" FontWeight="SemiBold" FontSize="14" Foreground="#FF2B579A"/>
            </StackPanel>
        </Border>
        
        <!-- 输入区域 -->
        <Border Grid.Row="1" Padding="20,15">
            <StackPanel>
                <!-- X轴 -->
                <Grid Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="50"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="绕 X 轴:" VerticalAlignment="Center" FontSize="11" Foreground="#FF333333"/>
                    <TextBox Grid.Column="1" 
                             x:Name="XAxisTextBox"
                             GotFocus="OnAxisTextBoxGotFocus"
                             Text="{Binding RotationXDegrees, Mode=TwoWay, UpdateSourceTrigger=Explicit, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.###, ValidatesOnExceptions=True, NotifyOnValidationError=True}" 
                             Height="28"
                             VerticalContentAlignment="Center"
                             Padding="8,0"
                             FontSize="11"
                             BorderBrush="#FFCCCCCC"
                             BorderThickness="1"/>
                    <TextBlock Grid.Column="2" Text="°" VerticalAlignment="Center" FontSize="11" Foreground="#FF666666" Margin="8,0,0,0"/>
                </Grid>

                <!-- Y轴 -->
                <Grid Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="50"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="绕 Y 轴:" VerticalAlignment="Center" FontSize="11" Foreground="#FF333333"/>
                    <TextBox Grid.Column="1"
                             x:Name="YAxisTextBox"
                             GotFocus="OnAxisTextBoxGotFocus"
                             Text="{Binding RotationYDegrees, Mode=TwoWay, UpdateSourceTrigger=Explicit, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                             Height="28"
                             VerticalContentAlignment="Center"
                             Padding="8,0"
                             FontSize="11"
                             BorderBrush="#FFCCCCCC"
                             BorderThickness="1"/>
                    <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Text="°" FontSize="11" Foreground="#FF666666" Margin="8,0,4,0" VerticalAlignment="Center"/>
                        <Button x:Name="YAxisRotateButton"
                                Click="OnYAxisRotateClick"
                                Style="{StaticResource IconButtonStyle}"
                                ToolTip="当前值增加 90°">
                            <Path Data="{StaticResource RotateIconGeometry}"
                                  Fill="{StaticResource NavisworksPrimaryBrush}"
                                  Width="16" Height="16" Stretch="Uniform"/>
                        </Button>
                    </StackPanel>
                </Grid>

                <!-- Z轴 -->
                <Grid Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="50"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="绕 Z 轴:" VerticalAlignment="Center" FontSize="11" Foreground="#FF333333"/>
                    <TextBox Grid.Column="1" 
                             x:Name="ZAxisTextBox"
                             GotFocus="OnAxisTextBoxGotFocus"
                             Text="{Binding RotationZDegrees, Mode=TwoWay, UpdateSourceTrigger=Explicit, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.###, ValidatesOnExceptions=True, NotifyOnValidationError=True}" 
                             Height="28"
                             VerticalContentAlignment="Center"
                             Padding="8,0"
                             FontSize="11"
                             BorderBrush="#FFCCCCCC"
                             BorderThickness="1"/>
                    <TextBlock Grid.Column="2" Text="°" VerticalAlignment="Center" FontSize="11" Foreground="#FF666666" Margin="8,0,0,0"/>
                </Grid>

                <Grid Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="50"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="上下偏移:" VerticalAlignment="Center" FontSize="11" Foreground="#FF333333"/>
                    <TextBox Grid.Column="1"
                             x:Name="GroundLiftTextBox"
                             Text="{Binding GroundPathLiftHeightInMeters, Mode=TwoWay, UpdateSourceTrigger=Explicit, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                             IsEnabled="{Binding IsGroundLiftEnabled}"
                             Height="28"
                             VerticalContentAlignment="Center"
                             Padding="8,0"
                             FontSize="11"
                             BorderBrush="#FFCCCCCC"
                             BorderThickness="1"/>
                    <TextBlock Grid.Column="2" Text="m" VerticalAlignment="Center" FontSize="11" Foreground="#FF666666" Margin="8,0,0,0"/>
                </Grid>

                <Grid Margin="0,0,0,8">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="110"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="50"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="物流车高:" VerticalAlignment="Center" FontSize="11" Foreground="#FF333333"/>
                    <TextBox Grid.Column="1"
                             x:Name="VehicleHeightTextBox"
                             Text="{Binding VehicleHeightInMeters, Mode=TwoWay, UpdateSourceTrigger=Explicit, Converter={StaticResource EditableNumberConverter}, ConverterParameter=0.###, ValidatesOnExceptions=True, NotifyOnValidationError=True}"
                             Height="28"
                             VerticalContentAlignment="Center"
                             Padding="8,0"
                             FontSize="11"
                             BorderBrush="#FFCCCCCC"
                             BorderThickness="1"/>
                    <TextBlock Grid.Column="2" Text="m" VerticalAlignment="Center" FontSize="11" Foreground="#FF666666" Margin="8,0,0,0"/>
                </Grid>

                <!-- 门型偏好 -->
                <CheckBox x:Name="WidthLargerCheckBox"
                          IsChecked="{Binding RequireWidthLarger}"
                          Content="宽 > 高（否则高 > 宽）"
                          ToolTip="根据物流通道门型选择"
                          FontSize="10"
                          Foreground="#FF666666"
                          Margin="0,0,0,8"/>

                <!-- 快捷按钮 -->
                <TextBlock Text="快捷角度（作用于当前焦点输入框）:" FontSize="10" Foreground="#FF666666" Margin="0,0,0,8"/>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button Content="0°" 
                            Click="OnQuickAngleClick" 
                            Tag="0"
                            Style="{StaticResource SecondaryButtonStyle}" 
                            Width="70" 
                            Height="28"
                            Margin="0,0,10,0"/>
                    <Button Content="90°" 
                            Click="OnQuickAngleClick" 
                            Tag="90"
                            Style="{StaticResource SecondaryButtonStyle}" 
                            Width="70" 
                            Height="28"
                            Margin="0,0,10,0"/>
                    <Button Content="180°" 
                            Click="OnQuickAngleClick" 
                            Tag="180"
                            Style="{StaticResource SecondaryButtonStyle}" 
                            Width="70" 
                            Height="28"
                            Margin="0,0,10,0"/>
                    <Button Content="270°" 
                            Click="OnQuickAngleClick" 
                            Tag="270"
                            Style="{StaticResource SecondaryButtonStyle}" 
                            Width="70" 
                            Height="28"/>
                </StackPanel>
            </StackPanel>
        </Border>
        
        <!-- 按钮栏 -->
        <Border Grid.Row="2" Background="#FFF8FBFF" BorderBrush="#FFD4E7FF" BorderThickness="0,1,0,0" Padding="10,12">
            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Content="初始值" 
                        Click="OnResetClick" 
                        Style="{StaticResource SecondaryButtonStyle}" 
                        Width="64" Height="32" Margin="0"/>
                <Button Grid.Column="2" Content="自动调整"
                        Click="OnAutoAdjustClick"
                        Style="{StaticResource SecondaryButtonStyle}"
                        Width="64" Height="32" Margin="0"/>
                <Button Grid.Column="4" Content="贴合地面"
                        Click="OnAlignToGroundClick"
                        Style="{StaticResource SecondaryButtonStyle}"
                        Width="64" Height="32" Margin="0"/>
                <Button Grid.Column="6" Content="平移" 
                        Click="OnTranslateClick" 
                        Style="{StaticResource SecondaryButtonStyle}" 
                        Width="64" Height="32" Margin="0"/>
                <Button Grid.Column="8" Content="确认" 
                        Click="OnConfirmClick" 
                        Style="{StaticResource ActionButtonStyle}" 
                        Width="64" Height="32" Margin="0"/>
                <Button Grid.Column="10" Content="取消" 
                        Click="OnCancelClick" 
                        Style="{StaticResource SecondaryButtonStyle}" 
                        Width="64" Height="32" Margin="0"/>
            </Grid>
        </Border>
    </Grid>
</Window>
