<UserControl x:Class="CtrEditor.ObjetosSim.ucPhotocell"
             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:CtrEditor.ObjetosSim.UserControls"
             xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
             mc:Ignorable="d">


    <UserControl.DataContext>
        <vm:osPhotocell Color="#FFCA1C1C" Ancho="0.8" Nombre="PTH" Alto="0.04" />
    </UserControl.DataContext>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                    Width="{Binding Alto, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=5}" />
            <!-- Columna para el Label -->
            <ColumnDefinition Width="Auto"/>
            <!-- Columna para la Image -->
            <ColumnDefinition Width="Auto"/>
            <!-- Columna para el Rectangle -->
        </Grid.ColumnDefinitions>

        <Grid.RenderTransform>
            <RotateTransform Angle="{Binding Angulo}" CenterX="0" CenterY="0"/>
        </Grid.RenderTransform>

        <!-- Label en la primera columna -->
        <Viewbox Grid.Column="0" Stretch="UniformToFill">
            <Label Content="{Binding Nombre}"                    
                   VerticalAlignment="Center" HorizontalAlignment="Center" Opacity="0.8" FontWeight="Bold" Foreground="{Binding Color}"/>
        </Viewbox>

        <Image Source="/Icons/fotocelula.png"
                Width="{Binding Alto, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=2}" 
           Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=2}" 
           VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2,2,2,2" Grid.Column="1"/>

        <Rectangle x:Name="Photocell" Grid.Column="2" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}, ConverterParameter=0.9}"
                Height="{Binding Ancho_Haz_De_Luz, Converter={StaticResource MeterToPixelConverter}}">
            <Rectangle.Fill>
                <VisualBrush x:Name="MovingPattern" TileMode="Tile" Viewport="0,0,3,3" ViewportUnits="Absolute" Viewbox="0,0,3,3" ViewboxUnits="Absolute">
                    <VisualBrush.Visual>
                        <Canvas>
                            <Ellipse
                                    Width="1"
                                    Height="1" Fill="{Binding Color}"/>
                        </Canvas>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
    </Grid>


</UserControl>