<styles:WindowChromeBase x:Class="_1RM.View.Editor.PasswordPopupDialogView"
                         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                         xmlns:styles="clr-namespace:Shawn.Utils.WpfResources.Theme.Styles;assembly=Shawn.Utils.WpfResources"
                         xmlns:attachProperty="clr-namespace:Shawn.Utils.WpfResources.Theme.AttachProperty;assembly=Shawn.Utils.WpfResources"
                         xmlns:editor="clr-namespace:_1RM.View.Editor"
                         xmlns:controls="clr-namespace:_1RM.Controls"
                         ShowInTaskbar="False"
                         ResizeMode="NoResize"
                         WindowStyle="None"
                         SizeToContent="Height"
                         WindowStartupLocation="CenterOwner"
                         Background="Transparent"
                         d:DesignHeight="400"
                         mc:Ignorable="d"
                         Topmost="True"
                         d:DataContext="{d:DesignInstance editor:PasswordPopupDialogViewModel}"
                         Title="PasswordPopupDialogView" Width="500">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="-1" />
    </WindowChrome.WindowChrome>
    <Window.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
            <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
            <Setter Property="MinWidth" Value="50"></Setter>
            <Setter Property="VerticalAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
            <Setter Property="TextAlignment" Value="Right"></Setter>
            <Setter Property="TextWrapping" Value="WrapWithOverflow"></Setter>
            <Setter Property="Margin" Value="10 10"></Setter>
        </Style>
    </Window.Resources>
    <Border Margin="50" Padding="30" Background="Transparent">
        <Border CornerRadius="10" Background="{DynamicResource PrimaryMidBrush}">
            <Border.Effect>
                <DropShadowEffect BlurRadius="10" />
            </Border.Effect>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" Height="35" VerticalAlignment="Top">
                    <TextBlock Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Text="{Binding Title}"></TextBlock>
                </Grid>

                <Button Grid.Row="0" Name="BtnQuit" Width="35" Height="35" VerticalAlignment="Top" HorizontalAlignment="Right"
                        Command="{Binding CmdQuit}"
                        Style="{StaticResource ButtonBarPrimaryStyle}"
                        attachProperty:VisionElement.BorderCornerRadius="10"
                        attachProperty:VisionElement.ForegroundAccent="White"
                        attachProperty:VisionElement.BackgroundAccent="Red"
                        attachProperty:VisionElement.ForegroundOnMouseDown="White"
                        attachProperty:VisionElement.BackgroundOnMouseDown="Red">
                    <Path Height="15" Width="15"
                          StrokeThickness="0.5" 
                          Stroke="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}"
                          Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Button}, Path=Foreground}"
                          Data="F1 M 47.910156 -44.000000 L 87.183594 -4.683594 L 83.316406 -0.816406 L 44.000000 -40.089844 L 4.683594 -0.816406 L 0.816406 -4.683594 L 40.089844 -44.000000 L 0.816406 -83.316406 L 4.683594 -87.183594 L 44.000000 -47.910156 L 83.316406 -87.183594 L 87.183594 -83.316406 Z "
                          Stretch="Uniform">
                    </Path>
                </Button>

                <Grid Grid.Row="1" Margin="10 5" VerticalAlignment="Center">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>


                    <TextBlock Grid.Row="1" Text="{DynamicResource User}"></TextBlock>
                    <TextBox Name="TbUserName"
                             Grid.Row="1" Grid.Column="1" 
                             Height="30" Margin="3 5 10 5" 
                             Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}"
                             KeyDown="TbUserName_OnKeyDown"></TextBox>


                    <TextBlock Grid.Row="2" Grid.Column="0" Text="{DynamicResource Password}"></TextBlock>


                    <controls:PasswordInput x:Name="TbPwd"
                                            Visibility="{Binding UsePrivateKeyForConnect, Converter={StaticResource ConverterBool2VisibleInv}}"
                                            Grid.Row="2" Grid.Column="1"
                                            Margin="3 5 10 5"
                                            Height="30" 
                                            KeyDown="TbPwd_OnKeyDown"
                                            Password="{Binding Password, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay }"
                    />


                    <Grid Grid.Row="2" Grid.Column="1" Margin="3 5 10 5"
                          Visibility="{Binding UsePrivateKeyForConnect, Converter={StaticResource ConverterBool2Visible}}"
                    >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBox Name="TbPrivateKey" Text="{Binding PrivateKey}" Height="30"></TextBox>
                        <Button Grid.Column="1"
                                Content="{DynamicResource Select}" 
                                Click="ButtonOpenPrivateKey_OnClick" 
                                Style="{StaticResource ButtonPrimaryStyle}"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Stretch">
                        </Button>
                    </Grid>

                    <CheckBox Grid.Row="3" Grid.Column="1" Margin="0 5 0 5"
                              Name="CbUsePrivateKeyForConnect"
                              Visibility="{Binding CanUsePrivateKeyForConnect, Converter={StaticResource ConverterBool2Visible}}"
                              IsChecked="{Binding UsePrivateKeyForConnect}"
                              Content="{DynamicResource 'Use private key'}">
                    </CheckBox>

                    <CheckBox Grid.Row="4" Grid.Column="1" Margin="0 5 0 5"
                              Name="CbRememberMe"
                              Visibility="{Binding CanRememberInfo, Converter={StaticResource ConverterBool2Visible}}"
                              IsChecked="{Binding IsRememberInfo}">
                        <TextBlock Text="{DynamicResource 'Remember the information above'}" TextAlignment="Left" TextWrapping="Wrap" Margin="0"></TextBlock>
                    </CheckBox>
                </Grid>

                <StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Height="35">
                    <Button Name="BtnSave" Command="{Binding CmdSave}" Padding="15 2" Content="{DynamicResource OK}"></Button>
                </StackPanel>
            </Grid>
        </Border>
    </Border>
</styles:WindowChromeBase>
