<Window x:Class="ScreenToGif.Windows.Other.UploadHistory"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:n="clr-namespace:ScreenToGif.Controls"
        xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"
        Title="{DynamicResource S.Options.Upload.History.Title}" Width="600" Height="350" MinWidth="500" MinHeight="300" 
        WindowStartupLocation="CenterScreen" SnapsToDevicePixels="True" Background="{DynamicResource Panel.Background}" Loaded="Window_Loaded">

    <Window.Resources>
        <Style TargetType="{x:Type FlowDocument}">
            <Setter Property="Foreground" Value="{DynamicResource Element.Foreground.Medium}"/>
            <Setter Property="ColumnGap" Value="0"/>
        </Style>

        <Style TargetType="{x:Type Hyperlink}">
            <Setter Property="Foreground" Value="{DynamicResource Brush.Hyperlink}"/>
        </Style>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

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

            <Border Grid.Column="0" x:Name="MainBorder" Margin="6" Background="{StaticResource Vector.Clock}" Width="23" Opacity="{DynamicResource Element.Opacity}"/>

            <TextBlock Grid.Column="1" x:Name="TypeTextBlock" Text="{DynamicResource S.Options.Upload.History.Title}" Margin="5" VerticalAlignment="Center" 
                       FontFamily="Segoe UI Semilight" FontSize="18" Foreground="{DynamicResource Element.Foreground.Header}"/>
        </Grid>

        <DataGrid Grid.Row="1" Grid.Column="0" x:Name="DataGrid" Margin="5,3" MinHeight="60" SelectionMode="Single" SelectionUnit="FullRow" CanUserSortColumns="False"
                  SelectionChanged="DataGrid_SelectionChanged" PreviewKeyDown="DataGrid_PreviewKeyDown">
            <DataGrid.Columns>
                <DataGridTextColumn Header="{DynamicResource S.Options.Upload.History.Date}" Width="Auto" MinWidth="110" IsReadOnly="True" 
                                    Binding="{Binding DateInLocalTime, UpdateSourceTrigger=PropertyChanged, Mode=OneWay, StringFormat='{}{0:G}', ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}}"/>
                <DataGridTextColumn Header="{DynamicResource S.Options.Upload.Presets.Service}" Width="Auto" MinWidth="110" IsReadOnly="True" 
                                    Binding="{Binding Type, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
                <DataGridTextColumn Header="{DynamicResource S.Options.Upload.History.Preset}" Width="*" IsReadOnly="True" 
                                    Binding="{Binding PresetName, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
                <DataGridCheckBoxColumn Header="{DynamicResource S.Options.Upload.History.Successful}" Width="Auto" MinWidth="70" IsReadOnly="True" 
                                        Binding="{Binding WasSuccessful, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>

                <DataGridTemplateColumn Width="35">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <n:ExtendedButton x:Name="DeleteButton" Style="{StaticResource Style.Button.NoText}" Icon="{StaticResource Vector.Cancel}" ContentHeight="13" ContentWidth="16"
                                              ToolTip="{DynamicResource S.Options.Upload.History.Remove}" Click="DeleteButton_Click"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

        <FlowDocumentScrollViewer Grid.Row="2" x:Name="FlowDocumentViewer" Margin="5,3" VerticalScrollBarVisibility="Auto" MinHeight="23" Padding="0"
                                  BorderThickness="1" BorderBrush="{DynamicResource Element.Border}"
                                  Visibility="{Binding ElementName=DataGrid, Path=SelectedItem, Converter={StaticResource ContentToVisibility}}"/>

        <Grid Grid.Row="3" Background="{DynamicResource Panel.Background.Level3}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto" MinWidth="100"/>
            </Grid.ColumnDefinitions>

            <n:ExtendedButton Grid.Column="1" x:Name="OkButton" Text="{DynamicResource S.Ok}" Icon="{StaticResource Vector.Ok}" ContentHeight="18" ContentWidth="18" 
                              Padding="4,0" Margin="5" Click="OkButton_Click" IsCancel="True"/>
        </Grid>
    </Grid>
</Window>