<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
             xmlns:layoutFinder="clr-namespace:Artemis.UI.Screens.Workshop.LayoutFinder"
             xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
             xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia.ProgressRing"
             mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="55"
             x:Class="Artemis.UI.Screens.Workshop.LayoutFinder.LayoutFinderDeviceView"
             x:DataType="layoutFinder:LayoutFinderDeviceViewModel">
    <Grid RowDefinitions="Auto,Auto" ColumnDefinitions="55,*,Auto">
        <Border Grid.Column="0" Grid.RowSpan="2" Width="50" Height="50" Margin="5 0 10 5" IsVisible="{CompiledBinding HasLayout}" >
            <shared:DeviceVisualizer Device="{CompiledBinding Device}" 
                                     VerticalAlignment="Center"
                                     HorizontalAlignment="Center"
                                     RenderOptions.BitmapInterpolationMode="MediumQuality"/>
        </Border>
        <avalonia:MaterialIcon Grid.Column="0"
                               Grid.Row="0" 
                               Grid.RowSpan="2" 
                               IsVisible="{CompiledBinding !HasLayout}" 
                               Kind="{CompiledBinding DeviceIcon}" 
                               Width="50" 
                               Height="40"
                               Margin="5 5 10 10"
                               HorizontalAlignment="Center" 
                               VerticalAlignment="Center"/>
        
        <TextBlock Grid.Column="1" Grid.Row="0" Text="{CompiledBinding Device.RgbDevice.DeviceInfo.Model}" VerticalAlignment="Bottom" />
        <TextBlock Grid.Column="1" Grid.Row="1" Classes="subtitle" VerticalAlignment="Top">
            <Run Text="{CompiledBinding Device.RgbDevice.DeviceInfo.Manufacturer}"></Run>
            <Run>-</Run>
            <Run Text="{CompiledBinding Device.RgbDevice.DeviceInfo.DeviceType}"></Run>
        </TextBlock>

        <Panel Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" IsVisible="{CompiledBinding !HasLayout}">
            <controls:ProgressRing IsVisible="{CompiledBinding Searching}"
                                   IsIndeterminate="True"
                                   BorderThickness="2" 
                                   Width="25"
                                   Height="25"
                                   PreserveAspect="False"
                                   Margin="0 0 0 0" 
                                   VerticalAlignment="Center"/>
            <Panel IsVisible="{CompiledBinding !Searching}">
                <avalonia:MaterialIcon IsVisible="{CompiledBinding Entry, Converter={x:Static ObjectConverters.IsNull}}"
                                       Width="28" 
                                       Height="28" 
                                       Kind="MultiplyCircle"
                                       Foreground="#D64848"
                                       ToolTip.Tip="No layout found"/>
                <avalonia:MaterialIcon IsVisible="{CompiledBinding Entry, Converter={x:Static ObjectConverters.IsNotNull}}"
                                       Width="28" 
                                       Height="28" 
                                       Kind="CloudCheck"
                                       Foreground="{DynamicResource SystemAccentColorLight1}"
                                       ToolTip.Tip="Layout found and installed"/>
            </Panel>
        </Panel>
       
        <avalonia:MaterialIcon Grid.Column="2"
                               Grid.Row="0"
                               Grid.RowSpan="2"
                               IsVisible="{CompiledBinding HasLayout}"
                               Width="28" 
                               Height="28" 
                               Kind="CheckCircle"
                               Foreground="{DynamicResource SystemAccentColorLight1}"
                               ToolTip.Tip="Using existing layout"/>
      
    </Grid>
</UserControl>
