<Window x:Class="GestoreTrimestrale.MainWindow"
             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:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:converters="clr-namespace:GestoreTrimestrale.Converters"
             xmlns:mycontrols="clr-namespace:GestoreTrimestrale.Views"
             Title="Quaterly Report Management 2 "
             mc:Ignorable="d" Height="570" Width="1200" Icon="Bulb.ico" ResizeMode="CanMinimize">
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <i:InvokeCommandAction Command="{Binding WindowClosingCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
   
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVis" />
        <converters:BooleanInverterConverter x:Key="BooleanInverterConverter"/>
    </Window.Resources>

    <Grid MinHeight="300" MinWidth="549" IsEnabled="{Binding Path=ApplicationStateModel.IsEnabledEntireInterface, Mode=OneWay}" >
        <Grid.RowDefinitions>
            <RowDefinition Height="528.2*"/>
            <RowDefinition Height="120*" />
        </Grid.RowDefinitions>
    
        <TabControl Grid.Row="0" x:Name="tabControl" Height="440" VerticalAlignment="Bottom">
            <TabItem Header="Pre-Generation">
                <mycontrols:PreGenerationView x:Name="preGenView"/>
            </TabItem>
            <TabItem Header="Pre-Generation II">
                <mycontrols:PreGeneration2View  x:Name="preGen2View"/>
            </TabItem>
            <TabItem Header="PDF Generation">
                <mycontrols:PDFGenerationView/>
            </TabItem>
            <TabItem Header="PDF Validator">
                <mycontrols:PDFValidatorView/>
            </TabItem>
            <TabItem Header="Zipping">
                <mycontrols:ZippingView/>
            </TabItem>
            <TabItem Header="ZIP tester">
                <mycontrols:ZipTesterView />
            </TabItem>
            <TabItem Header="FTP Transfer">
                <mycontrols:FTPTransferView/>
            </TabItem>
            <TabItem Header="Mail notification" Visibility="{Binding Path=ApplicationStateModel.ShowMailNotificationTab, Converter={StaticResource BoolToVis}, Mode=OneWay}">
                <mycontrols:MailNotificationView/>
            </TabItem>
        
        </TabControl>
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="28"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0"  Height="28" HorizontalAlignment="Center" VerticalAlignment="Top">
                <Label Foreground="Red" Content="You must save the config in order for any change to take place."/>
            </Grid>
            <Grid Grid.Row="1" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="25"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="1">
                    <TextBlock Margin="5" Text="{Binding Path=ConfigurationModel.Path, Mode=TwoWay}" Name="ConfigPathLabel" VerticalAlignment="Center" TextWrapping="Wrap"/>
                </Grid>

                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button x:Name="buttonLoadSQLConfig" Command="{Binding LoadSQLConfigCommand}" Content="Load DB config"  Height="23"  Width="111" Margin="5"/>
                    <Button x:Name="buttonLoadConfig" IsEnabled="{Binding Path=ApplicationStateModel.PdfGenerationProcessRunning, Converter={StaticResource BooleanInverterConverter}, Mode=OneWay}" Command="{Binding Path=LoadConfigCommand}" Content="Load configuration" HorizontalAlignment="Right" Height="23"  VerticalAlignment="Center" Width="111" Margin="5"/>
                    <Button x:Name="buttonSaveConfig" Command="{Binding Path=SaveConfigCommand}" Content="Save configuration" HorizontalAlignment="Right" Height="23"  VerticalAlignment="Center" Width="111" Margin="5"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</Window>