<UserControl
    x:Class="PowerRenameUI.ExplorerItem"
    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:local="using:PowerRenameUI"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Height="28" Padding="0,0,0,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="4" />
            <!--  Some spacing in between  -->
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <!--  Error tooltip  -->
        </Grid.ColumnDefinitions>

        <Border
            Name="HighlightBorder"
            Grid.ColumnSpan="4"
            Margin="0,0,0,-1"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Background="Transparent" />

        <Grid
            Grid.Column="0"
            Margin="10,4,0,4"
            HorizontalAlignment="Left">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="{x:Bind Indentation}" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>


            <CheckBox
                Name="{x:Bind IdStr}"
                Grid.Column="1"
                Width="28"
                Height="28"
                MinWidth="0"
                AutomationProperties.HelpText="{x:Bind Renamed}"
                AutomationProperties.Name="{x:Bind Original}"
                Content=""
                IsChecked="{x:Bind Checked, Mode=TwoWay}"
                IsTabStop="True"
                Style="{StaticResource CheckBoxDefaultStyleOverride}"
                TabIndex="0"
                XYFocusKeyboardNavigation="Enabled" />

            <Image
                Grid.Column="2"
                Width="16"
                Margin="4,0,0,0"
                HorizontalAlignment="Left"
                Source="{x:Bind ImagePath}" />
            <TextBlock
                Grid.Column="3"
                Margin="6,0,4,0"
                VerticalAlignment="Center"
                FontSize="12"
                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                Text="{x:Bind Original, Mode=OneWay}"
                TextTrimming="CharacterEllipsis" />
        </Grid>
        <TextBlock
            Grid.Column="2"
            Margin="0,0,4,0"
            VerticalAlignment="Center"
            FontSize="12"
            FontWeight="SemiBold"
            Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
            Text="{x:Bind Renamed, Mode=OneWay}"
            TextTrimming="CharacterEllipsis" />

        <Border
            x:Name="ErrorIcon"
            Grid.Column="3"
            Width="12"
            Height="12"
            Margin="4,0,8,0"
            Background="{ThemeResource SystemFillColorCriticalBrush}"
            CornerRadius="12"
            Visibility="Collapsed">
            <TextBlock
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontFamily="{ThemeResource SymbolThemeFontFamily}"
                FontSize="8"
                Foreground="White"
                Text="&#xE10A;" />
            <ToolTipService.ToolTip>
                <TextBlock
                    x:Name="ErrorMessageTxt"
                    Text="Error message goes here"
                    TextWrapping="Wrap" />
            </ToolTipService.ToolTip>
        </Border>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal" />
                <VisualState x:Name="Highlight">
                    <VisualState.Setters>
                        <Setter Target="HighlightBorder.Opacity" Value="0.1" />
                        <Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                        <Setter Target="HighlightBorder.Background" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Error">
                    <VisualState.Setters>
                        <Setter Target="HighlightBorder.Opacity" Value="1" />
                        <Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
                        <Setter Target="HighlightBorder.Background" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
                        <Setter Target="ErrorIcon.Visibility" Value="Visible" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</UserControl>
