<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dataModel="clr-namespace:Artemis.UI.Shared.DataModelVisualization.Shared"
        xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
        xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
        xmlns:dataModelPicker="clr-namespace:Artemis.UI.Shared.DataModelPicker">
    <Design.PreviewWith>
        <dataModelPicker:DataModelPicker />
    </Design.PreviewWith>

    <Style Selector="dataModelPicker|DataModelPicker">
        <Setter Property="Template">
            <ControlTemplate>
                <Grid RowDefinitions="Auto,Auto,*" Width="600" Height="400" Margin="10">
                    <TextBox Grid.Row="0" Watermark="Search - not yet implemented 😱" Name="SearchBox" IsEnabled="False" />

                    <Border Grid.Row="1" Classes="card card-condensed" Margin="0 10">
                        <Panel>
                            <Grid ColumnDefinitions="Auto,*"
                                  RowDefinitions="*"
                                  MinHeight="38"
                                  IsVisible="{CompiledBinding DataModelPath, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}">
                                <avalonia:MaterialIcon Grid.Column="0"
													   Grid.Row="0" 
                                                       Name="CurrentPathIcon" 
                                                       Kind="QuestionMarkCircle" 
                                                       Height="22"
                                                       Width="22"
                                                       Margin="5 0 15 0" 
                                                       IsVisible="{CompiledBinding !IsEventPicker, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <avalonia:MaterialIcon Grid.Column="0"
                                                       Grid.Row="0" 
                                                       Name="EventIcon"
                                                       Kind="LightningBolt"
                                                       Height="22"
                                                       Width="22" 
                                                       Margin="5 0 15 0"
                                                       IsVisible="{CompiledBinding IsEventPicker, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <StackPanel Grid.Column="1" Grid.Row="0" VerticalAlignment="Center">
                                    <TextBlock Name="CurrentPathDisplay" Classes="BodyStrongTextBlockStyle" MaxHeight="50" />
                                    <TextBlock Name="CurrentPathDescription" Classes="BodyTextBlockStyle" Foreground="{DynamicResource TextFillColorSecondary}" MaxHeight="50" />
                                </StackPanel>
                            </Grid>
                            <Grid MinHeight="38"
                                  IsVisible="{CompiledBinding DataModelPath, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNull}}" ColumnDefinitions="*,Auto"
                                  RowDefinitions="*,*">
                                <TextBlock Grid.Column="0" Grid.Row="0" Classes="BodyStrongTextBlockStyle">Welcome to the data model picker</TextBlock>
                                <TextBlock Grid.Column="0" Grid.Row="1" Foreground="{DynamicResource TextFillColorSecondary}">Select a value from the data model below</TextBlock>
                                <controls:HyperlinkButton Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">Learn more</controls:HyperlinkButton>
                            </Grid>
                        </Panel>
                    </Border>

                    <TreeView Grid.Row="2"
                              Name="DataModelTreeView"
                              ItemsSource="{CompiledBinding DataModelViewModel.Children, RelativeSource={RelativeSource TemplatedParent}}">
                        <TreeView.Styles>
                            <Style Selector="TreeViewItem">
                                <Setter Property="IsExpanded" Value="{CompiledBinding IsVisualizationExpanded, Mode=TwoWay, DataType=dataModel:DataModelVisualizationViewModel}" />
                                <Setter Property="IsEnabled" Value="{CompiledBinding IsMatchingFilteredTypes, Mode=OneWay, DataType=dataModel:DataModelVisualizationViewModel}" />
                            </Style>
                        </TreeView.Styles>
                        <TreeView.DataTemplates>
                            <TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{CompiledBinding Children}">
                                <Grid ColumnDefinitions="Auto,*">
                                    <TextBlock Grid.Column="0" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
                                    <TextBlock Grid.Column="1"
                                               Text="{CompiledBinding DisplayValue}"
                                               FontFamily="Consolas"
                                               HorizontalAlignment="Right"
                                               Margin="0 0 10 0" />
                                </Grid>
                            </TreeDataTemplate>

                            <TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
                                <Grid ColumnDefinitions="Auto,*">
                                    <StackPanel Grid.Column="0" Orientation="Horizontal">
                                        <TextBlock Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
                                        <TextBlock Text=" changed"
                                                   ToolTip.Tip="{CompiledBinding PropertyDescription.Description}"
                                                   IsVisible="{CompiledBinding IsEventPicker, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dataModelPicker:DataModelPicker}}}"/>
                                    </StackPanel>

                                    <ContentControl Grid.Column="1" Content="{CompiledBinding DisplayViewModel}" FontFamily="Consolas" Margin="0 0 10 0" />
                                </Grid>
                            </TreeDataTemplate>

                            <TreeDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}">
                                <Grid ColumnDefinitions="Auto,*">
                                    <TextBlock Grid.Column="0" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
                                    <TextBlock Grid.Column="1"
                                               Text="{CompiledBinding CountDisplay, Mode=OneWay}"
                                               FontFamily="Consolas"
                                               HorizontalAlignment="Right"
                                               Margin="0 0 10 0" />
                                </Grid>
                            </TreeDataTemplate>

                            <TreeDataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}" ItemsSource="{CompiledBinding Children}">
                                <TextBlock Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
                            </TreeDataTemplate>
                        </TreeView.DataTemplates>
                    </TreeView>
                    <StackPanel Grid.Row="2" VerticalAlignment="Center" Spacing="20" IsVisible="False">
                        <avalonia:MaterialIcon Kind="CloseCircle" Width="64" Height="64"></avalonia:MaterialIcon>
                        <TextBlock Classes="h4" TextAlignment="Center">No parts of the data model match your search</TextBlock>
                    </StackPanel>
                </Grid>

            </ControlTemplate>
        </Setter>
    </Style>
</Styles>