<Page x:Class="Sessioa.Pages.OrderCard"
      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:Sessioa.Pages"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      FontFamily="Comic Sans MS"
      FontSize="16"
      Title="Корзина с товарами">
    <Page.Resources>
        <BitmapImage x:Key="defaultImage" UriSource="/Resources/picture.png"/>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="8.5*"/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button Name="B_Back" Content="Назад" Style="{StaticResource ButtonAct}" Margin="10,0" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="B_Back_Click"  VerticalAlignment="Center" HorizontalAlignment="Left"/>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="30,0" VerticalAlignment="Center">
            <TextBlock Text="Пункт выдачи: " Style="{StaticResource TextBlock}" VerticalAlignment="Center"/>
            <ComboBox Name="CB_Punkt" MaxHeight="50" MinWidth="250" Margin="5"/>
        </StackPanel>
        <ListBox Name="LB_ProductsOrder" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="0.2*"/>
                        </Grid.ColumnDefinitions>
                        <Border BorderBrush="#498C51" BorderThickness="3" CornerRadius="5" Margin="10,0,0,0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.3*"/>
                                    <ColumnDefinition Width="2*"/>
                                    <ColumnDefinition Width="0.2*"/>
                                </Grid.ColumnDefinitions>
                                <Image Source="{Binding ProductPhoto, TargetNullValue={StaticResource defaultImage}}" Margin="5" MaxWidth="80"/>
                                <StackPanel Grid.Column="1">
                                    <TextBlock Text="{Binding ProductName}" Style="{StaticResource TextBlockBold}"/>
                                    <TextBlock Text="{Binding ProductDescription}" Style="{StaticResource TextBlock}"/>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Производитель:" Style="{StaticResource TextBlock}" Margin="0,0,5,0"/>
                                        <TextBlock Text="{Binding Manufacturer.Manufacturer1}" Style="{StaticResource TextBlock}"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="Цена: " Style="{StaticResource TextBlock}" Margin="0,0,5,0"/>
                                        <TextBlock Name="countPr" Text="{Binding ProductCost, StringFormat={}{0:C}}" Language="ru-Ru" Style="{StaticResource TextBlock}" Uid="{Binding ProductArticleNumber}" Loaded="countPr_Loaded"/>
                                        <TextBlock Name="countDPr" Style="{StaticResource TextBlock}" Language="ru-Ru" Uid="{Binding ProductArticleNumber}" Visibility="Collapsed" Loaded="countDPr_Loaded" Margin="5,0,0,0"/>
                                    </StackPanel>
                                </StackPanel>
                                <TextBlock Name="Discount" Loaded="Discount_Loaded" Uid="{Binding ProductArticleNumber}" Style="{StaticResource TextBlock}" Grid.Column="2" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                        <Border BorderBrush="#498C51" BorderThickness="3" CornerRadius="5" Grid.Column="1" Margin="20,0,10,0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Button Name="Back_B" Content="-" Style="{StaticResource ButtonAct}" MaxHeight="30" MinWidth="30" MaxWidth="50" Click="Back_B_Click" Uid="{Binding ProductArticleNumber}" HorizontalAlignment="Center"/>
                                <TextBlock x:Name="CountProduct" Grid.Column="1" Text="1" Style="{StaticResource TextBlockBold}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="22" Loaded="CountProduct_Loaded" Uid="{Binding ProductArticleNumber}"/>
                                <Button Name="Next_B" Content="+" Style="{StaticResource ButtonAct}" Grid.Column="2" MaxHeight="30" MinWidth="30" MaxWidth="50" Click="Next_B_Click" Uid="{Binding ProductArticleNumber}" HorizontalAlignment="Center"/>
                            </Grid>
                        </Border>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <StackPanel Orientation="Vertical" Grid.Row="2" HorizontalAlignment="Right" Margin="20,0">
            <TextBlock x:Name="TB_ItogoSkidka" Style="{StaticResource TextBlockMain}"/>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="ИТОГО: " Style="{StaticResource TextBlockMain}"/>
                <TextBlock x:Name="TB_Itogo" Style="{StaticResource TextBlockMain}" />
            </StackPanel>
        </StackPanel>
        <Button Name="B_Save" Content="Оформить заказ" Style="{StaticResource ButtonSt}" Margin="10,5" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="B_Save_Click" Grid.Row="3"/>
    </Grid>
</Page>
