<UserControl
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Splitter_UI.Views.InspectorPane"
xmlns:vm="clr-namespace:Splitter_UI.ViewModels"
x:DataType="vm:InspectorPaneViewModel">

    <Border Background="#252525" Padding="12">
        <ScrollViewer>
            <StackPanel Spacing="2">

                <StackPanel Orientation="Horizontal"
                            HorizontalAlignment="Right"
                            Spacing="8"
                            Margin="0,0,10,0">

                    <Button Content="Apply to Selected"
                            Command="{Binding ApplyOverridesCommand}"/>

                    <Button Content="Transform all"
                            Background="#AA0000"
                            Foreground="White"
                            Command="{Binding TransformAllCommand}"/>

                </StackPanel>
                
                <TextBlock Text="Parameters" FontSize="10" Margin="0,0,0,10" FontWeight="Bold"/>

                <!-- InputFile -->
                <StackPanel Orientation="Vertical" Spacing="8">
                    <TextBlock Text="{Binding Selected.FileName}" Width="360" Margin="0,0,0,5" FontStyle="Italic"/>
                    <TextBlock Text="{Binding Selected.TextDesc}" Width="360" FontSize="10" Margin="0,0,0,10" FontWeight="Bold" Foreground="#676767"/>
                </StackPanel>

                <!-- Rotate -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Rotate" Width="120"/>

                    <StackPanel Orientation="Horizontal" Spacing="4">

                        <Button Width="24" Height="24"
                                Padding="0"
                                Command="{Binding RotateLeftCommand}">
                            <TextBlock FontFamily="{StaticResource FontAwesome}"
                                       Text="&#xf2ea;"
                                       FontSize="12"
                                       VerticalAlignment="Center"
                                       HorizontalAlignment="Center"
                                       Margin="0,-1,0,0"/>
                        </Button>

                        <Button Width="24" Height="24"
                                Padding="0"
                                Command="{Binding RotateRightCommand}">
                            <TextBlock FontFamily="{StaticResource FontAwesome}"
                                       Text="&#xf2f9;"
                                       FontSize="12"
                                       VerticalAlignment="Center"
                                       HorizontalAlignment="Center"
                                       Margin="0,-1,0,0"/>
                        </Button>


                        <!-- Angle display -->
                        <TextBlock Text="{Binding Selected.Rotate}"
                                    Width="40"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"/>
                    </StackPanel>
                </StackPanel>

                <!-- Mask -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Mask" Width="120"/>
                    <TextBox Text="{Binding Selected.Mask}" Width="260"/>
                </StackPanel>

                <!-- OutputFolder -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Output Folder" Width="120"/>
                    <TextBox Text="{Binding Selected.OutputFolder}" Width="260"/>
                </StackPanel>

                <!-- Crop -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Crop (w,h)" Width="120"/>
                    <TextBox Text="{Binding Selected.CropText}" Width="160"/>
                </StackPanel>

                <!-- GravitateTo -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="GravitateTo" Width="120"/>
                    <TextBox Text="{Binding Selected.GravitateText}" Width="160"/>
                </StackPanel>

                <!-- Detect -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Detect" Width="120"/>
                    <ComboBox ItemsSource="{Binding DetectModes}"
                              SelectedItem="{Binding Selected.Detect}"
                              Width="160"/>
                </StackPanel>

                <!-- ScoreThreshold -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Score threshold" Width="120"/>

                    <StackPanel Orientation="Vertical" Spacing="4" Width="260">
                        <Slider Minimum="0"
                                Maximum="1"
                                SmallChange="0.01"
                                LargeChange="0.1"
                                TickFrequency="0.05"
                                IsSnapToTickEnabled="False"
                                Value="{Binding Selected.ScoreThreshold, Mode=TwoWay}"/>

                        <TextBlock Text="{Binding Selected.ScoreThreshold, StringFormat='0.00'}"
                                   FontSize="10"
                                   HorizontalAlignment="Right"/>
                    </StackPanel>
                </StackPanel>
                
                <!-- ScoreThreshold -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Identity matching threshold" Width="120"/>

                    <StackPanel Orientation="Vertical" Spacing="4" Width="260">
                        <Slider Minimum="0"
                                Maximum="1"
                                SmallChange="0.01"
                                LargeChange="0.1"
                                TickFrequency="0.05"
                                IsSnapToTickEnabled="False"
                                Value="{Binding Selected.IdentityThreshold, Mode=TwoWay}"/>

                        <TextBlock Text="{Binding Selected.IdentityThreshold, StringFormat='0.00'}"
                                   FontSize="10"
                                   HorizontalAlignment="Right"/>
                    </StackPanel>
                </StackPanel>

                <!-- DetectAbove -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Detect Above" Width="120"/>
                    <TextBox Text="{Binding Selected.DetectAbove}" Width="160"/>
                </StackPanel>

                <!-- DetectId -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Object to track" Width="120"/>
                    <TextBox Text="{Binding Selected.DetectId}" Width="160"/>
                </StackPanel>

                <!-- OverrideTargetDuration -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Target Duration" Width="120"/>
                    <NumericUpDown Value="{Binding Selected.OverrideTargetDuration}" Width="120"/>
                </StackPanel>

                <!-- Enhance -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <CheckBox Content="Enhance resolution x2"
                              IsChecked="{Binding Selected.Enhance}"/>
                    <TextBlock Text="(Very slow and not worth it!)" 
                               Foreground="#FFFF80FF"
                               FontSize="10" 
                               Margin="0,12,0,0"/>
                </StackPanel>

                <!-- ForceFixed -->
                <CheckBox Content="Force Fixed Duration"
                          IsChecked="{Binding Selected.ForceFixed}"/>

                <!-- Debug -->
                <CheckBox Content="Debug Mode"
                          IsChecked="{Binding Selected.Debug}"/>

                <!-- Parameters dictionary -->
                <TextBlock Text="Advanced Parameters" FontSize="10" Margin="0,10,0,0" FontWeight="Bold"/>

                <DataGrid ItemsSource="{Binding Selected.ParametersList}"
                                AutoGenerateColumns="False"
                                HeadersVisibility="Column"
                                Margin="0,0,20,0"
                                Height="160">

                    <DataGrid.Columns>

                        <DataGridTemplateColumn Header="Key" Width="*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Key}"
                                               FontSize="10"
                                               TextTrimming="CharacterEllipsis"
                                               ToolTip.Tip="{Binding Key}">
                                    </TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Header="Value" Width="2*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Value}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>

                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>

                    </DataGrid.Columns>
                </DataGrid>


                <!-- Passthrough -->
                <StackPanel Orientation="Horizontal" Spacing="8">
                    <TextBlock Text="Passthrough" Width="120"/>
                    <TextBox Text="{Binding Selected.PassthroughText}" Width="260"/>
                </StackPanel>

            </StackPanel>
        </ScrollViewer>
    </Border>
</UserControl>
