<UserControl x:Class="Valg.EVA.Skanning.JobManagement.Startup.UI.Counting.CountingView"
             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:counting="clr-namespace:Valg.EVA.Skanning.JobManagement.Startup.UI.Counting"
             xmlns:commonEnums1="clr-namespace:Valg.EVA.Skanning.Contracts.CommonEnums;assembly=Valg.EVA.Skanning.Contracts"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance d:Type=counting:CountingViewModel}"
             d:DesignHeight="300" d:DesignWidth="350">
    <UserControl.Resources>
        <ResourceDictionary>
            <Style TargetType="TextBlock" x:Key="CountingStateStyle" BasedOn="{StaticResource TextBlockNormal}">
                <Setter Property="FontWeight" Value="Bold"></Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding State}"
                                 Value="{x:Static commonEnums1:CountingState.Complete}">
                        <Setter Property="Foreground"
                                Value="{StaticResource Green}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border BorderBrush="{StaticResource GrayBorder}" BorderThickness="1" Margin="0,0,0,-1">
        <StackPanel  Margin="5">
            <ToggleButton DockPanel.Dock="Top"
                          Style="{StaticResource WhiteToggleButton}"
                          Name="ToggleButton"
                          IsChecked="{Binding IsOpen}">
                <ToggleButton.Content>
                    <StackPanel Orientation="Horizontal" Height="20" Cursor="Hand">
                        <TextBlock Style="{StaticResource PlayArrowIcon}"
                                   VerticalAlignment="Center"
                                   Foreground="{StaticResource ActiveElementBackgroundBrush}"
                                   FontSize="12"
                                   Margin="0,0,5,0" 
                                   Visibility="{Binding IsChecked, ElementName=ToggleButton, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"/>
                        <TextBlock Style="{StaticResource DownArrowIcon}"
                                   VerticalAlignment="Center"
                                   Foreground="{StaticResource DefaultBlackishBackground}"
                                   FontSize="12"
                                   Margin="0,0,5,0" 
                                   Visibility="{Binding IsChecked, ElementName=ToggleButton, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <TextBlock Style="{StaticResource TextBlockNormal}" FontSize="14" Text="{Binding Name}" />
                        <TextBlock Style="{StaticResource TextBlockNormal}" Text="-" Margin="5,0" />
                        <TextBlock Text="{Binding Status}" Style="{StaticResource CountingStateStyle}" />
                    </StackPanel>
                </ToggleButton.Content>
            </ToggleButton>

            <StackPanel Visibility="{Binding IsChecked, ElementName=ToggleButton, Converter={StaticResource BooleanToVisibilityConverter}}">
                <counting:BoxCountingView DataContext="{Binding}"
                                          Margin="0,10,0,0"
                                          Visibility="{Binding DataContext.HasCountings, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource BooleanToVisibilityConverter}}"></counting:BoxCountingView>
                <StackPanel Orientation="Horizontal"
                            Margin="0,20,0,15">
                    <Button Command="{Binding DeleteCountingCommand}"
                            IsEnabled="{Binding IsDeleteCountingButtonEnabled}"
                            Margin="0,0,10,0"
                            Style="{StaticResource RedButtonCancel}"
                            Content="{Binding JobManagementLanguageString.CountingView_DeleteCounting}"
                            Height="49">
                    </Button>
                    <Button IsEnabled="{Binding IsCompleteCountingButtonEnabled}"
                            Command="{Binding CreateResultCommand}"
                            Margin="0,0,10,0"
                            Style="{StaticResource BlueButtonOk}"
                            Content="{Binding JobManagementLanguageString.CountingView_CompleteCounting}"
                            Height="49">
                    </Button>
                    <Button 
                            Margin="0,0,10,0"
                            Visibility="{Binding IsResolveDuplicatesButtonEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"
                            Command="{Binding ResolveDuplicatesCommand}"
                            Style="{StaticResource BlueButtonResolveDuplicates}"
                            Content="{Binding JobManagementLanguageString.Duplicates_FixDuplicateButtonText}"
                            Height="49">
                    </Button>
                    <Button
                            Margin="0,0,10,0"
                            Command="{Binding GenerateBarcodesCommand}"
                            Visibility="{Binding IsGenerateBarcodeButtonEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"
                            Style="{StaticResource BlueButton}"
                            Content="{Binding JobManagementLanguageString.CountingView_GenerateBarCodes}"
                            Height="49">
                    </Button>
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Border>
</UserControl>

