<UserControl x:Class="Valg.EVA.Skanning.Sample.Startup.Box.BoxControl"
             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:local="clr-namespace:Valg.EVA.Skanning.Sample.Startup.Box"
             xmlns:ballot="clr-namespace:Valg.EVA.Skanning.Sample.Startup.Ballot"
             xmlns:ballotPaperXofY="clr-namespace:Valg.EVA.Skanning.Verify.Startup.VerifyBallotPaper.BallotPaperXOfY;assembly=Valg.EVA.Skanning.Verify.Startup"
             xmlns:userInterfaceElements="clr-namespace:Valg.EVA.Skanning.UserInterfaceElements;assembly=Valg.EVA.Skanning.UserInterfaceElements"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             d:DataContext="{d:DesignInstance d:Type=local:BoxControlViewModel}"
             Loaded="BoxControl_OnLoaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.3*"/>
            <ColumnDefinition Width="0.7*"/>
        </Grid.ColumnDefinitions>

        <TabControl Grid.Column="0" >
            <TabControl.Items>
                <TabItem Header="{Binding SampleLanguageString.Ballot}">
                    <ScrollViewer VerticalScrollBarVisibility="Auto">
                        <ballot:BallotMetadataControl  
                        Margin="10"
                        DataContext="{Binding NavigateBallotsViewModel.BallotControlViewModel}"></ballot:BallotMetadataControl>
                    </ScrollViewer>
                </TabItem>
                <TabItem Header="{Binding SampleLanguageString.Box}">
                    <ScrollViewer VerticalScrollBarVisibility="Auto">

                        <StackPanel Height="Auto" Width="Auto" Margin="10">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontWeight="Bold" Text="{Binding BoxOverview.BallotsScanned}" />
                                <TextBlock Text=" "></TextBlock>
                                <TextBlock FontWeight="Bold" Text="{Binding SampleLanguageString.Box_NumberScanned}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding BoxOverview.AutomaticVerifiedOk}"/>
                                <TextBlock Text=" "></TextBlock>
                                <TextBlock Text="{Binding SampleLanguageString.Box_NumberMachineInterpreted}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding BoxOverview.ManuallyVerified}"/>
                                 <TextBlock Text=" "></TextBlock>
                               <TextBlock Text="{Binding SampleLanguageString.Box_NumberManuallyVerified}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0 10 0 0">
                                <TextBlock Text="{Binding BoxOverview.ProposedRejected}"/>
                                <TextBlock Text=" "></TextBlock>
                                <TextBlock Text="{Binding SampleLanguageString.Box_NumberSuggestedRejected}"/>
                            </StackPanel>
                            <TextBlock Text="{Binding SampleLanguageString.Box_AffiliationDistribution}" 
                                       Margin="0 10 0 0" 
                                       FontWeight="Bold"/>
                            <DataGrid ItemsSource="{Binding BoxOverview.AffiliationVoteAggregated}" AutoGenerateColumns="False" Width="Auto" IsReadOnly="True">
                                <DataGrid.Columns >
                                    <DataGridTextColumn Header="Parti" Binding="{Binding AffiliationId}" Width="0.5*"/>
                                    <DataGridTextColumn Header="Gyldige stemmer" Binding="{Binding ValidVotes}" Width="0.5*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                            <TextBlock Text="{Binding SampleLanguageString.Box_Rejections}" 
                                       FontWeight="Bold" 
                                       Margin="0 10 0 0"
                                       Visibility="{Binding BoxOverview.HasRejections, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            <DataGrid ItemsSource="{Binding BoxOverview.RejectionsAggregated}" AutoGenerateColumns="False" Width="Auto" IsReadOnly="True" Visibility="{Binding BoxOverview.HasRejections, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <DataGrid.Columns >
                                    <DataGridTextColumn Header="Kode" Binding="{Binding RejectionReason}" Width="0.15*"/>
                                    <DataGridTextColumn Header="Beskrivelse" Binding="{Binding RejectionReasonText}" Width="0.7*"/>
                                    <DataGridTextColumn Header="Antall" Binding="{Binding Ballots}" Width="0.15*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                            <TextBlock Text="{Binding SampleLanguageString.BallotMetadata_PersonVotes}" FontWeight="Bold" Visibility="{Binding BoxOverview.HasPersonVotes, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            <DataGrid ItemsSource="{Binding BoxOverview.PersonVotesAggregated}" AutoGenerateColumns="False" Width="Auto" IsReadOnly="True" Visibility="{Binding BoxOverview.HasPersonVotes, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <DataGrid.Columns >
                                    <DataGridTextColumn Header="Navn" Binding="{Binding CandidateName}" Width="0.7*"/>
                                    <DataGridTextColumn Header="Parti" Binding="{Binding AffiliationId}" Width="0.15*"/>
                                    <DataGridTextColumn Header="Stemmer" Binding="{Binding Votes}" Width="0.15*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                            <TextBlock Text="{Binding SampleLanguageString.BallotMetadata_Writeins}" FontWeight="Bold" Visibility="{Binding BoxOverview.HasWriteIns, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            <DataGrid ItemsSource="{Binding BoxOverview.WriteInVoteAggregated}" AutoGenerateColumns="False" Width="Auto" IsReadOnly="True" Visibility="{Binding BoxOverview.HasWriteIns, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <DataGrid.Columns >
                                    <DataGridTextColumn Header="Navn" Binding="{Binding CandidateName}" Width="0.7*"/>
                                    <DataGridTextColumn Header="Parti" Binding="{Binding AffiliationId}" Width="0.15*"/>
                                    <DataGridTextColumn Header="Antall" Binding="{Binding Votes}" Width="0.15*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </StackPanel>

                    </ScrollViewer>
                </TabItem>
            </TabControl.Items>
        </TabControl>

        <Grid Margin="10" Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <ballot:BallotControl Grid.Row="0"  DataContext="{Binding NavigateBallotsViewModel.BallotControlViewModel}"/>

            <StackPanel Grid.Row="1"
                        Orientation="Horizontal" 
                        VerticalAlignment="Bottom" 
                        HorizontalAlignment="Center">
                <Button x:Name="FirstButton" 
                         Style="{StaticResource BlueButtonRewind}"
                         Command="{Binding NavigateBallotsViewModel.FirstCommand}" 
                         IsEnabled="{Binding NavigateBallotsViewModel.IsPreviousButtonEnabled, Mode=OneWay}" 
                         Width="50" 
                         Height="50"
                         Margin="0 0 5 0"
                         Content=""/>
                <Button x:Name="PreviousButton" 
                        Style="{StaticResource BlueButtonPrevious}"
                        Command="{Binding NavigateBallotsViewModel.PreviousCommand}" 
                        IsEnabled="{Binding NavigateBallotsViewModel.IsPreviousButtonEnabled, Mode=OneWay}" 
                        Width="50" 
                        Height="50"
                        Content=""/>

                <local:BallotPaperXOfYControl 
                    DataContext="{Binding NavigateBallotsViewModel.BallotPaperXOfYViewModel}"
                    Margin="5 0 5 0"/>

                <Button x:Name="NextButtonBlinking" Style="{StaticResource BlueButtonNext}"
                        Command="{Binding NavigateBallotsViewModel.NextCommand}" 
                        IsEnabled="{Binding NavigateBallotsViewModel.IsNextButtonEnabled, Mode=OneWay}"
                        userInterfaceElements:FocusExtension.IsFocused="False"
                        Width="50" Height="50"
                        Content=""/>
                <Button x:Name="LastButton" Style="{StaticResource BlueButtonFastForward}"
                        Command="{Binding NavigateBallotsViewModel.LastCommand}" 
                        IsEnabled="{Binding NavigateBallotsViewModel.IsNextButtonEnabled, Mode=OneWay}"
                        userInterfaceElements:FocusExtension.IsFocused="False"
                        Width="50" Height="50"
                        Margin ="5 0 0 0"
                        Content=""/>
            </StackPanel>

        </Grid>

    </Grid>
</UserControl>

