<styles:WindowChromeBase x:Class="_1RM.View.Editor.Forms.AlternativeCredential.AlternativeCredentialEditView"
                         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:styles="clr-namespace:Shawn.Utils.WpfResources.Theme.Styles;assembly=Shawn.Utils.WpfResources"
                         xmlns:s="https://github.com/canton7/Stylet"
                         xmlns:alternativeCredential="clr-namespace:_1RM.View.Editor.Forms.AlternativeCredential"
                         xmlns:controls="clr-namespace:_1RM.Controls"
                         mc:Ignorable="d" 
                         ShowInTaskbar="False"
                         SizeToContent="WidthAndHeight" 
                         WindowStyle="None"
                         Background="Transparent"
                         MaxWidth="1800"
                         AllowsTransparency="True"
                         d:DataContext="{d:DesignInstance alternativeCredential:AlternativeCredentialEditViewModel}">
    <Window.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="TextWrapping" Value="Wrap"></Setter>
            <Setter Property="Margin" Value="15 0 0 0"></Setter>
            <Setter Property="Width" Value="100"></Setter>
        </Style>
        <Style TargetType="TextBox" BasedOn="{StaticResource TextBoxAccentStyle}">
            <Setter Property="Height" Value="26"></Setter>
        </Style>
        <Style TargetType="PasswordBox" BasedOn="{StaticResource PasswordBoxAccentStyle}">
            <Setter Property="Height" Value="26"></Setter>
        </Style>
        <Style TargetType="CheckBox" BasedOn="{StaticResource CheckBoxAccentStyle}">
            <Setter Property="Margin" Value="10 0 0 0"></Setter>
        </Style>
        <Style x:Key="ErrorTip" TargetType="TextBlock"  BasedOn="{StaticResource TextBlockBase}">
            <Setter Property="TextWrapping" Value="WrapWithOverflow"></Setter>
            <Setter Property="Margin" Value="0 3 0 0"></Setter>
            <Setter Property="Foreground" Value="Red"></Setter>
            <!--<Setter Property="MinHeight" Value="0"></Setter>-->
        </Style>
    </Window.Resources>

    <Border Background="{DynamicResource PrimaryMidBrush}"
            BorderBrush="{DynamicResource PrimaryLightBrush}"
            BorderThickness="1" 
            CornerRadius="{StaticResource DefaultCornerRadius}" 
            ClipToBounds="True">
        <Grid IsSharedSizeScope="True">

            <StackPanel Margin="20 0">
                <TextBlock Text="{DynamicResource 'Connection Info'}" Margin="15" FontSize="{DynamicResource GlobalFontSizeSubtitle}" MinHeight="30" HorizontalAlignment="Left" Width="Auto"></TextBlock>

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" Text="{DynamicResource Name}"></TextBlock>
                        <Grid Grid.Row="0" Grid.Column="1">
                            <TextBox Name="TbName" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 />
                        </Grid>
                    </Grid>


                    <Grid Grid.Row="1">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{DynamicResource Hostname}"></TextBlock>
                        <TextBox Grid.Column="1" Text="{Binding New.Address, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 Tag="{DynamicResource 'Leave blank to inherit the default value'}"/>
                    </Grid>


                    <Grid Grid.Row="2">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{DynamicResource Port}"></TextBlock>
                        <TextBox Grid.Column="1" Text="{Binding Port, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 InputMethod.IsInputMethodEnabled="False" InputScope="Number"
                                 Tag="{DynamicResource 'Leave blank to inherit the default value'}"></TextBox>
                    </Grid>


                    <Grid Grid.Row="3">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{DynamicResource User}" 
                                   Visibility="{Binding ShowUsername, Converter={StaticResource ConverterBool2Visible}}"></TextBlock>
                        <TextBox Grid.Column="1" Text="{Binding New.UserName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                 Visibility="{Binding ShowUsername, Converter={StaticResource ConverterBool2Visible}}"
                                 Tag="{DynamicResource 'Leave blank to inherit the default value'}"/>
                    </Grid>


                    <Grid Grid.Row="4">
                        <Grid.Style>
                            <Style TargetType="Grid">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsUsePrivateKey}" Value="True">
                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ShowPassword}" Value="False">
                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Style>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{DynamicResource Password}"></TextBlock>
                        <controls:PasswordInput Grid.Row="0" Grid.Column="1" 
                                                x:Name="TbPassword" Height="26"
                                                Tag="{DynamicResource 'Leave blank to inherit the default value'}"
                                                Password="{Binding New.Password, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"/>


                        <CheckBox Grid.Row="0" Grid.Column="2" IsChecked="{Binding IsUsePrivateKey}" 
                                  Visibility="{Binding ShowPrivateKeyPath, Converter={StaticResource ConverterBool2Visible}}"
                                  Content="{DynamicResource 'Use private key'}" ></CheckBox>
                    </Grid>


                    <Grid Grid.Row="4">
                        <Grid.Style>
                            <Style TargetType="Grid">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsUsePrivateKey}" Value="False">
                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding ShowPrivateKeyPath}" Value="False">
                                        <Setter Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Style>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition MinHeight="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="A" ></ColumnDefinition>
                            <ColumnDefinition Width="280" SharedSizeGroup="B"></ColumnDefinition>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="C"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{DynamicResource 'Private key'}"></TextBlock>
                        <Grid Grid.Row="0" Grid.Column="1">
                            <TextBox Name="TbPrivateKey" HorizontalAlignment="Left"
                                     Text="{Binding PrivateKeyPath, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
                                     Width="280"
                                     Tag="{DynamicResource 'Leave blank to inherit the default value'}"></TextBox>
                            <Button Content="{DynamicResource Select}" HorizontalAlignment="Right" Click="{s:Action ButtonOpenPrivateKey_OnClick}"></Button>
                        </Grid>
                        <CheckBox Grid.Row="0" Grid.Column="2" IsChecked="{Binding IsUsePrivateKey}" 
                                  Visibility="{Binding ShowPrivateKeyPath, Converter={StaticResource ConverterBool2Visible}}"
                                  Content="{DynamicResource 'Use private key'}" ></CheckBox>
                    </Grid>
                </Grid>


                <StackPanel Margin="0 0 0 20" Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button Command="{Binding CmdSave}" Content="{DynamicResource Save}" MinWidth="100" Margin="10 0"></Button>
                    <Button Command="{Binding CmdCancel}" Content="{DynamicResource Cancel}" MinWidth="100" Margin="10 0"></Button>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Border>
</styles:WindowChromeBase>
