<UserControl x:Class="Apollon.WPF.Views.OverviewView"
             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:Apollon.WPF.Views"
             xmlns:components="clr-namespace:Apollon.WPF.Views.Components" 
             xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
             mc:Ignorable="d" 
             d:DesignHeight="680" d:DesignWidth="1080"
             Background="Transparent">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions> 
        
        <StackPanel Grid.ColumnSpan="3">
            <TextBlock 
                   Text="Apollon"
                   FontSize="50"                   
                   TextAlignment="Center"
                   Margin="0,35"
                   Foreground="{StaticResource BrushPrimary2}"
                   FontFamily="Arial Black">
                <TextBlock.Effect>
                    <DropShadowEffect Color="#808080"></DropShadowEffect>
                </TextBlock.Effect>
            </TextBlock>
            <TextBlock
                   Margin="-25"
                   Text="Auswertung Bogen"
                   TextAlignment="Center"
                   FontFamily="Arial"
                   FontWeight="Bold"
                   FontSize="20"
                   Foreground="{StaticResource BrushPrimary1}">                
            </TextBlock>
        </StackPanel>        

        <StackPanel Grid.Row="2" 
                    VerticalAlignment="Stretch">

            <Image Grid.Column="2"
               Grid.Row="2"
               Source="D:\Projekte\Apollon\Apollon\Apollon.WPF\Images\Archery.png"
               Width="250"
               Height="250">
            </Image>

            <Button Style="{StaticResource ModernButton}"
                    Content="Neues Turnier vorbereiten"
                    FontSize="16"
                    Height="40"
                    Width="210"
                    Margin="40"
                    Cursor="Hand"
                    Command="{Binding AddTournamentCommand}"/>

            <Button Style="{StaticResource ModernButton}"
                    Content="Namenliste pflegen"
                    FontSize="16"
                    Height="40"
                    Width="210"
                    Margin="40"
                    Cursor="Hand"
                    Command="{Binding NavigateNameListCommand}"/>
        </StackPanel>
        
        <Grid Grid.Column="1"
                    Grid.Row="1"
                    Margin="20">            
            <StackPanel>

                <TextBlock Margin="20"
                       Text="Liste der erstellten Turniere"
                       TextAlignment="Center"
                       FontFamily="Arial"
                       FontWeight="Bold"
                       FontSize="16"
                       Foreground="{StaticResource BrushPrimary1}"/>
                
                    
                    <components:OverViewListing Height="400"
                                        Width="400"
                                        DataContext="{Binding OverviewListingViewModel}"/>
                
                    
            </StackPanel>
            <StackPanel VerticalAlignment="Center">
                <StackPanel.Style>
                    <Style TargetType="StackPanel">
                        <Setter Property="Visibility" Value="Collapsed"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsLoading}" Value="true">
                                <Setter Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
                <TextBlock Text="Daten werden geladen...."
                       TextAlignment="Center"
                       VerticalAlignment="Center"
                           Foreground="{StaticResource BrushPrimary1}"
                           Margin="0 0 0 30"
                           FontSize="14">
                </TextBlock>
                <custom:LoadingSpinner Diameter="50" IsLoading="True" Thickness="3" Color="{StaticResource BrushPrimary1}"/>
            </StackPanel>
            <Grid Width="250">
                <Grid.Style>
                    <Style TargetType="Grid">
                        <Setter Property="Visibility" Value="Collapsed"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding HasErrorMessage}" Value="true">
                                <Setter Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <TextBlock Text="{Binding ErrorMessage}"
                       FontSize="14"
                       Foreground="Red"
                       TextWrapping="WrapWithOverflow"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                           TextAlignment="Center">

                </TextBlock>
            </Grid>            
        </Grid>

        <Grid Grid.Column="2"
                    Grid.Row="1"
                    VerticalAlignment="Center">
            <Grid.Style>
                <Style TargetType="Grid">
                    <Setter Property="Visibility" Value="Hidden"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsLoading}" Value="false">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding HasErrorMessage}" Value="true">
                            <Setter Property="Visibility" Value="Hidden"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>

            </Grid.Style>
            <StackPanel>
                <TextBlock Margin="20"
                       Text="Turnieredetails"
                       TextAlignment="Center"
                       FontFamily="Arial"
                       FontWeight="Bold"
                       FontSize="16"
                       Foreground="{StaticResource BrushPrimary1}"/>

                <components:OverviewDetails Width="320"
                                        DataContext="{Binding OverviewDetailsViewModel}"/>

            </StackPanel>
        </Grid>
             
              
    </Grid>
</UserControl>
