<UserControl x:Class="NebulaAuth.View.SettingsView"
             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"
             d:DesignHeight="650"
             FontFamily="{materialDesign:MaterialDesignFont}"
             MinHeight="400"
             MinWidth="480"
             MaxWidth="480"
             d:DataContext="{d:DesignInstance other:SettingsVM}"
             Background="Transparent"
             FontSize="15">
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <nebulaAuth:DialogHeader IconKind="Settings"
                                     Title="{Tr SettingsDialog.Title}"
                                     IsCloseEnabled="{Binding ApplyRenameSettingCommand.IsRunning, Converter={StaticResource ReverseBooleanConverter}, Mode=OneWay}" />

            <TabControl materialDesign:ColorZoneAssist.Background="{DynamicResource Base100Brush}"
                        Style="{StaticResource MaterialDesignUniformTabControl}" Grid.Row="1">
                <TabItem Header="{Tr SettingsDialog.MainSettings}">
                    <StackPanel Width="400" Margin="10,18,10,40" Orientation="Vertical" HorizontalAlignment="Center">
                        <ComboBox Style="{StaticResource MaterialDesignFloatingHintComboBox}" Margin="0,15,0,0"

                                  ItemsSource="{Binding Languages}" DisplayMemberPath="Value" SelectedValuePath="Key"
                                  SelectedValue="{Binding  Language}"
                                  materialDesign:HintAssist.Hint="{Tr LanguageWord}" />
                        <CheckBox Margin="0,5,0,0" IsChecked="{Binding HideToTray}"
                                  Content="{Tr SettingsDialog.MinimizeToTray}" />


                        <CheckBox Margin="0,5,0,0" IsChecked="{Binding ConfirmMafileImport}"
                                  Content="{Tr SettingsDialog.ConfirmMafileImport}"
                                  ToolTip="{Tr SettingsDialog.ConfirmMafileImportHint}" />
                        <!--<CheckBox IsEnabled="False"  Margin="0,10,0,0"  FontSize="16" IsChecked="{Binding AllowAutoUpdate}" Content="{Tr SettingsDialog.AllowAutoUpdate}"/>-->

                        <!--<CheckBox Margin="0,12,0,0"  IsChecked="{Binding UseAccountNameAsMafileName}">
                            <TextBlock TextWrapping="WrapWithOverflow" Text="{Tr SettingsDialog.UseAccountName}" />
                        </CheckBox>-->
                        <CheckBox Margin="0,5,0,0" IsChecked="{Binding UseIcon}"
                                  Content="{Tr SettingsDialog.UseIndicator}"
                                  ToolTip="{Tr SettingsDialog.UseIndicatorHint}" />
                        <materialDesign:ColorPicker Margin="-5,0,-5,0" IsEnabled="{Binding UseIcon}"
                                                    Color="{Binding IconColor, Delay=50}" />
                        <Grid Margin="0,10,0,10">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <PasswordBox MinWidth="250" materialDesign:PasswordBoxAssist.Password="{Binding Password}"
                                         Height="Auto" VerticalAlignment="Center"
                                         Style="{StaticResource MaterialDesignFloatingHintRevealPasswordBox}"
                                         materialDesign:HintAssist.Hint="{Tr SettingsDialog.PasswordBox.CurrentCryptPassword}"
                                         materialDesign:HintAssist.HelperText="{Tr SettingsDialog.PasswordBox.Hint}" />
                            <Button Command="{Binding SetPasswordCommand}" Margin="5,0,0,0" VerticalAlignment="Bottom"
                                    Grid.Column="1">
                                <materialDesign:PackIcon Kind="ContentSave" />
                            </Button>
                        </Grid>

                        <ComboBox materialDesign:HintAssist.Hint="{Tr SettingsDialog.MafileNamingMode}"
                                  Margin="0,25,0,0"
                                  Style="{StaticResource MaterialDesignFloatingHintComboBox}"
                                  SelectedItem="{Binding UseAccountNameAsMafileNamePreview}">
                            <ComboBox.ItemsSource>
                                <x:Array Type="{x:Type sys:Boolean}"
                                         xmlns:sys="clr-namespace:System;assembly=mscorlib">
                                    <sys:Boolean>True</sys:Boolean>
                                    <sys:Boolean>False</sys:Boolean>
                                </x:Array>

                            </ComboBox.ItemsSource>
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Converter={StaticResource BoolToMafileNamingConverter}}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <Button Margin="0,10,0,0"
                                materialDesign:ButtonProgressAssist.Maximum="1"
                                materialDesign:ButtonProgressAssist.Value="{Binding RenameMafilesProgress}"
                                materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding ApplyRenameSettingCommand.IsRunning}"
                                Style="{StaticResource MaterialDesignOutlinedButton}"
                                Command="{Binding ApplyRenameSettingCommand}"
                                Content="{Tr SettingsDialog.ApplyNamingMode}" />
                        <nebulaAuth:HintBox Margin="0,10,0,0" Text="{Binding RenameResultText}"
                                            FontSize="14"
                                            Visibility="{Binding RenameResultText, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}" />
                    </StackPanel>

                </TabItem>
                <TabItem TextElement.FontSize="13" IsEnabled="True" Header="{Tr SettingsDialog.ThemeSettings}">
                    <StackPanel Width="340" Margin="10,20,10,10" Orientation="Vertical" HorizontalAlignment="Center">
                        <ComboBox Style="{StaticResource MaterialDesignOutlinedComboBox}"
                                  Padding="8"
                                  Margin="0,15,0,0"
                                  FontSize="15"
                                  ItemsSource="{Binding ThemeTypes}" DisplayMemberPath="Value" SelectedValuePath="Key"
                                  SelectedValue="{Binding ThemeType}"
                                  materialDesign:HintAssist.Hint="{Tr SettingsDialog.Theme.CurrentTheme}" />

                        <ComboBox Style="{StaticResource MaterialDesignOutlinedComboBox}"
                                  Padding="8"
                                  Margin="0,15,0,0"
                                  FontSize="15"
                                  ItemsSource="{Binding BackgroundModes}" DisplayMemberPath="Value"
                                  SelectedValuePath="Key"
                                  SelectedValue="{Binding BackgroundMode}"
                                  materialDesign:HintAssist.Hint="{Tr SettingsDialog.BackgroundHint}" />

                        <TextBlock Text="{Tr SettingsDialog.Theme.BackgroundBlur}" Margin="0,15,0,0" />
                        <Slider materialDesign:SliderAssist.HideActiveTrack="True"

                                TickFrequency="5"
                                Minimum="0" Maximum="100" Value="{Binding BackgroundBlur, Mode=TwoWay}"
                                materialDesign:HintAssist.Hint="Blur Amount"
                                PreviewMouseDown="Slider_OnMouseDown"
                                PreviewMouseUp="Slider_OnMouseUp" />


                        <TextBlock Text="{Tr SettingsDialog.Theme.BackgroundOpacity}" Margin="0,15,0,0" />
                        <Slider materialDesign:SliderAssist.HideActiveTrack="True" Minimum="0" Maximum="1"
                                Value="{Binding BackgroundOpacity, Mode=TwoWay}"
                                materialDesign:HintAssist.Hint="Blur Amount"
                                PreviewMouseDown="Slider_OnMouseDown"
                                PreviewMouseUp="Slider_OnMouseUp" />

                        <!-- Gamma slider -->
                        <TextBlock Text="{Tr SettingsDialog.Theme.Gamma}" Margin="0,15,0,0" />
                        <Slider materialDesign:SliderAssist.HideActiveTrack="True" Minimum="0" Maximum="1"
                                Value="{Binding BackgroundGamma, Mode=TwoWay}"
                                materialDesign:HintAssist.Hint="Gamma/Smoke"
                                PreviewMouseDown="Slider_OnMouseDown"
                                PreviewMouseUp="Slider_OnMouseUp" />


                        <!-- Transparency sliders -->
                        <TextBlock Text="{Tr SettingsDialog.Theme.LeftOpacity}" Margin="0,15,0,0" />
                        <Slider materialDesign:SliderAssist.HideActiveTrack="True" Minimum="0" Maximum="1"
                                SmallChange="0.01"
                                Value="{Binding LeftOpacity, Mode=TwoWay}"
                                materialDesign:HintAssist.Hint="Left Transparency"
                                PreviewMouseDown="Slider_OnMouseDown"
                                PreviewMouseUp="Slider_OnMouseUp" />

                        <TextBlock Text="{Tr SettingsDialog.Theme.RightOpacity}" Margin="0,15,0,0" />

                        <Slider materialDesign:SliderAssist.HideActiveTrack="True" Minimum="0" Maximum="1"
                                SmallChange="0.01"
                                Value="{Binding RightOpacity, Mode=TwoWay}"
                                materialDesign:HintAssist.Hint="Right Transparency"
                                PreviewMouseDown="Slider_OnMouseDown"
                                PreviewMouseUp="Slider_OnMouseUp" />


                        <CheckBox Margin="0,0,0,0" Content="{Tr SettingsDialog.Theme.DialogBlur}"
                                  IsChecked="{Binding ApplyBlurBackground}"
                                  FontSize="15" />
                        <CheckBox Margin="0,0,0,0" Content="{Tr SettingsDialog.Theme.RippleDisabled}"
                                  FontSize="15"
                                  IsChecked="{Binding RippleDisabled}" />
                        <Button Margin="0,15,0,0" Command="{Binding ResetThemeDefaultsCommand}"
                                Content="{Tr SettingsDialog.Theme.Reset}" />
                    </StackPanel>
                </TabItem>
            </TabControl>
        </Grid>
    </Grid>
</UserControl>