<UserControl x:Class="NebulaAuth.View.MafileExporterView"
             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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:other="clr-namespace:NebulaAuth.ViewModel.Other"
             xmlns:nebulaAuth="clr-namespace:NebulaAuth"
             mc:Ignorable="d"
             TextElement.Foreground="{DynamicResource BaseContentBrush}"
             FontFamily="{materialDesign:MaterialDesignFont}"
             MinWidth="400"
             MaxWidth="400"
             Background="{DynamicResource WindowBackground}"
             d:DataContext="{d:DesignInstance other:MafileExporterVM}"
             d:Background="#141119"
             d:Foreground="White"
             FontSize="18">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Margin="10,10,10,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Kind="FileExport" Width="20" Height="20" Margin="0,0,5,0"
                                         VerticalAlignment="Center"
                                         Foreground="{DynamicResource PrimaryContentBrush}" />
                <TextBlock FontStyle="Normal" Foreground="{DynamicResource BaseContentBrush}"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center" FontSize="18" Text="{Tr ExportDialog.ExportTitle}" />
            </StackPanel>
            <Button Grid.Column="1" Width="30" Height="30" Style="{StaticResource MaterialDesignIconForegroundButton}"
                    HorizontalAlignment="Right" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
                    IsCancel="True">
                <materialDesign:PackIcon Kind="Close" Width="24" Height="24" Foreground="IndianRed" />
            </Button>
        </Grid>
        <Separator Background="DarkGray" Opacity="0.4" Grid.Row="1" />
        <Grid Grid.Row="2" Margin="15" TextElement.FontSize="14">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />

                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <ComboBox Grid.Column="0"
                              Padding="10"
                              Style="{StaticResource MaterialDesignOutlinedComboBox}"
                              Margin="0,0,5,0"
                              materialDesign:HintAssist.Hint="{Tr ExportDialog.TemplateHint}"
                              ItemsSource="{Binding Templates}"
                              DisplayMemberPath="Name"
                              SelectedItem="{Binding CurrentTemplate}"
                              Visibility="{Binding EditMode, Converter={StaticResource InverseBooleanToVisibilityConverter}}" />

                    <TextBox x:Name="EditTemplateNameTextBox"
                             Grid.Column="0"
                             Padding="10"
                             Margin="0,0,5,0"
                             Style="{StaticResource MaterialDesignOutlinedTextBox}"
                             materialDesign:HintAssist.Hint="{Tr ExportDialog.TemplateHint}"
                             Text="{Binding CurrentTemplate.Name,
                                    FallbackValue=''}"
                             IsEnabled="{Binding CurrentTemplate, Converter={StaticResource NullableToBooleanConverter}}"
                             Visibility="{Binding EditMode, Converter={StaticResource BooleanToVisibilityConverter}}">

                        <TextBox.InputBindings>
                            <KeyBinding Key="Enter"
                                        Command="{Binding ToggleEditModeCommand}" />
                        </TextBox.InputBindings>

                    </TextBox>


                    <Button Command="{Binding AddTemplateCommand}" Grid.Column="1">
                        <materialDesign:PackIcon Kind="Add" />
                    </Button>

                    <Button Command="{Binding ToggleEditModeCommand}" Click="EditButton_Click" Grid.Column="2">
                        <materialDesign:PackIcon Kind="Edit" />
                    </Button>

                    <Button Grid.Column="3" Command="{Binding RemoveCurrentTemplateCommand}">
                        <materialDesign:PackIcon Kind="Trash" />
                    </Button>
                </Grid>

                <Grid Margin="0,15,0,0" Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox
                        IsEnabled="{Binding CurrentTemplate, Converter={StaticResource NullableToBooleanConverter}}"
                        MouseDoubleClick="PathTB_DoubleClick" materialDesign:TextFieldAssist.HasClearButton="True"
                        Text="{Binding CurrentTemplate.Path, FallbackValue=''}" Padding="10"
                        Style="{StaticResource MaterialDesignOutlinedTextBox}" Grid.Column="0"
                        materialDesign:HintAssist.Hint="{Tr ExportDialog.SelectPathHint}" />
                    <Button Command="{Binding OpenSelectDirectoryDialogCommand}" Grid.Column="1" Margin="5,0,0,0">
                        <materialDesign:PackIcon Kind="FolderOpen" />
                    </Button>
                </Grid>

                <Border Grid.Row="2" BorderThickness="1" CornerRadius="4" Margin="0,15,0,0" Padding="2">
                    <Border.BorderBrush>
                        <SolidColorBrush Color="{DynamicResource BaseContentColor}" Opacity="0.4" />
                    </Border.BorderBrush>
                    <Expander x:Name="TemplateExpander"
                              Header="{Tr ExportDialog.ExportSettingsHeader}"
                              materialDesign:ExpanderAssist.HorizontalHeaderPadding="5"
                              materialDesign:ExpanderAssist.ExpanderButtonPosition="Start"
                              HorizontalAlignment="Stretch"
                              Padding="5,0,5,5"
                              IsEnabled="{Binding CurrentTemplate, Converter={StaticResource NullableToBooleanConverter}}">

                        <StackPanel>
                            <TextBlock FontWeight="DemiBold"
                                       Text="{Tr ExportDialog.ExportSettingsCommon}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.UseLoginAsMafileName, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.UseLoginAsMafileName}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.UseLoginAsMafileName}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.IncludeSharedSecret, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.IncludeSharedSecret}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.IncludeSharedSecret}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.IncludeIdentitySecret, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.IncludeIdentitySecret}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.IncludeIdentitySecret}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.IncludeRCode, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.IncludeRCode}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.IncludeRCode}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.IncludeSessionData, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.IncludeSessionData}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.IncludeSessionData}" />

                            <CheckBox IsChecked="{Binding CurrentTemplate.IncludeOtherInfo, FallbackValue=False}"
                                      Margin="3,0,0,0"
                                      Content="{Tr ExportDialog.ExportOptions.IncludeOtherInfo}"
                                      ToolTipService.InitialShowDelay="200"
                                      ToolTip="{Tr ExportDialog.Tooltips.IncludeOtherInfo}" />

                            <TextBlock FontWeight="DemiBold"
                                       Margin="0,10,0,0"
                                       Text="{Tr ExportDialog.ExportSettingsNebula}" />

                            <Grid Margin="3,0,3,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <CheckBox Grid.Column="0"
                                          IsChecked="{Binding CurrentTemplate.IncludeNebulaProxy, FallbackValue=False}"
                                          Content="{Tr ExportDialog.ExportOptions.NebulaProxy}"
                                          ToolTipService.InitialShowDelay="200"
                                          ToolTip="{Tr ExportDialog.Tooltips.NebulaProxy}" />

                                <CheckBox Grid.Column="1"
                                          HorizontalAlignment="Center"
                                          IsChecked="{Binding CurrentTemplate.IncludeNebulaPassword, FallbackValue=False}"
                                          Content="{Tr ExportDialog.ExportOptions.NebulaPassword}"
                                          ToolTipService.InitialShowDelay="200"
                                          ToolTip="{Tr ExportDialog.Tooltips.NebulaPassword}" />

                                <CheckBox Grid.Column="2"
                                          HorizontalAlignment="Right"
                                          IsChecked="{Binding CurrentTemplate.IncludeNebulaGroup, FallbackValue=False}"
                                          Content="{Tr ExportDialog.ExportOptions.NebulaGroup}"
                                          ToolTipService.InitialShowDelay="200"
                                          ToolTip="{Tr ExportDialog.Tooltips.NebulaGroup}" />
                            </Grid>
                        </StackPanel>


                    </Expander>
                </Border>
                <TextBox GotFocus="ExportTB_GotFocus" PreviewMouseUp="ExportTB_GotFocus" Grid.Row="3"
                         Style="{StaticResource MaterialDesignOutlinedTextBox}" MaxHeight="600" Margin="0,10,0,0"
                         MinHeight="250" Height="250" AcceptsReturn="True"
                         Text="{Binding AccountsText, UpdateSourceTrigger=PropertyChanged}"
                         IsEnabled="{Binding ExportCommand.IsRunning, Converter={StaticResource ReverseBooleanConverter}}"
                         Name="AccountsTB" />


                <TextBlock Grid.Row="3"
                           Text="{Tr ExportDialog.ExportAccountsPlaceholder}"
                           Margin="18,27,10,10"
                           Opacity="0.6"
                           IsHitTestVisible="False"
                           TextWrapping="Wrap"
                           Visibility="{Binding Text.IsEmpty,
                     ElementName=AccountsTB,
                     Converter={StaticResource BooleanToVisibilityConverter}}" />
                <nebulaAuth:HintBox Margin="0,10,0,0" Severity="{Binding HintBoxSeverity}" Grid.Row="4"
                                    Text="{Binding HintText}" />


            </Grid>


        </Grid>
        <Separator Grid.Row="3" />
        <Button Command="{Binding ExportCommand}" Style="{StaticResource MaterialDesignFlatDarkBgButton}" Grid.Row="4"
                Margin="20,7,20,7" MaxWidth="150" Content="{Tr ExportDialog.ExportButton}" />
    </Grid>
</UserControl>