<UserControl x:Class="Artemis.UI.Shared.ArtemisIcon"
             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:system="clr-namespace:System;assembly=System.Runtime"
             xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <ContentControl Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Icon}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Focusable="False">
        <ContentControl.Resources>
            <DataTemplate DataType="{x:Type system:Uri}">
                <Rectangle Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Foreground}">
                    <Rectangle.OpacityMask>
                        <VisualBrush Stretch="Uniform">
                            <VisualBrush.Visual>
                                <Image Source="{Binding Converter={svgc:SvgImageConverter}, Mode=OneWay}"/>
                            </VisualBrush.Visual>
                        </VisualBrush>
                    </Rectangle.OpacityMask>
                </Rectangle>
            </DataTemplate>
            <DataTemplate DataType="{x:Type materialDesign:PackIconKind}">
                <materialDesign:PackIcon Kind="{Binding}" Width="Auto" Height="Auto"/>
            </DataTemplate>
        </ContentControl.Resources>
    </ContentControl>
</UserControl>
