<UserControl x:Class="CtrEditor.Controls.PanelEdicionControl"
             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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim"
             xmlns:ObjetosExtraccion="clr-namespace:CtrEditor.ObjetosSim.Extraccion_Datos"
             mc:Ignorable="d">
    
    <xctk:PropertyGrid x:Name="PropertyGridControl" 
                       Margin="5" 
                       AutoGenerateProperties="False"
                       ShowDescriptionByTooltip="True"
                       FocusManager.IsFocusScope="True">
        <xctk:PropertyGrid.EditorDefinitions>
            <!-- String -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type sys:String}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <TextBox Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                                Text="{Binding Value, UpdateSourceTrigger=LostFocus}" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- Float -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type sys:Single}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <xctk:SingleUpDown Increment="0.01"
                                Text="{Binding Value, Converter={StaticResource floatFormatter}, UpdateSourceTrigger=LostFocus}" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- Double -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type sys:Double}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding Value, Converter={StaticResource doubleFormatter}, UpdateSourceTrigger=LostFocus}" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- Velocidad -->
            <xctk:EditorTemplateDefinition TargetProperties="VelocidadActual">
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <xctk:SingleUpDown Increment="0.01" Background="Beige"
                                Text="{Binding Value, Converter={StaticResource floatFormatter}}"
                                FontWeight="Bold" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- File Dialog -->
            <xctk:EditorTemplateDefinition TargetProperties="ImagePath">
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox Grid.Column="0"
                                    Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <Button Grid.Column="1" Content="..." Width="25" Margin="2,0,0,0"
                                    Click="ImagePathButton_Click" />
                        </Grid>
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- osBuscarCoincidencias -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type ObjetosExtraccion:osBuscarCoincidencias}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding DataContext.ObjetosSimulables, 
                                           RelativeSource={RelativeSource AncestorType=Window}, 
                                           Converter={StaticResource SubclassFilterConverterosBuscarCoincidencias}}"
                                        SelectedItem="{Binding Value}" DisplayMemberPath="Nombre" IsEditable="True" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- osVMmotorSim -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type ObjetosSim:osVMmotorSim}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding DataContext.ObjetosSimulables, 
                                           RelativeSource={RelativeSource AncestorType=Window}, 
                                           Converter={StaticResource SubclassFilterConverterosVMMotor}}"
                                        SelectedItem="{Binding Value}" DisplayMemberPath="Nombre" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

            <!-- osBase -->
            <xctk:EditorTemplateDefinition>
                <xctk:EditorTemplateDefinition.TargetProperties>
                    <xctk:TargetPropertyType Type="{x:Type ObjetosSim:osBase}" />
                </xctk:EditorTemplateDefinition.TargetProperties>
                <xctk:EditorTemplateDefinition.EditingTemplate>
                    <DataTemplate>
                        <ComboBox
                                ItemsSource="{Binding DataContext.ObjetosSimulables, RelativeSource={RelativeSource AncestorType=Window}}"
                                SelectedItem="{Binding Value}" DisplayMemberPath="Nombre" />
                    </DataTemplate>
                </xctk:EditorTemplateDefinition.EditingTemplate>
            </xctk:EditorTemplateDefinition>

        </xctk:PropertyGrid.EditorDefinitions>
    </xctk:PropertyGrid>
</UserControl>
