<Window x:Class="ScratchNet.LibraryWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ScratchNet"
        mc:Ignorable="d" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" ShowActivated="True"
        xmlns:loc="clr-namespace:ScratchNet.Properties"
        Title="{x:Static loc:Resources.LibraryTitle}" Height="480" Width="800">
    <Window.Resources>
        <local:LibraryImageConverter x:Key="LibraryImageConverter"/>
        <local:StoreVisibilityConverter x:Key="StoreVisibilityConverter"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <ListView Name="LibraryList" Margin="5">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.Template>
                <ControlTemplate>
                    <ScrollViewer Margin="0" Padding="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                        <ItemsPresenter/>
                    </ScrollViewer>
                </ControlTemplate>
            </ListView.Template>
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListViewItem}">
                                <Border BorderBrush="LightGray" Width="140" BorderThickness="1" CornerRadius="5" Margin="2">
                                    <Grid Margin="2">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto"/>
                                            <RowDefinition Height="auto"/>
                                            <RowDefinition Height="auto"/>
                                        </Grid.RowDefinitions>
                                        <Border Background="White">
                                        </Border>
                                        <Image Margin="1" Source="{Binding Converter={StaticResource LibraryImageConverter}}" Height="140" ToolTip="{Binding Path=Library.Description}"/>
                                        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock Margin="3,3" HorizontalAlignment="Center" Grid.Row="1" Text="{Binding Path=Library.Title}" FontWeight="Bold"/>
                                            <TextBlock Margin="3,3" Text="{Binding Path=Price}" FontWeight="Bold" Foreground="Red"/>
                                        </StackPanel>
                                        <Border Margin="0" Name="BD_Collector" BorderThickness="1"/>
                                        <CheckBox Tag="{Binding}" Grid.Row="2" HorizontalAlignment="Center" IsChecked="{Binding Path=IsImported}"/>
                                        <Button Grid.Row="2" Padding="3,1" HorizontalAlignment="Center" Click="BuyAddon"
                                                Tag="{Binding}"
                                                Visibility="{Binding Path=IsPurchased, Converter={StaticResource StoreVisibilityConverter}}">Buy</Button>
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter TargetName="BD_Collector" Property="BorderBrush" Value="YellowGreen" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
            <Button Margin="5" Padding="10,5" Width="120" IsDefault="True" Click="OnOK" Content="{x:Static loc:Resources.Confirm}"></Button>
            <Button Margin="5" Padding="10,5" Width="120" IsCancel="True" Content="{x:Static loc:Resources.Cancel}"></Button>
        </StackPanel>
    </Grid>
</Window>
