<Window x:Class="NBAManagment.PhotosPage"
        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:NBAManagment"
        mc:Ignorable="d"
        Title="PhotosPage" Height="450" Width="800"  ResizeMode="NoResize">
    <Grid>
        <TextBlock Text="When you like a photo, you can right-click a photo and choose the download menu item in the context menu to download."
                   HorizontalAlignment="Center" VerticalAlignment="Top"
                   FontSize="14"/>
        <Border BorderThickness="1" Margin="10, 35, 10, 45">
            <ItemsControl ItemsSource="{Binding PagedImage.CurrentPage}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel ItemHeight="180" ItemWidth="250"
                                   Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                   Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Button Margin="5" PreviewMouseRightButtonDown="ShowDownloadPoput">
                                <Image Source="{Binding ImageSource}" Stretch="Fill"/>
                            </Button>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Border>
        <Popup x:Name="downloadPoput" Width="125" Height="30" IsOpen="False" Placement="Mouse" PopupAnimation="None" StaysOpen="False">
            <Grid>
                <Button Click="DownloadImage" Margin="0">
                    <Button.Content>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/NBAManagement;component/Resources/download.png" Height="25" Width="25"/>
                            <TextBlock Text="Download" FontSize="16"/>
                        </StackPanel>
                    </Button.Content>
                </Button>
            </Grid>
        </Popup>

        <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,10,10" Orientation="Horizontal" Height="35" Width="642">
            <Button Content="|&lt;" Padding="10, 2" BorderBrush="Black" Margin="3, 0" Click="FirstPage"/>
            <Button Content="&lt;" Padding="10, 2" BorderBrush="Black" Margin="3, 0" Click="PriveusPage"/>
            <TextBox Name="pageNumTaxtBlock" Text="{Binding PageNum}" Width="30" Padding="4" TextAlignment="Center" Margin="3, 0"/>
            <Button Content="&gt;" Padding="10, 2" BorderBrush="Black" Margin="3, 0" Click="NextPage"/>
            <Button Content="&gt;|" Padding="10, 2" BorderBrush="Black" Margin="3, 0" Click="LastPage"/>
            <Button Margin="50, 0, 10, 0" Style="{StaticResource ModernButton}" Content="Download photos in current page" Padding="10, 2" BorderBrush="Black" Click="DownloadPageImages"/>
        </StackPanel>
    </Grid>
</Window>
