<UserControl x:Class="NebulaAuth.View.LinkerView"
             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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:linker="clr-namespace:NebulaAuth.ViewModel.Linker"
             xmlns:nebulaAuth="clr-namespace:NebulaAuth"
             mc:Ignorable="d"
             TextElement.Foreground="{DynamicResource BaseContentBrush}"
             FontFamily="{materialDesign:MaterialDesignFont}"
             MinWidth="400"
             MaxWidth="400"
             Background="{DynamicResource WindowBackground}"
             d:DataContext="{d:DesignInstance linker:LinkAccountVM}"
             FontSize="18">
    <UserControl.InputBindings>
        <KeyBinding Key="Enter"
                    Command="{Binding CurrentStep.NextCommand}" />
    </UserControl.InputBindings>
    <d:DesignerProperties.DesignStyle>
        <Style TargetType="UserControl">
            <Setter Property="Background" Value="{DynamicResource WindowBackground}" />
        </Style>
    </d:DesignerProperties.DesignStyle>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style TargetType="materialDesign:PackIcon">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=StackPanel}, Path=Tag}"
                                 Value="False">
                        <Setter Property="Foreground" Value="IndianRed" />
                        <Setter Property="Kind" Value="CheckBoxOutlineBlank" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=StackPanel}, Path=Tag}"
                                 Value="True">
                        <Setter Property="Foreground" Value="Green" />
                        <Setter Property="Kind" Value="CheckBoxOutline" />
                    </DataTrigger>
                </Style.Triggers>

            </Style>
            <Style TargetType="TextBlock">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=StackPanel}, Path=Tag}"
                                 Value="True">
                        <Setter Property="Foreground" Value="Gray" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
        <Grid Margin="10,10,10,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Kind="LinkBoxOutline" Width="20" Height="20" Margin="0,0,5,0"
                                         VerticalAlignment="Center"
                                         Foreground="{DynamicResource PrimaryContentBrush}" />
                <TextBlock FontStyle="Normal" Foreground="{DynamicResource BaseContentBrush}"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center" FontSize="18" Text="{Tr LinkerDialog.Title}" />
                <TextBlock Margin="5,0,0,0" VerticalAlignment="Center" FontSize="12">
                    <Hyperlink Command="{Binding OpenTroubleshootingCommand}">
                        <Run Text="{Tr LinkerDialog.GotErrorHyperlinkText, IsDynamic=False}" />
                    </Hyperlink>
                </TextBlock>
            </StackPanel>
            <Button Grid.Column="1" Width="30" Height="30" Style="{StaticResource MaterialDesignIconForegroundButton}"
                    HorizontalAlignment="Right" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}">
                <materialDesign:PackIcon Kind="Close" Width="24" Height="24" Foreground="IndianRed" />
            </Button>
        </Grid>
        <Separator Background="DarkGray" Opacity="0.4" Grid.Row="1" />
        <nebulaAuth:HintBox FontSize="14"
                            Visibility="{Binding Tip, Converter={StaticResource NullableToVisibilityConverter}}"
                            Grid.Row="2" Margin="10,10,10,0"
                            Text="{Binding Tip}" MaxWidth="330" />
        <ContentControl
            Grid.Row="3" Margin="20"
            d:DataContext="{d:DesignInstance Type=linker:DesignLinkAccountAuthStepVM, IsDesignTimeCreatable=True}"
            Content="{Binding CurrentStep}" />

        <nebulaAuth:HintBox FontSize="14"
                            Visibility="{Binding Error, Converter={StaticResource NullableToVisibilityConverter}}"
                            Grid.Row="4" Margin="10,0,10,10"
                            Severity="Error"
                            Text="{Binding Error}" />

    </Grid>
</UserControl>