<!--
// /***************************************************************************
// Aaru Data Preservation Suite
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//
// Filename       : MediaDump.xaml
// Author(s)      : Natalia Portillo <claunia@claunia.com>
//
// Component      : GUI windows.
//
// ‐‐[ Description ] ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//
//     Media dumping window.
//
// ‐‐[ License ] ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
//
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General public License as
//     published by the Free Software Foundation, either version 3 of the
//     License, or (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General public License for more details.
//
//     You should have received a copy of the GNU General public License
//     along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
// Copyright © 2011-2026 Natalia Portillo
// ****************************************************************************/
-->
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:windows="clr-namespace:Aaru.Gui.ViewModels.Windows"
        xmlns:localization="clr-namespace:Aaru.Localization;assembly=Aaru.Localization"
        xmlns:controls="clr-namespace:Aaru.Gui.Controls"
        mc:Ignorable="d"
        d:DesignWidth="800"
        d:DesignHeight="450"
        Width="900"
        Height="650"
        x:Class="Aaru.Gui.Views.Windows.MediaDump"
        Icon="/Assets/aaru.png"
        x:DataType="windows:MediaDumpViewModel"
        Title="{Binding Title, Mode=OneWay}">
    <Design.DataContext>
        <windows:MediaDumpViewModel />
    </Design.DataContext>
    <Grid Margin="12"
          RowSpacing="8"
          RowDefinitions="Auto, *, Auto">
        <ScrollViewer Grid.Row="0"
                      HorizontalScrollBarVisibility="Disabled"
                      VerticalScrollBarVisibility="Auto"
                      IsVisible="{Binding OptionsVisible, Mode=OneWay}">
            <TabControl>
                <TabItem>
                    <TabItem.Header>
                        <controls:SpectreTextBlock Text="{x:Static localization:UI.Title_General}" />
                    </TabItem.Header>
                    <StackPanel Orientation="Vertical"
                                Margin="8"
                                Spacing="8">
                        <Grid ColumnDefinitions="Auto, *"
                              ColumnSpacing="8">
                            <TextBlock Grid.Column="0"
                                       Text="{x:Static localization:UI.Output_format}"
                                       VerticalAlignment="Center" />
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding PluginsList, Mode=OneWay}"
                                      SelectedItem="{Binding SelectedPlugin, Mode=TwoWay}"
                                      HorizontalAlignment="Stretch"
                                      IsEnabled="{Binding FormatReadOnly, Mode=OneWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name, Mode=OneWay}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </Grid>
                        <Grid ColumnDefinitions="Auto, *"
                              ColumnSpacing="8">
                            <Button Grid.Column="0"
                                    Command="{Binding DestinationCommand, Mode=OneWay}"
                                    IsEnabled="{Binding DestinationEnabled, Mode=OneWay}">
                                <TextBlock Text="{x:Static localization:UI.ButtonLabel_Choose}" />
                            </Button>
                            <TextBox Grid.Column="1"
                                     Text="{Binding Destination, Mode=OneWay}"
                                     IsReadOnly="True" />
                        </Grid>
                        <CheckBox IsChecked="{Binding Resume, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Create_or_use_resume_mapfile}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding Track1Pregap, Mode=TwoWay}"
                                  IsVisible="{Binding Track1PregapVisible, Mode=OneWay}">
                            <TextBlock Text="{x:Static localization:UI.Try_to_read_track_1_pregap}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding CreateSidecar, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Create_Aaru_Metadata_sidecar}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding ExistingMetadata, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Take_metadata_from_existing_CICM_XML_sidecar}" />
                        </CheckBox>
                        <Grid ColumnDefinitions="Auto, *"
                              IsVisible="{Binding EncodingVisible, Mode=OneWay}"
                              ColumnSpacing="8">
                            <TextBlock Grid.Column="0"
                                       Text="{x:Static localization:UI.Encoding_to_use_on_metadata_sidecar_creation}"
                                       VerticalAlignment="Center" />
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding Encodings, Mode=OneWay}"
                                      SelectedItem="{Binding SelectedEncoding, Mode=TwoWay}"
                                      IsEnabled="{Binding EncodingEnabled, Mode=OneWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name, Mode=OneWay}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </Grid>
                    </StackPanel>
                </TabItem>
                <TabItem>
                    <TabItem.Header>
                        <controls:SpectreTextBlock Text="{x:Static localization:UI.Errors}" />
                    </TabItem.Header>
                    <StackPanel Orientation="Vertical"
                                Margin="8"
                                Spacing="8">
                        <CheckBox IsChecked="{Binding StopOnError, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Stop_media_dump_on_first_error}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding Force, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Continue_dumping_whatever_happens}" />
                        </CheckBox>
                        <Grid ColumnDefinitions="Auto, *"
                              ColumnSpacing="8">
                            <TextBlock Grid.Column="0"
                                       Text="{x:Static localization:UI.Retry_passes}"
                                       VerticalAlignment="Center" />
                            <NumericUpDown Grid.Column="1"
                                           HorizontalAlignment="Stretch"
                                           Value="{Binding Retries, Mode=TwoWay}"
                                           Increment="1"
                                           Minimum="0" />
                        </Grid>
                        <CheckBox IsChecked="{Binding Persistent, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Try_to_recover_partial_or_incorrect_data}" />
                        </CheckBox>
                        <Grid ColumnDefinitions="Auto, *"
                              ColumnSpacing="8">
                            <TextBlock Grid.Column="0"
                                       Text="{x:Static localization:UI.Skipped_sectors_on_error}"
                                       VerticalAlignment="Center" />
                            <NumericUpDown Grid.Column="1"
                                           Increment="1"
                                           Minimum="1"
                                           HorizontalAlignment="Stretch"
                                           Value="{Binding Skipped, Mode=TwoWay}" />
                        </Grid>
                        <CheckBox IsChecked="{Binding Trim, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Trim_errors_from_skipped_sectors}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding Paranoia, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Paranoia_help}" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding CureParanoia, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Cure_paranoia_help}" />
                        </CheckBox>
                    </StackPanel>
                </TabItem>
                <TabItem IsVisible="{Binding HasSubchannel, Mode=OneWay}">
                    <TabItem.Header>
                        <controls:SpectreTextBlock Text="{x:Static localization:UI.Subchannels}" />
                    </TabItem.Header>
                    <StackPanel Orientation="Vertical"
                                Margin="8"
                                Spacing="8">
                        <CheckBox IsChecked="{Binding FixSubchannelPosition, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Fix_subchannel_position_help}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding RetrySubchannel, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Retry_subchannel_help}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding FixSubchannel, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Fix_subchannel_help}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding FixSubchannelCrc, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Fix_subchannel_crc_help}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding GenerateSubchannels, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Generate_subchannels_dump_help}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                    </StackPanel>
                </TabItem>
                <TabItem>
                    <TabItem.Header>
                        <controls:SpectreTextBlock Text="{x:Static localization:UI.Encryption}" />
                    </TabItem.Header>
                    <StackPanel Orientation="Vertical"
                                Margin="8"
                                Spacing="8">
                        <CheckBox IsChecked="{Binding StoreEncryptedAsIs, Mode=TwoWay}">
                            <TextBlock Text="{x:Static localization:UI.Store_encrypted_data_as_is}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding ReadTitleKeys, Mode=TwoWay}"
                                  IsVisible="{Binding IsDvd, Mode=OneWay}">
                            <TextBlock Text="{x:Static localization:UI.Try_to_read_the_title_keys_from_CSS_DVDs}"
                                       TextWrapping="Wrap" />
                        </CheckBox>
                        <CheckBox IsChecked="{Binding BypassWiiDecryption, Mode=TwoWay}"
                                  IsVisible="{Binding IsWii, Mode=OneWay}">
                            <TextBox Text="{x:Static localization:UI.Bypass_Wii_decryption_help}"
                                     TextWrapping="Wrap" />
                        </CheckBox>
                    </StackPanel>
                </TabItem>
                <!-- TODO: Image options -->
            </TabControl>
        </ScrollViewer>
        <Grid Grid.Row="1"
              RowDefinitions="Auto,Auto,*,Auto,Auto"
              VerticalAlignment="Stretch"
              IsVisible="{Binding ProgressVisible, Mode=OneWay}"
              RowSpacing="8">
            <Grid Grid.Row="0"
                  ColumnDefinitions="Auto, *"
                  ColumnSpacing="8">
                <TextBlock Grid.Column="0"
                           Text="{x:Static localization:UI.Writing_image_to}" />
                <TextBlock Grid.Column="1"
                           Text="{Binding Destination, Mode=OneWay}" />
            </Grid>
            <TextBlock Grid.Row="1"
                       Text="{x:Static localization:UI.Title_Log}" />
            <Border Grid.Row="2"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Stretch"
                    BorderThickness="1"
                    BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
                    CornerRadius="8">
                <ScrollViewer Padding="8">
                    <controls:SpectreTextBlock TextWrapping="Wrap"
                                               Text="{Binding Log, Mode=OneWay}" />
                </ScrollViewer>
            </Border>
            <StackPanel Grid.Row="3"
                        Orientation="Vertical"
                        IsVisible="{Binding Progress1Visible, Mode=OneWay}"
                        Spacing="8">
                <controls:SpectreTextBlock Text="{Binding ProgressText, Mode=OneWay}" />
                <ProgressBar Value="{Binding ProgressValue, Mode=OneWay}"
                             Maximum="{Binding ProgressMaxValue, Mode=OneWay}"
                             IsIndeterminate="{Binding ProgressIndeterminate, Mode=OneWay}" />
            </StackPanel>
            <StackPanel Grid.Row="4"
                        Orientation="Vertical"
                        IsVisible="{Binding Progress2Visible, Mode=OneWay}"
                        Spacing="8">
                <controls:SpectreTextBlock Text="{Binding Progress2Text, Mode=OneWay}" />
                <ProgressBar Value="{Binding Progress2Value, Mode=OneWay}"
                             Maximum="{Binding Progress2MaxValue, Mode=OneWay}"
                             IsIndeterminate="{Binding Progress2Indeterminate, Mode=OneWay}" />
            </StackPanel>
        </Grid>
        <StackPanel Grid.Row="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right"
                    Spacing="8">
            <Button Command="{Binding StartCommand, Mode=OneWay}"
                    IsVisible="{Binding StartVisible, Mode=OneWay}">
                <TextBlock Text="{x:Static localization:UI.ButtonLabel_Start}" />
            </Button>
            <Button Command="{Binding CloseCommand, Mode=OneWay}"
                    IsVisible="{Binding CloseVisible, Mode=OneWay}">
                <TextBlock Text="{x:Static localization:UI.ButtonLabel_Close}" />
            </Button>
            <Button Command="{Binding StopCommand, Mode=OneWay}"
                    IsVisible="{Binding StopVisible, Mode=OneWay}"
                    IsEnabled="{Binding StopEnabled, Mode=OneWay}">
                <TextBlock Text="{x:Static localization:UI.ButtonLabel_Stop}" />
            </Button>
        </StackPanel>
    </Grid>
</Window>