<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.TimelineGroupView"
             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:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline"
             xmlns:s="https://github.com/canton7/Stylet"
             xmlns:layerProperties="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             d:DataContext="{d:DesignInstance local:TimelineGroupViewModel}"
             Visibility="{Binding LayerPropertyGroupViewModel.IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24" />
            <RowDefinition Height="1" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ItemsControl Grid.Row="0"
                      Height="24"
                      Visibility="{Binding LayerPropertyGroupViewModel.IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
                      ItemsSource="{Binding KeyframePositions}"
                      Background="{DynamicResource MaterialDesignToolBarBackground}"
                      HorizontalAlignment="Stretch">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemContainerStyle>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Setter Property="Canvas.Left" Value="{Binding}" />
                </Style>
            </ItemsControl.ItemContainerStyle>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Ellipse Fill="{StaticResource MaterialDesignCheckBoxDisabled}"
                             Stroke="White"
                             StrokeThickness="0"
                             Width="10"
                             Height="10"
                             Margin="-5,6,0,0" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <Rectangle Grid.Row="1" HorizontalAlignment="Stretch" Fill="{DynamicResource MaterialDesignDivider}" Height="1" />

        <ItemsControl Grid.Row="2"
                      ItemsSource="{Binding LayerPropertyGroupViewModel.Items}"
                      Visibility="{Binding LayerPropertyGroupViewModel.IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
                      HorizontalAlignment="Stretch"
                      HorizontalContentAlignment="Stretch">
            <ItemsControl.ItemContainerStyle>
                <Style TargetType="ContentPresenter">
                    <Setter Property="VerticalAlignment" Value="Stretch" />
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                </Style>
            </ItemsControl.ItemContainerStyle>
            <ItemsControl.Resources>
                <DataTemplate DataType="{x:Type layerProperties:LayerPropertyGroupViewModel}">
                    <ContentControl s:View.Model="{Binding TimelineGroupViewModel}" 
                                    IsTabStop="False" 
                                    HorizontalAlignment="Stretch" 
                                    Visibility="{Binding IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"/>
                </DataTemplate>
                <DataTemplate DataType="{x:Type layerProperties:LayerPropertyViewModel}">
                    <ContentControl s:View.Model="{Binding TimelinePropertyViewModel}" 
                                    IsTabStop="False" 
                                    HorizontalAlignment="Stretch" 
                                    Visibility="{Binding IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
                </DataTemplate>
            </ItemsControl.Resources>
        </ItemsControl>
    </Grid>
</UserControl>
