<UserControl x:Class="FasdDesktopUi.Basics.UserControls.CustomMenuItem"
             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:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
             xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
             xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
             Name="CustomMenuItemUc"
             mc:Ignorable="d"
             d:DesignHeight="45"
             d:DesignWidth="350" Initialized="CustomMenuItemUc_Initialized">

    <UserControl.Resources>
        <vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
    </UserControl.Resources>

    <Border x:Name="MenuItemBorder"
            Style="{DynamicResource Menu.MainCategory}"
            MouseLeftButtonUp="MenuItemBorder_Click"
            TouchDown="MenuItemBorder_Click"
            MouseEnter="MenuItemBorder_MouseEnter"
            MouseLeave="MenuItemBorder_MouseLeave">

        <Grid x:Name="MenuItemContent">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <ico:AdaptableIcon x:Name="MenuItemIcon"
                               Grid.Column="0" />

            <ico:AdaptableIcon x:Name="MenuItemOverlayIcon"
                               Grid.Column="0"
                               BorderPadding="10 10 0 0"
                               Margin="0 0 -5 -5"/>

            <StackPanel Grid.Column="1"
                        Margin="15 0 15 0"
                        VerticalAlignment="Center"
                        IsHitTestVisible="False">
                <Border x:Name="CustomTextBlockBorder"
                        ClipToBounds="True">
                    <Grid x:Name="CustomTextGrid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock x:Name="CustomTextBlock"
                                   Grid.Column="0"
                                   TextTrimming="CharacterEllipsis" />
                        <TextBlock x:Name="CustomTrailingTextBlock"
                                   Grid.Column="1"
                                   Margin="10 0 0 0"
                                   TextTrimming="CharacterEllipsis"
                                   HorizontalAlignment="Right"
                                   TextAlignment="Right"
                                   Visibility="Collapsed" />
                    </Grid>
                </Border>

                <Border x:Name="CustomTextBlockBorderBottom"
                        ClipToBounds="True"
                        Visibility="Collapsed">
                    <TextBlock x:Name="CustomTextBlockBottom"
                               TextTrimming="CharacterEllipsis"
                               FontWeight="UltraLight" />
                </Border>
            </StackPanel>

            <Border x:Name="SubMenuCounterBorder"
                    Grid.Column="2"
                    Height="15"
                    Width="15"
                    Margin="-15 0 0 0"
                    Background="{DynamicResource Color.FunctionMarker}"
                    CornerRadius="15"
                    Visibility="Collapsed">
                <TextBlock x:Name="SubMenuCounterTextBlock"
                           HorizontalAlignment="Center" VerticalAlignment="Center"
                           Margin="0"
                           FontSize="9"
                           Padding="0,0,0,1"
                           Foreground="White" />
            </Border>

            <ico:AdaptableIcon x:Name="LoadingIcon"
                               Grid.Column="2"
                               Style="{x:Null}"
                               Visibility="Collapsed"
                               SelectedInternGif="loadingSpinner" />

            <Grid x:Name="SearchRelationGrid"
                  Visibility="Collapsed"
                  Grid.Column="2"
                  VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition SharedSizeGroup="SearchResultDetails" />
                </Grid.ColumnDefinitions>

                <TextBlock x:Name="LastSeenTextBox"
                           Grid.Row="0"
                           Grid.Column="0"
                           FontSize="10"
                           Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Searchbar.LastSeen}" />

                <TextBlock x:Name="LessThanTextBlock"
                           Margin="5 0 5 0"
                           Grid.Row="0"
                           Grid.Column="1"
                           FontSize="10"
                           HorizontalAlignment="Right" />

                <TextBlock x:Name="ActivityTextBlock"
                           Grid.Column="0"
                           Grid.Row="1"
                           FontSize="10"
                           Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Searchbar.Activity}" />

                <Border x:Name="ActivityIndicator"
                        Grid.Row="1"
                        Grid.Column="1"
                        Margin="5 0 5 0"
                        CornerRadius="1.5"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center"
                        Height="5"
                        Width="40"
                        Background="{DynamicResource Color.FunctionMarker}" />
            </Grid>

        </Grid>

    </Border>

</UserControl>
