<Window x:Class="ScreenToGif.Windows.Other.VideoSource"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:ScreenToGif.Controls"
        xmlns:u="clr-namespace:ScreenToGif.Util"
        xmlns:t="clr-namespace:ScreenToGif.Settings"
        Title="{DynamicResource S.ImportVideo.Title}" Height="500" Width="800" MinHeight="400" MinWidth="500" 
        SnapsToDevicePixels="True" UseLayoutRounding="True" Icon="/ScreenToGif;component/Resources/Logo.ico" WindowStartupLocation="CenterOwner" 
        Background="{DynamicResource Panel.Background}" Loaded="Window_Loaded" Closing="Window_Closing">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Background="{DynamicResource Panel.Background.Level4}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Border Grid.Column="0" x:Name="IconViewBox" Margin="6" Background="{StaticResource Vector.FramesFromVideo}" Opacity="{DynamicResource Element.Opacity}"/>

            <TextBlock Grid.Column="1" Text="{DynamicResource S.ImportVideo.Title}" Margin="5" VerticalAlignment="Center" Padding="2" FontSize="18" 
                       FontFamily="Segoe UI Semilight" Foreground="{DynamicResource Element.Foreground.Header}"/>

            <TextBlock Grid.Column="2" Text="{DynamicResource S.ImportVideo.Importer}" FontSize="13" Foreground="{DynamicResource Element.Foreground.Header}" 
                       TextAlignment="Center" VerticalAlignment="Center" Margin="3"/>

            <ComboBox Grid.Column="3" x:Name="ImporterComboBox" Margin="5,3" Height="23" MinWidth="100" SelectedIndex="{Binding VideoImporter, Source={x:Static t:UserSettings.All}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                      SelectionChanged="ImporterComboBox_SelectionChanged">
                <TextBlock Text="MediaPlayer"/>
                <TextBlock Text="FFmpeg"/>
            </ComboBox>
        </Grid>

        <c:StatusBand Grid.Row="1" x:Name="StatusBand"/>

        <Label x:Name="LoadingLabel" Grid.Row="2" Content="{DynamicResource S.ImportVideo.Loading}" Margin="0" VerticalContentAlignment="Center" 
               HorizontalContentAlignment="Center" FontSize="24" Foreground="{DynamicResource Element.Foreground.Header}" FontFamily="Segoe UI Semilight"/>

        <Grid Grid.Row="2" x:Name="PreviewerGrid" Margin="5" Opacity="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="50"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition MinWidth="50"/>
            </Grid.ColumnDefinitions>

            <Image x:Name="LowerSelectionImage" Grid.Column="0"/>
            <Image x:Name="UpperSelectionImage" Grid.Column="2"/>

            <GridSplitter x:Name="Splitter" Grid.Column="1" Width="4" BorderBrush="{DynamicResource Element.Border}" 
                          KeyboardIncrement="5" ShowsPreview="False" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" 
                          Effect="{StaticResource Shadow.Background.Small}" Opacity="0.8" Margin="-2,0"/>
        </Grid>

        <c:RangeSlider x:Name="SelectionSlider" Grid.Row="3" Height="Auto" MinHeight="20" UpperValue="100" LowerValue="0" TickPlacement="BottomRight" Margin="5,5" IsEnabled="False"
                       UpperValueChanged="SelectionSlider_UpperValueChanged" LowerValueChanged="SelectionSlider_LowerValueChanged" PreviewMouseUp="SelectionSlider_PreviewMouseUp"/>

        <Grid x:Name="DetailsGrid" Grid.Row="4" IsEnabled="False" Margin="0,0,0,5">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Text="{DynamicResource S.ImportVideo.Scale}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal">
                <c:IntegerUpDown x:Name="ScaleIntegerUpDown" MinWidth="60" Margin="5" Maximum="200" Minimum="5" Value="100" ValueChanged="ScaleNumericUpDown_ValueChanged"/>
                <TextBlock Text="%" VerticalAlignment="Center" Padding="0,0,5,0" Foreground="{DynamicResource Element.Foreground.Medium}"/>
            </StackPanel>

            <TextBlock Grid.Row="0" Grid.Column="1" Text="{DynamicResource S.ImportVideo.Size}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left">
                <TextBlock Text="{DynamicResource S.ImportVideo.Width}" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
                <TextBlock x:Name="WidthTextBlock" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>

                <TextBlock Text="{DynamicResource S.ImportVideo.Height}" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
                <TextBlock x:Name="HeightTextBlock" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
            </StackPanel>

            <Separator Grid.Row="0" Grid.Column="2" Grid.RowSpan="2" Width="1" HorizontalAlignment="Left"/>

            <TextBlock Grid.Row="0" Grid.Column="3" Text="{DynamicResource S.ImportVideo.Framerate}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Row="1" Grid.Column="3" Orientation="Horizontal" HorizontalAlignment="Left">
                <c:IntegerUpDown x:Name="FpsIntegerUpDown" MinWidth="60" Margin="5" Maximum="60" Minimum="1" Value="{Binding Source={x:Static t:UserSettings.All}, Path=LatestFpsImport, Mode=TwoWay}" 
                                 ValueChanged="FpsIntegerUpDown_ValueChanged"/>
                <TextBlock Text="{DynamicResource S.ImportVideo.Fps}" Padding="0,0,5,0" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}"/>
            </StackPanel>

            <Separator Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Width="1" HorizontalAlignment="Left"/>

            <TextBlock Grid.Row="0" Grid.Column="6" Text="{DynamicResource S.ImportVideo.Start}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Row="1" Grid.Column="6" Orientation="Horizontal" HorizontalAlignment="Left">
                <c:IntegerUpDown x:Name="StartIntegerUpDown" MinWidth="60" Margin="5" StepValue="10" Padding="2,0"
                                 Maximum="{Binding Value, ElementName=EndIntegerUpDown}" Minimum="{Binding Minimum, ElementName=SelectionSlider}" 
                                 Value="{Binding LowerValue, ElementName=SelectionSlider, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 ValueChanged="StartIntegerUpDown_ValueChanged"/>
                <TextBlock Text="ms" Padding="0,0,5,0" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}"/>
            </StackPanel>

            <TextBlock Grid.Row="0" Grid.Column="7" Text="{DynamicResource S.ImportVideo.End}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Row="1" Grid.Column="7" Orientation="Horizontal" HorizontalAlignment="Left">
                <c:IntegerUpDown x:Name="EndIntegerUpDown" MinWidth="60" Margin="5" StepValue="10" Padding="2,0"
                                 Maximum="{Binding Maximum, ElementName=SelectionSlider}" Minimum="{Binding Value, ElementName=StartIntegerUpDown}" 
                                 Value="{Binding UpperValue, ElementName=SelectionSlider, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 ValueChanged="EndIntegerUpDown_ValueChanged"/>
                <TextBlock Text="ms" Padding="0,0,5,0" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}"/>
            </StackPanel>

            <TextBlock Grid.Row="0" Grid.Column="8" Text="{DynamicResource S.ImportVideo.Selection}" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Margin="3"/>
            <StackPanel Grid.Row="1" Grid.Column="8" Orientation="Horizontal">
                <TextBlock Text="{DynamicResource S.ImportVideo.Frames}" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
                <TextBlock x:Name="FrameCountTextBlock" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>

                <TextBlock Text="{DynamicResource S.ImportVideo.Duration}" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
                <TextBlock x:Name="DurationTextBlock" VerticalAlignment="Center" Foreground="{DynamicResource Element.Foreground.Medium}" Margin="3"/>
            </StackPanel>
        </Grid>

        <Grid Grid.Row="5" Background="{DynamicResource Panel.Background.Level3}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Label x:Name="StatusLabel" Content="{DynamicResource S.InsertFrames.Importing}" Margin="5,0,0,0"
                   Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center" Visibility="Collapsed"/>
            <ProgressBar x:Name="CaptureProgressBar" Grid.Column="1" Height="4" Margin="5,0" Visibility="Collapsed"/>

            <c:ExtendedButton x:Name="OkButton" Grid.Column="2" Text="{DynamicResource S.Ok}" IsEnabled="False" Icon="{StaticResource Vector.Ok}" 
                              ContentWidth="18" ContentHeight="18" Padding="5,0" MinWidth="90" Margin="5" Click="OkButton_Click" />
            <c:ExtendedButton x:Name="CancelButton" Grid.Column="3" Text="{DynamicResource S.Cancel}" Icon="{StaticResource Vector.Cancel}"
                              ContentWidth="18" ContentHeight="18" Padding="5,0" MinWidth="90" Margin="5" IsCancel="True" Click="CancelButton_Click"/>
        </Grid>
    </Grid>
</Window>