<UserControl x:Class="TSManagementApp.Views.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:local="clr-namespace:TSManagementApp.Utils"
             xmlns:props="clr-namespace:TSManagementApp.Properties"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Background="White">
    <Grid>
        <Grid.Resources>
            <Style TargetType="TabControl">
                <Setter Property="BorderThickness" Value="0"/>
            </Style>
            <Style TargetType="TextBlock">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
            </Style>
            <Style TargetType="CheckBox">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Style>
            <Style TargetType="TextBlock" x:Key="InfoForTextBox">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="Width" Value="150"/>
                <Setter Property="TextAlignment" Value="Right"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
            </Style>
            <Style TargetType="TextBox" x:Key="BigWidth">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Width" Value="400"/>
                <Setter Property="Margin" Value="5,2.5"/>
            </Style>
            <Style TargetType="TextBox" x:Key="SmallWidth">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Width" Value="200"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
            </Style>
            <Style TargetType="PasswordBox">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Width" Value="200"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
            </Style>
            <Style TargetType="RadioButton">
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Style>
            <Style TargetType="Button" BasedOn="{StaticResource ButtonBlue}">

            </Style>
            <Style TargetType="TextBlock" x:Key="AuthTitle">
                <Setter Property="TextAlignment" Value="Center"/>
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="FontWeight" Value="DemiBold"/>
                <Setter Property="Foreground" Value="{StaticResource MyWhite}"/>
                <Setter Property="Background" Value="{StaticResource DarkBlue}"/>
                <Setter Property="Margin" Value="0,15"/>
            </Style>
            <Style TargetType="TextBlock" x:Key="Italics">
                <Setter Property="FontSize" Value="12"/>
                <Setter Property="TextWrapping" Value="Wrap"/>
                <Setter Property="Margin" Value="5,0"/>
                <Setter Property="FontStyle" Value="Italic"/>
            </Style>
            <Style TargetType="Border" x:Key="BorderSettings">
                <Setter Property="BorderBrush" Value="{StaticResource BorderGrayBorderBrush}"/>
                <Setter Property="BorderThickness" Value="1.5"/>
                <Setter Property="Margin" Value="5,2.5"/>
            </Style>
            <Style TargetType="ComboBox">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="Width" Value="400"/>
                <Setter Property="Margin" Value="5,2.5"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
            </Style>
        </Grid.Resources>
        <TabControl>
            <TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TabItem">
                                <Border Name="Border" BorderThickness="1,1,1,1" BorderBrush="Gainsboro" CornerRadius="4" Margin="2,0">
                                    <ContentPresenter x:Name="ContentSite"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Center"
                                        ContentSource="Header"
                                        TextBlock.FontSize="14"
                                        Margin="10,2"/>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="Border" Property="Background" Value="#3561a2" />
                                        <Setter TargetName="Border" Property="TextBlock.Foreground" Value="White"/>
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="False">
                                        <Setter TargetName="Border" Property="Background" Value="GhostWhite" />
                                    </Trigger>
                                    <MultiTrigger>
                                        <MultiTrigger.Conditions>
                                            <Condition Property="IsMouseOver" Value="True"/>
                                            <Condition Property="IsSelected" Value="False"/>
                                        </MultiTrigger.Conditions>
                                        <MultiTrigger.Setters>
                                            <Setter TargetName="Border" Property="Background" Value="#90bade"/>
                                        </MultiTrigger.Setters>
                                    </MultiTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>
            <TabItem Header="{x:Static props:Resources.SettingsV_Settings}" >
                <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                    <Grid>
                        <StackPanel>
                            <GroupBox Header="{x:Static props:Resources.SettingsV_InternetConn}">
                                <StackPanel>
                                    <RadioButton Content="{x:Static props:Resources.SettingsV_DefaultSettings}" GroupName="InternetConnection" IsChecked="{Binding IeSettingIsChecked, Mode=TwoWay}"/>
                                    <RadioButton Content="{x:Static props:Resources.SettingsV_ProxyServer}" GroupName="InternetConnection" IsChecked="{Binding ProxyIsChecked, Mode=TwoWay}"/>
                                    <StackPanel HorizontalAlignment="Center">
                                        <DockPanel>
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_ProxyPort}" Name="Widdest" Style="{StaticResource InfoForTextBox}"/>
                                            <TextBox Text="{Binding ProxyServer, Mode=TwoWay}" Style="{StaticResource BigWidth}"/>
                                        </DockPanel>
                                        <DockPanel>
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_GeneralUser}" Style="{StaticResource InfoForTextBox}"/>
                                            <TextBox Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource SmallWidth}"/>
                                        </DockPanel>
                                        <DockPanel>
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_GeneralPassword}" Style="{StaticResource InfoForTextBox}"/>
                                            <PasswordBox local:PasswordHelper.Password="{Binding Password, Mode=TwoWay}"/>
                                        </DockPanel>
                                    </StackPanel>
                                </StackPanel>
                            </GroupBox>
                            <DockPanel HorizontalAlignment="Center">
                                <Button Content="{x:Static props:Resources.SettingsV_ButtonSave}" Command="{Binding CommandSaveSettings}"/>
                                <Button Content="{x:Static props:Resources.SettingsV_ButtonHome}" Command="{Binding CommandGoUcAbout}"/>
                            </DockPanel>
                        </StackPanel>
                    </Grid>
                </ScrollViewer>
            </TabItem>
            <TabItem Header="{x:Static props:Resources.SettingsV_Tsa}" HorizontalAlignment="Left" Width="94">
                <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                    <Grid>
                        <StackPanel>
                            <TextBlock Text="{x:Static props:Resources.SettingsV_TsaTitle}" Style="{StaticResource AuthTitle}"/>
                            <GroupBox Header="{x:Static props:Resources.SettingsV_TsAuthority}">
                                <StackPanel>
                                    <DockPanel HorizontalAlignment="Center">
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_HashAlg}" Style="{StaticResource InfoForTextBox}"/>
                                        <ItemsControl ItemsSource="{Binding TsaShaAlogirthms}" Width="400" >
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Orientation="Horizontal"/>
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <RadioButton IsChecked="{Binding IsChecked}" Content="{Binding Name}" GroupName="TsaShaType"/>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </DockPanel>
                                    <DockPanel HorizontalAlignment="Center">
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_TsaOidPolicy}" Style="{StaticResource InfoForTextBox}"/>
                                        <StackPanel>
                                            <TextBox Text="{Binding TsaPolitics, Mode=TwoWay}" Style="{StaticResource BigWidth}"/>
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_Optional}" Style="{StaticResource Italics}"/>
                                        </StackPanel>
                                    </DockPanel>
                                    <DockPanel HorizontalAlignment="Center">
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_TsaServer}" Style="{StaticResource InfoForTextBox}"/>
                                        <StackPanel>
                                            <TextBox Text="{Binding TsaTSUrl, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource BigWidth}"/>
                                            <ComboBox ItemsSource="{Binding TsaTimeStampServers, Mode=OneWay}" SelectedItem="{Binding TsaSelectedTimeStampServer}" DisplayMemberPath="Name"
                                                      SelectedIndex="{Binding IndexOfTsaSelectedTimeStampServer}"/>
                                        </StackPanel>
                                    </DockPanel>
                                </StackPanel>
                            </GroupBox>
                            <Border Style="{StaticResource BorderSettings}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.4*"/>
                                        <ColumnDefinition Width="1"/>
                                        <ColumnDefinition Width="1*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid >
                                        <RadioButton Grid.Column="0"  Content="Žádná autentizace" VerticalAlignment="Center" GroupName="TsaAuth"
                                                 IsChecked="{Binding NoAuthIsChecked, Mode=TwoWay}"/>
                                    </Grid>
                                    <Rectangle Grid.Column="1" VerticalAlignment="Stretch" Width="1.5" Stroke="{StaticResource BorderGrayBorderBrush}"/>
                                    <StackPanel Grid.Column="2">
                                        <TextBlock Text="Žádnou autentizaci lze provést pouze u serverů časových autorit, které nejsou zpoplatněny."/>
                                    </StackPanel>
                                </Grid>
                            </Border>

                            <Border Style="{StaticResource BorderSettings}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.4*"/>
                                        <ColumnDefinition Width="1"/>
                                        <ColumnDefinition Width="1*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid >
                                        <RadioButton Grid.Column="0"  Content="{x:Static props:Resources.SettingsV_AuthCert}" VerticalAlignment="Center" GroupName="TsaAuth"
                                                 IsChecked="{Binding TsaAuthCertIsChecked, Mode=TwoWay}"/>
                                    </Grid>
                                    <Rectangle Grid.Column="1" VerticalAlignment="Stretch" Width="1.5" Stroke="{StaticResource BorderGrayBorderBrush}"/>
                                    <StackPanel Grid.Column="2">
                                        <TextBlock Text="{Binding TsaCertCn, Mode=TwoWay}"/>
                                        <DockPanel HorizontalAlignment="Left">
                                            <Button Content="{x:Static props:Resources.SettingsV_ButtonView}" Command="{Binding CommandTsaShowCertificate}"/>
                                            <Button Content="{x:Static props:Resources.SettingsV_ButtonChange}" Command="{Binding CommandTsaChooseCertificate}"/>
                                        </DockPanel>
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_AuthCertInfo}" Style="{StaticResource Italics}"/>
                                    </StackPanel>
                                </Grid>
                            </Border>
                            <Border Style="{StaticResource BorderSettings}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.4*"/>
                                        <ColumnDefinition Width="1"/>
                                        <ColumnDefinition Width="1*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid>
                                        <RadioButton Grid.Column="0"  Content="{x:Static props:Resources.SettingsV_AuthIp}" VerticalAlignment="Center" GroupName="TsaAuth"
                                                 IsChecked="{Binding TsaAuthIpIsChecked, Mode=TwoWay}"/>
                                    </Grid>
                                    <Rectangle Grid.Column="1" VerticalAlignment="Stretch" Width="1.5" Stroke="{StaticResource BorderGrayBorderBrush}"/>
                                    <StackPanel Grid.Column="2">
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_AuthIpInfo1}"/>
                                        <TextBlock Text="{x:Static props:Resources.SettingsV_AuthIpInfo2}"/>
                                        <TextBlock>
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_AuthIpInfo3}" Margin="0"/>
                                            <Hyperlink NavigateUri="http://whatismyipaddress.com/" RequestNavigate="Hyperlink_RequestNavigate">http://whatismyipaddress.com/</Hyperlink>
                                        </TextBlock>
                                    </StackPanel>
                                </Grid>
                            </Border>
                            <Border Style="{StaticResource BorderSettings}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.4*"/>
                                        <ColumnDefinition Width="1"/>
                                        <ColumnDefinition Width="1*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid>
                                        <RadioButton Grid.Column="0"  Content="{x:Static props:Resources.SettingsV_AuthLoginData}" VerticalAlignment="Center" GroupName="TsaAuth"
                                                 IsChecked="{Binding TsaAuthLoginDataIsChecked, Mode=TwoWay}"/>
                                    </Grid>
                                    <Rectangle Grid.Column="1" VerticalAlignment="Stretch" Width="1.5" Stroke="{StaticResource BorderGrayBorderBrush}"/>
                                    <StackPanel Grid.Column="2">
                                        <DockPanel HorizontalAlignment="Center">
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_AuthLoginName}" Style="{StaticResource InfoForTextBox}"/>
                                            <TextBox Text="{Binding TsaLoginName, Mode=TwoWay}" Style="{StaticResource SmallWidth}"/>
                                        </DockPanel>
                                        <DockPanel HorizontalAlignment="Center">
                                            <TextBlock Text="{x:Static props:Resources.SettingsV_AuthLoginPassword}" Style="{StaticResource InfoForTextBox}"/>
                                            <PasswordBox local:PasswordHelper.Password="{Binding TsaLoginPassword, Mode=TwoWay}"/>
                                        </DockPanel>
                                        <TextBlock Text="{x:Static props:Resources.SettigsV_AuthLoginInfo}" 
                                               Style="{StaticResource Italics}"/>
                                    </StackPanel>
                                </Grid>
                            </Border>
                            <DockPanel HorizontalAlignment="Center">
                                <Button Content="{x:Static props:Resources.SettingsV_ButtonSave}" Command="{Binding CommandSaveSettings}"/>
                                <Button Content="{x:Static props:Resources.SettingsV_ButtonHome}" Command="{Binding CommandGoUcAbout}"/>
                            </DockPanel>
                        </StackPanel>
                    </Grid>
                </ScrollViewer>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>
