<UserControl
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    d:DataContext="{d:DesignInstance Type=viewModels:RefreshBadgeViewModel,
                                     IsDesignTimeCreatable=True}"
    d:DesignHeight="150"
    d:DesignWidth="150"
    mc:Ignorable="d"
    ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
    ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
    x:Class="StabilityMatrix.Controls.RefreshBadge"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:converters="clr-namespace:StabilityMatrix.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:StabilityMatrix.Controls"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
    xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <converters:ValueConverterGroup x:Key="InvertAndVisibleOrHidden">
            <converters:BoolNegationConverter />
            <converters:BooleanToHiddenVisibleConverter />
        </converters:ValueConverterGroup>
    </UserControl.Resources>

    <Grid>
        <ui:Button
            Appearance="Transparent"
            BorderThickness="0"
            Command="{Binding RefreshCommand}"
            FontSize="26"
            Foreground="{Binding ColorBrush}"
            HorizontalAlignment="Center"
            Icon="{Binding Icon, FallbackValue=CheckmarkCircle12}"
            Margin="4"
            Padding="2"
            ToolTip="{Binding CurrentToolTip}"
            VerticalAlignment="Center"
            Visibility="{Binding IsWorking, Converter={StaticResource InvertAndVisibleOrHidden}}" />
        <ui:ProgressRing
            FontSize="14"
            Grid.Row="0"
            Height="20"
            HorizontalAlignment="Center"
            IsEnabled="{Binding IsWorking, Converter={StaticResource BoolToVisibilityConverter}}"
            IsIndeterminate="{Binding IsWorking}"
            ToolTip="{Binding CurrentToolTip}"
            VerticalAlignment="Center"
            Visibility="{Binding IsWorking, Converter={StaticResource BoolToVisibilityConverter}}"
            Width="20" />
    </Grid>

</UserControl>
