<UserControl x:Class="HandBrakeWPF.Views.Options.OptionsUpdates"
             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:converters="clr-namespace:HandBrakeWPF.Converters"
             xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="Margin" Value="0,0,5,0" />
        </Style>

        <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Padding" Value="5,2" />
            <Setter Property="MinHeight" Value="22" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        </Style>

        <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
            <Setter Property="Margin" Value="0,2,0,2" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
    </UserControl.Resources>

    <StackPanel Name="Updates" Orientation="Vertical" Margin="10,5,0,0">


        <TextBlock Text="{x:Static Properties:Resources.Options_Updates}" Style="{StaticResource pageHeader}" />

        <TextBlock Text="{x:Static Properties:Resources.Options_CurVersion}" Style="{StaticResource subHeader}" Margin="0,10,0,10"/>

        <Grid Margin="20,10,0,20">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <!-- Version -->
            <TextBlock Grid.Column="0" Margin="0,0,0,0" Text="{x:Static Properties:Resources.Options_Version}" />
            <TextBox Grid.Column="1" Margin="0,0,0,0" VerticalAlignment="Bottom" IsReadOnly="True" Text="{Binding Version, Mode=OneWay}" BorderThickness="0" x:Name="versionTextBox" MouseDoubleClick="VersionTextBox_OnMouseDoubleClick" />
        </Grid>

        <TextBlock Text="{x:Static Properties:Resources.Options_Updates}" Style="{StaticResource subHeader}" Margin="0,10,0,10"/>

        <StackPanel Margin="20,0,0,0" Orientation="Horizontal">
            <Button Content="{x:Static Properties:Resources.Options_CheckForUpdates}" MaxWidth="130" Margin="0,0,5,0" Command="{Binding RelayCommand}" CommandParameter="PerformUpdateCheck"
                    Visibility="{Binding IsUpdateFound, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
            <Button Content="{x:Static Properties:Resources.Options_DownloadUpdates}" Width="120" Command="{Binding RelayCommand}" CommandParameter="DownloadUpdate" Visibility="{Binding DownloadAvailable, Converter={StaticResource boolToVisConverter}}" />
        </StackPanel>

        <StackPanel Margin="20,10,0,0" Orientation="Horizontal">
            <ProgressBar Minimum="0" Maximum="100" Height="20" Width="400" Value="{Binding DownloadProgressPercentage}" 
                                 Visibility="{Binding DownloadAvailable, Converter={StaticResource boolToVisConverter}}" />

        </StackPanel>

        <StackPanel Orientation="Horizontal"  Margin="20,10,10,0" Visibility="{Binding IsUpdateMessageSet, Converter={StaticResource boolToVisConverter}}">

            <Image Source="../Images/information.png" Width="16" Height="16" VerticalAlignment="Center" Margin="0,0,10,0" />
            <TextBlock Text="{Binding UpdateMessage}" VerticalAlignment="Center" TextWrapping="Wrap" Style="{StaticResource sectionHeader}"/>

        </StackPanel>

        <Grid Visibility="{Binding IsPortableModeUpdateAvailable, Converter={StaticResource boolToVisConverter}}" Margin="20,5,10,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Image Source="../Images/warningsmall.png" Width="16" Height="16" VerticalAlignment="Center" Margin="0,0,10,0" Grid.Column="0" />
            <TextBlock Text="{x:Static Properties:Resources.OptionsViewModel_PortableMode}" TextWrapping="Wrap" Grid.Column="1" Style="{StaticResource subHeader}" />
        </Grid>

        <StackPanel Visibility="{Binding UpdateAvailable, Converter={StaticResource boolToVisConverter}}" Margin="0,10,10,0">

            <TextBlock Text="{x:Static Properties:Resources.Options_BeforeUpdating}" Style="{StaticResource subHeader}" Margin="0,10,0,5"/>
            <TextBlock Text="{x:Static Properties:Resources.OptionsViewModel_UpdateNotice}" Margin="20,0,10,0" Visibility="{Binding UpdateAvailable, Converter={StaticResource boolToVisConverter}}" TextWrapping="Wrap" />

            <TextBlock Text="{x:Static Properties:Resources.AboutView_ReleaseNotes}" Style="{StaticResource subHeader}" Margin="0,20,0,5"/>
            <StackPanel Orientation="Horizontal" Grid.Row="3"  Margin="20,5,0,0">
                <TextBlock Text="{x:Static Properties:Resources.Options_ReleaseNotesDesc}" />
                <TextBlock>           
                    <Hyperlink x:Name="githubReleaseNotes" NavigateUri="/" RequestNavigate="GithubReleaseNotes_OnRequestNavigate" > https://github.com/HandBrake/HandBrake/releases</Hyperlink>
                </TextBlock>
            </StackPanel>
        </StackPanel>

    </StackPanel>
</UserControl>
