<UserControl x:Class="SharepointToolbox.Views.Tabs.SettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:SharepointToolbox.Localization">
  <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
  <StackPanel Margin="16">
    <!-- Language -->
    <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.language]}" />
    <ComboBox Width="200" HorizontalAlignment="Left"
              SelectedValue="{Binding SelectedLanguage}"
              SelectedValuePath="Tag">
      <ComboBoxItem Tag="en"
                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.lang.en]}" />
      <ComboBoxItem Tag="fr"
                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.lang.fr]}" />
    </ComboBox>

    <Separator Margin="0,12" />

    <!-- Theme -->
    <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.theme]}" />
    <ComboBox Width="200" HorizontalAlignment="Left"
              SelectedValue="{Binding SelectedTheme}"
              SelectedValuePath="Tag">
      <ComboBoxItem Tag="System"
                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.theme.system]}" />
      <ComboBoxItem Tag="Light"
                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.theme.light]}" />
      <ComboBoxItem Tag="Dark"
                    Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.theme.dark]}" />
    </ComboBox>

    <Separator Margin="0,12" />

    <!-- Data folder -->
    <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.folder]}" />
    <DockPanel>
      <Button DockPanel.Dock="Right"
              Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.browse]}"
              Command="{Binding BrowseFolderCommand}" Width="80" Margin="8,0,0,0" />
      <TextBox Text="{Binding DataFolder, UpdateSourceTrigger=PropertyChanged}" />
    </DockPanel>

    <Separator Margin="0,12" />

    <!-- MSP Logo -->
    <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.logo.title]}" />
    <Border BorderBrush="{DynamicResource BorderSoftBrush}" BorderThickness="1" Padding="8" CornerRadius="4"
            HorizontalAlignment="Left" MinWidth="200" MinHeight="60" Margin="0,4,0,0">
      <Grid>
        <Image Source="{Binding MspLogoPreview, Converter={StaticResource Base64ToImageConverter}}"
               MaxHeight="80" MaxWidth="240" Stretch="Uniform" HorizontalAlignment="Left"
               Visibility="{Binding MspLogoPreview, Converter={StaticResource StringToVisibilityConverter}}" />
        <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.logo.nopreview]}"
                   VerticalAlignment="Center" HorizontalAlignment="Center"
                   Foreground="{DynamicResource TextMutedBrush}" FontStyle="Italic">
          <TextBlock.Style>
            <Style TargetType="TextBlock">
              <Setter Property="Visibility" Value="Visible" />
              <Style.Triggers>
                <DataTrigger Binding="{Binding MspLogoPreview, Converter={StaticResource StringToVisibilityConverter}}" Value="Visible">
                  <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
              </Style.Triggers>
            </Style>
          </TextBlock.Style>
        </TextBlock>
      </Grid>
    </Border>
    <StackPanel Orientation="Horizontal" Margin="0,6,0,0">
      <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.logo.browse]}"
              Command="{Binding BrowseMspLogoCommand}" Width="80" Margin="0,0,8,0" />
      <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.logo.clear]}"
              Command="{Binding ClearMspLogoCommand}" Width="80" />
    </StackPanel>
    <Separator Margin="0,12" />

    <!-- Auto-Take Ownership -->
    <Label Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.ownership.title]}" />
    <CheckBox IsChecked="{Binding AutoTakeOwnership}"
              Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.ownership.auto]}"
              Margin="0,4,0,0" />
    <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[settings.ownership.description]}"
               Foreground="{DynamicResource TextMutedBrush}" FontSize="11" TextWrapping="Wrap" Margin="20,4,0,0" />

    <TextBlock Text="{Binding StatusMessage}" Foreground="{DynamicResource DangerBrush}" FontSize="11" Margin="0,4,0,0"
               Visibility="{Binding StatusMessage, Converter={StaticResource StringToVisibilityConverter}}" />
  </StackPanel>
  </ScrollViewer>
</UserControl>
