<mah:MetroWindow x:Class="FFXIV_TexTools.Views.Transactions.TransactionStatusWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:FFXIV_TexTools.Views.Transactions"
        mc:Ignorable="d"
        Title="Transaction Manager" Height="400" Width="500" MinWidth="660" MinHeight="300">
    <Grid>
        <Grid.ColumnDefinitions>
            
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Margin="5">
            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center">
                <Run>Transaction Status:</Run>
                <Run Text="{Binding Path=TxStatusText, FallbackValue=Unknown}" FontWeight="Bold" Foreground="{Binding Path=TxStatusBrush, FallbackValue=Red}"></Run>
            </TextBlock>
            <Label HorizontalAlignment="Right" VerticalAlignment="Center" FontStyle="Italic" FontSize="10">You may close this window after beginning a transaction.</Label>
        </Grid>

        <Grid x:Name="TxTutorialGrid" Grid.Row="1">
            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" FontStyle="Italic">
                Transactions are a scratch-pad like fake-file system ontop of your FFXIV install.
                <LineBreak/>While using a Transaction, your real FFXIV files will not be altered.
                <LineBreak/>Likewise, they will not be reflected in game (without being connected to Penumbra).
                <LineBreak/>
                <LineBreak/>You may commit your transaction changes to the game files via the [Commit] button,
                <LineBreak/>otherwise they will be discarded when TexTools is closed or the Transaction cancelled.
            </TextBlock>
        </Grid>
        
        <Grid x:Name="TxStatusGrid" Grid.Row="1" IsEnabled="{Binding Path=TxActionEnabled}" >
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>

            <Grid Grid.Row="0" Margin="10" MinHeight="150">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"></RowDefinition>
                    <RowDefinition Height="1*"></RowDefinition>
                </Grid.RowDefinitions>
                <Label Content="Modified Files" HorizontalAlignment="Left" VerticalAlignment="Center"></Label>

                <Button x:Name="PenumbraRestore" Content="Restore Mod Backup" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,155,0" Width="150" Click="RestorePenumbraBackup_Click" IsEnabled="{Binding Path=TxActionEnabled}"></Button>
                <Button Content="Reset Selected File(s)" HorizontalAlignment="Right" VerticalAlignment="Center" Click="ResetFiles_Click" Width="150"></Button>
                <Border Grid.Row="1" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1">
                    <ListBox x:Name="FileListBox" Grid.Row="0" ItemsSource="{Binding Path=FileListSource}" SelectionMode="Extended"></ListBox>
                </Border>
            </Grid>

            <Grid Grid.Row="1" x:Name="TargetGrid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="40" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <Label Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Content="Transaction Target:"></Label>
                <ComboBox Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Width="120" VerticalAlignment="Center" DisplayMemberPath="Key" SelectedValuePath="Value" ItemsSource="{Binding Path=TargetSource}" SelectedValue="{Binding Path=TxTarget}" IsEnabled="{Binding Path=TxTargetEnabled}"></ComboBox>

                <Grid x:Name="ExtendedTargetInfo" Grid.Row="1" Height="40" Grid.ColumnSpan="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <Button Content="Target Path:" HorizontalAlignment="Right" VerticalAlignment="Center" Width="100" Click="SelectTargetPath_Click" Margin="5,0,5,0" IsEnabled="{Binding Path=TxPathEnabled}"></Button>
                    <TextBox Grid.Column="1" VerticalAlignment="Center" Margin="5,0,5,0" IsEnabled="False" Text="{Binding Path=TxTargetPath}"></TextBox>
                </Grid>
            </Grid>
        </Grid>

        <Grid Grid.Row="2" x:Name="PreTxRow"  IsEnabled="{Binding Path=TxActionEnabled}" >
            <Button Content="Attach to Penumbra" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5,5,160,5" Width="150" Click="AttachPenumbra_Click"></Button>
            <Button Content="Begin Transaction" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" Width="150" Click="Begin_Click"></Button>
            <Button Content="Prepare Transaction" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,5,315,5" Width="150" ToolTip="Open a Preparation-state Transaction, where you may pre-load files." Click="Prepare_Click"></Button>
            <Button Content="Cancel" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Width="150" Click="Close_Click"></Button>
        </Grid>
        
        <Grid Grid.Row="2" x:Name="PreparingTxRow"  IsEnabled="{Binding Path=TxActionEnabled}" Visibility="Collapsed" >
            <Button Content="Attach to Penumbra" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5,5,160,5" Width="150" Click="AttachPenumbra_Click"></Button>
            <Button Content="Begin Transaction" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" Width="150" Click="Begin_Click"></Button>
            <Button Content="Cancel Transaction" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Width="150" Click="Cancel_Click"></Button>
        </Grid>
        
        <Grid Grid.Row="2" x:Name="DuringTxRow" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
                <ColumnDefinition Width="160"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Button Content="Cancel Transaction" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Width="150" Click="Cancel_Click"></Button>
            <CheckBox x:Name="CloseOnCommitBox"  Grid.Column="2"  Content="Keep Open after Commit" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Path=KeepOpen}" ToolTip="Keep the transaction open after committing.  Not available when targeting base game files."></CheckBox>
            <CheckBox x:Name="AutoCommitBox"  Grid.Column="3"  Content="Auto-Commit Changes" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Path=AutoCommit}" ToolTip="Automatically save the transaction whenever any changes are made."></CheckBox>
            <Button Content="Commit Transaction"  Grid.Column="4"  VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5" Width="150" Click="Commit_Click" IsEnabled="{Binding Path=CommitEnabled}"></Button>
        </Grid>
    </Grid>
</mah:MetroWindow>
