<UserControl x:Class="Valg.EVA.Skanning.Verify.Startup.StartPage.VerifyStartPage"
             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:startPage="clr-namespace:Valg.EVA.Skanning.Verify.Startup.StartPage"
             xmlns:filter="clr-namespace:Valg.EVA.Skanning.Verify.Startup.Filter"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance d:Type=startPage:VerifyStartPageViewModel}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Valg.EVA.Skanning.Assets;component/ResourceDictionaries/ResourceLibrary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.Resources>
            <Style x:Key="BallotListBaseGridStyle" TargetType="Grid">
                <Setter Property="Margin" Value="0,0,10,0"/>
                <Setter Property="MinWidth" Value="450"/>
            </Style>

            <Style x:Key="BallotListHeaderTextblockStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockNormal}">
                <Setter Property="Margin" Value="5,10,0,10"/>
                <Setter Property="Foreground" Value="White" />
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>

            <Style x:Key="BallotListInternalListBoxStyle" TargetType="ItemsControl">
                <Setter Property="BorderThickness" Value="0" />
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0"
                   Style="{StaticResource TextBlockLargeHeader}" 
                   VerticalAlignment="Center" Margin="0,50,0,50" 
                   Text="{Binding VerifyStartPageHeaderText}"/>

        <StackPanel Grid.Row="1">
            <TextBlock Style="{StaticResource TextBlockNormal}"
                    Margin="0,0,0,10">
                <Run Text="{Binding VerifyLanguageString.Verify_RefreshInfo_LastUpdated, Mode=OneWay}" />
                <Run Text="{Binding LastUpdated}" />
            </TextBlock>
            <TextBlock Style="{StaticResource TextBlockNormal}"
                       Margin="0,0,0,10" 
                       Text="{Binding VerifyLanguageString.Verify_RefreshInfo_HowToUpdate}" />
        </StackPanel>
        <filter:FilterView Grid.Row="2"
                           DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=FilterViewModel}" />

        <StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Top">
            <Grid Style="{StaticResource BallotListBaseGridStyle}">
                <Grid.RowDefinitions>
                    <RowDefinition MaxHeight="50" MinHeight="50"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0"  Orientation="Horizontal" Background="{StaticResource DefaultBlackishBackground}" >
                    <TextBlock Margin="10,0,0,0" Style="{StaticResource BallotListHeaderTextblockStyle}" Text="{Binding BallotPapersToVerifyHeaderText}" />
                </StackPanel>

                <ItemsControl IsTabStop="False" Grid.Row="1" ItemsSource="{Binding BoxesToVerify}" Style="{StaticResource BallotListInternalListBoxStyle}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="10,20,0,10" Orientation="Vertical"
                                        d:DataContext="{d:DesignInstance startPage:StartPageBoxToVerifyViewModel}"
                                        Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <startPage:MiniBoxCountingInformationWithNoResources DataContext="{Binding BoxCountingInformationViewModel}" />
                                <StackPanel Orientation="Horizontal" Margin="0,15,0,0" >
                                    <Button Style="{StaticResource LinkButtonNormal}" Content="{Binding BoxDetailsLinkText}" Command="{Binding GoToVerifyWithThisBoxCommand}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>

            <Grid Style="{StaticResource BallotListBaseGridStyle}">
                <Grid.RowDefinitions>
                    <RowDefinition MaxHeight="50" MinHeight="50"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal" Background="{StaticResource DefaultBlackishBackground}">
                    <TextBlock Margin="10,0,0,0" Style="{StaticResource BallotListHeaderTextblockStyle}" Text="{Binding BallotPapersVerifiedHeaderText}" />
                </StackPanel>

                <ItemsControl IsTabStop="False" Grid.Row="1" ItemsSource="{Binding BoxesVerified}" Style="{StaticResource BallotListInternalListBoxStyle}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="10,20,0,10" Orientation="Vertical"
                                        d:DataContext="{d:DesignInstance startPage:StartPageBoxVerifiedViewModel}"
                                        Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <startPage:MiniBoxCountingInformationWithNoResources DataContext="{Binding BoxCountingInformationViewModel}" />
                                <StackPanel Orientation="Horizontal" Margin="0,15,0,0" >
                                    <Button Style="{StaticResource LinkButtonNormal}" Content="{Binding BoxDetailsLinkText}" Command="{Binding OpenReviewOfVerifiedBallotsCommand}" />
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>

