<UserControl x:Class="Filtration.Views.ItemFilterBlockDisplaySettingsView"
             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:userControls="clr-namespace:Filtration.UserControls"
             xmlns:viewModels="clr-namespace:Filtration.ViewModels"
             xmlns:blockItembaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel"
             xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:blockItemTypes="clr-namespace:Filtration.ObjectModel.BlockItemTypes;assembly=Filtration.ObjectModel"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}"
             d:DesignHeight="120" d:DesignWidth="175">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="SharedResourcesDictionary.xaml" />
                <ResourceDictionary>
                    <CollectionViewSource x:Key="AudioVisualBlockItemsViewSource" Source="{Binding AudioVisualBlockItems}">
                        <CollectionViewSource.SortDescriptions>
                            <componentModel:SortDescription PropertyName="SortOrder" />
                        </CollectionViewSource.SortDescriptions>
                    </CollectionViewSource>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border BorderThickness="2" CornerRadius="4" BorderBrush="Black" Padding="4" Background="White">
        <Grid Background="White" Name="SettingsGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <ItemsControl ItemsSource="{Binding AudioVisualBlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,5">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel></WrapPanel>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0,0,3,0">
                            <Hyperlink Command="{Binding ElementName=SettingsGrid, Path=DataContext.AddAudioVisualBlockItemCommand}" CommandParameter="{Binding}">
                                <TextBlock>+</TextBlock><TextBlock Text="{Binding Path=., Converter={StaticResource BlockItemTypeToStringConverter}}" />
                            </Hyperlink>
                        </TextBlock>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <ItemsControl Grid.Row="1" ItemsSource="{Binding Source={StaticResource AudioVisualBlockItemsViewSource}}" Grid.IsSharedSizeScope="True">
                <ItemsControl.Resources>
                    <Style TargetType="{x:Type TextBlock}" x:Key="DisplayHeading">
                        <Setter Property="Margin" Value="0,0,5,0" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>
                    <DataTemplate DataType="{x:Type blockItembaseTypes:ColorBlockItem}">
                        <Grid Margin="0,0,0,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*"  />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto"  />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
                            <xctk:ColorPicker Grid.Column="1" SelectedColor="{Binding Color}" HorizontalAlignment="Right" Width="100" AvailableColors="{Binding ElementName=SettingsGrid, Path=DataContext.AvailableColors}" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
                            <userControls:CrossButton Grid.Column="2" Height="12" Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
                        </Grid>
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type blockItembaseTypes:IntegerBlockItem}">
                        <Grid Margin="0,0,0,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*"  />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto"  />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
                            <xctk:ShortUpDown Grid.Column="1" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Width="50" HorizontalAlignment="Right"/>
                            <userControls:CrossButton Grid.Column="2" Height="12" Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
                        </Grid>
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type blockItemTypes:SoundBlockItem}">
                        <Grid Margin="0,0,0,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*"  />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
                                <ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto"  />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
                            <WrapPanel  Grid.Column="1"  Grid.Row="0" HorizontalAlignment="Right">
                                <Button Command="{Binding ElementName=SettingsGrid, Path=DataContext.PlaySoundCommand}" Width="20" Height="20" Padding="3" Background="Transparent" BorderBrush="Transparent">
                                    <Image Source="/Filtration;component/Resources/Icons/speaker_icon.png"  VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </Button>
                                <ComboBox ItemsSource="{Binding ElementName=SettingsGrid, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" />
                                <xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="100" HorizontalAlignment="Right" ToolTip="Volume"/>
                            </WrapPanel>
                            <userControls:CrossButton Grid.Column="2" Grid.Row="0" Height="12"  Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.Resources>
            </ItemsControl>
        </Grid>
    </Border>
</UserControl>
