<sync:ChromelessWindow
    x:Class="AppFramework.Views.LoginView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:b="clr-namespace:AppFramework.Behaviors"
    xmlns:const="clr-namespace:AppFramework.Common;assembly=AppFramework.Common"
    xmlns:converter="clr-namespace:AppFramework.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:extensions="clr-namespace:AppFramework.Extensions"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:sync="http://schemas.syncfusion.com/wpf"
    xmlns:win="clr-namespace:AppFramework.WindowHost"
    Width="940"
    Height="550"
    BorderBrush="Transparent"
    Icon="/Assets/Images/logo.ico"
    ResizeMode="NoResize"
    ShowMaximizeButton="False"
    TitleBarHeight="0"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <prism:Dialog.WindowStyle>
        <Style TargetType="Window">
            <Setter Property="Width" Value="780" />
            <Setter Property="Height" Value="450" />
            <Setter Property="SizeToContent" Value="WidthAndHeight" />
        </Style>
    </prism:Dialog.WindowStyle>
    <sync:ChromelessWindow.Resources>
        <converter:ImageConverter x:Key="imageConverter" />
    </sync:ChromelessWindow.Resources>

    <win:DialogHost Identifier="{x:Static const:AppCommonConsts.LoginIdentifier}">
        <sync:SfBusyIndicator
            AnimationType="DualRing"
            IsBusy="{Binding IsBusy}"
            ViewboxHeight="80"
            ViewboxWidth="80">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Border
                    x:Name="HeaderBorder"
                    Grid.ColumnSpan="2"
                    Margin="-1,0"
                    Opacity="0"
                    Style="{StaticResource HeaderBorderStyle}" />

                <Button
                    x:Name="btnClose"
                    Grid.Column="1"
                    Grid.ColumnSpan="2"
                    Margin="5"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Top"
                    Background="Transparent"
                    BorderThickness="0"
                    Content="&#xe63a;"
                    FontSize="24"
                    Style="{StaticResource IconButtonStyle}" />

                <Image
                    Grid.Row="1"
                    Margin="50"
                    Source="/Assets/Images/back.png" />

                <DockPanel
                    Grid.Row="1"
                    Grid.Column="1"
                    Margin="15"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center">
                    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
                        <TextBlock Text="{extensions:Translate CurrentTenant}" />
                        <TextBlock Text="{Binding CurrentTenancyNameOrDefault}" />
                        <TextBlock Text=" ( " />
                        <TextBlock>
                            <Hyperlink Foreground="AliceBlue">
                                <TextBlock Text="{extensions:Translate TenantSelection}" />
                            </Hyperlink>
                        </TextBlock>
                        <TextBlock Text=" )" />
                    </StackPanel>

                    <TextBlock
                        Margin="0,10,0,5"
                        DockPanel.Dock="Top"
                        FontSize="26"
                        FontWeight="Bold"
                        Text="{extensions:Translate LogIn}" />
                    <TextBox
                        Margin="0,12"
                        Padding="3"
                        DockPanel.Dock="Top"
                        FontSize="14"
                        Text="{Binding UserName}" />
                    <PasswordBox
                        Margin="0,12"
                        Padding="3"
                        b:PasswordExtensions.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        DockPanel.Dock="Top"
                        FontSize="14">
                        <i:Interaction.Behaviors>
                            <b:PasswordBehavior />
                        </i:Interaction.Behaviors>
                    </PasswordBox>

                    <CheckBox
                        Content="{extensions:Translate RememberMe}"
                        DockPanel.Dock="Top"
                        IsChecked="{Binding IsRememberMe}" />

                    <Button
                        Margin="0,10"
                        Padding="5"
                        Command="{Binding ExecuteCommand}"
                        CommandParameter="LoginUser"
                        Content="{extensions:Translate LogIn}"
                        DockPanel.Dock="Top"
                        FontSize="14"
                        IsEnabled="{Binding IsLoginEnabled}" />

                    <DockPanel DockPanel.Dock="Top">
                        <TextBlock
                            DockPanel.Dock="Right"
                            FontWeight="Bold"
                            Text="{extensions:Translate ForgotPassword}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseLeftButtonDown">
                                    <i:InvokeCommandAction Command="{Binding ExecuteCommand}" CommandParameter="ForgotPassword" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </TextBlock>

                        <TextBlock FontWeight="Bold" Text="{extensions:Translate EmailActivation}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MouseLeftButtonDown">
                                    <i:InvokeCommandAction Command="{Binding ExecuteCommand}" CommandParameter="EmailActivation" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </TextBlock>
                    </DockPanel>

                    <ItemsControl Margin="0,20,0,0" ItemsSource="{Binding Languages}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>

                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button
                                    Margin="2"
                                    Padding="2"
                                    Command="{Binding DataContext.ChangeLanguageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"
                                    CommandParameter="{Binding}"
                                    ToolTip="{Binding DisplayName}">
                                    <Image
                                        Width="20"
                                        Height="20"
                                        Source="{Binding Icon, Converter={StaticResource imageConverter}}" />
                                </Button>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </DockPanel>
            </Grid>
        </sync:SfBusyIndicator>
    </win:DialogHost>
</sync:ChromelessWindow>