<UserControl
    x:Class="Translumo.MVVM.Views.LanguagesSettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:controls="clr-namespace:Translumo.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:translation="clr-namespace:Translumo.Translation;assembly=Translumo.Translation"
    xmlns:tts="clr-namespace:Translumo.TTS;assembly=Translumo.TTS"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ObjectDataProvider
            x:Key="dataFromEnum"
            MethodName="GetValues"
            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="translation:Translators" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <ObjectDataProvider
            x:Key="ttsSystems"
            MethodName="GetValues"
            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="tts:TTSEngines" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>

        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="475" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="0">
            <StackPanel.Resources>
                <Style TargetType="{x:Type StackPanel}">
                    <Setter Property="Margin" Value="0,0,0,20" />
                </Style>
            </StackPanel.Resources>
            <StackPanel Orientation="Horizontal">
                <ComboBox
                    DisplayMemberPath="DisplayName"
                    FontSize="14"
                    ItemsSource="{Binding Path=AvailableLanguages}"
                    SelectedValue="{Binding Path=TranslateFromLang}"
                    SelectedValuePath="LanguageDescriptor.Language"
                    Style="{StaticResource ComboBoxBase}" />
                <Label
                    Margin="10,0,0,0"
                    Content="{DynamicResource Str.LangSettings.SourceLang}"
                    Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <ComboBox
                    DisplayMemberPath="DisplayName"
                    FontSize="14"
                    ItemsSource="{Binding Path=AvailableTranslationLanguages}"
                    MaxDropDownHeight="300"
                    SelectedValue="{Binding Path=TranslateToLang}"
                    SelectedValuePath="LanguageDescriptor.Language"
                    Style="{StaticResource ComboBoxBase}" />
                <Label
                    Margin="10,0,0,0"
                    Content="{DynamicResource Str.LangSettings.TranslationLang}"
                    Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <ComboBox
                    Width="130"
                    FontSize="14"
                    ItemsSource="{Binding Source={StaticResource dataFromEnum}}"
                    SelectedItem="{Binding Path=Model.Translator}"
                    Style="{DynamicResource MaterialDesignComboBox}" />
                <Label
                    Margin="10,0,0,0"
                    HorizontalAlignment="Stretch"
                    Content="{DynamicResource Str.LangSettings.Translator}"
                    Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <ComboBox
                    Width="130"
                    FontSize="14"
                    ItemsSource="{Binding Source={StaticResource ttsSystems}}"
                    SelectedItem="{Binding Path=TtsSystem}"
                    Style="{DynamicResource MaterialDesignComboBox}" />
                <Label
                    Margin="10,0,0,0"
                    HorizontalAlignment="Stretch"
                    Content="{DynamicResource Str.LangSettings.TtsSystem}"
                    Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" Visibility="{Binding IsTtsWindowsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
                <ComboBox 
                    ItemsSource="{Binding AvailableVoices}"
                    SelectedItem="{Binding SelectedVoice, Mode=TwoWay}"
                    DisplayMemberPath="Name"
                    Width="130"
                    FontSize="14"
                    Style="{DynamicResource MaterialDesignComboBox}"/>
                <Label
                    Margin="10,0,0,0"
                    HorizontalAlignment="Stretch"
                    Content="Voices"
                    Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <GroupBox Margin="0,20,0,0" Style="{StaticResource MaterialDesignGroupBox}">
                <GroupBox.Header>
                    <Label
                        Margin="0,-7,0,-7"
                        Content="{DynamicResource Str.ProxySettings.Proxy}"
                        Style="{StaticResource SecondaryHeaderLabel}" />
                </GroupBox.Header>
                <StackPanel>
                    <TextBlock
                        FontSize="12"
                        Style="{StaticResource TextBlockBase}"
                        Text="{DynamicResource Str.ProxySettings.Note}"
                        TextWrapping="WrapWithOverflow" />
                    <Button
                        Margin="0,5,0,0"
                        HorizontalAlignment="Left"
                        Command="{Binding ProxySettingsClickedCommand}"
                        Content="{DynamicResource Str.Button.SettingProxy}"
                        Style="{StaticResource PrimaryButton}" />
                </StackPanel>
            </GroupBox>
        </StackPanel>
        <DockPanel
            Grid.Row="0"
            Grid.Column="1"
            Margin="9,0,0,0"
            Visibility="{Binding ProxySettingsIsOpened, Converter={StaticResource BooleanToVisibilityConverter}}">
            <controls:ProxyEditList
                x:Name="ProxyListControl"
                Padding="9,0,0,0"
                HorizontalAlignment="Stretch"
                AddCommand="{Binding ProxyItemAddCommand}"
                BorderBrush="{StaticResource PrimaryHueMidBrush}"
                BorderThickness="1,0,0,0"
                DeleteCommand="{Binding ProxyItemDeletedCommand}"
                SourceList="{Binding Path=ProxyCollection, Mode=TwoWay}"
                SubmitCommand="{Binding ProxySettingsSubmitCommand}"
                UseLayoutRounding="False" />
        </DockPanel>
    </Grid>
</UserControl>