<Page x:Class="Sessioa.Pages.ProductsPage"
      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="ProductsPage">
    <Page.Resources>
        <BitmapImage x:Key="defaultImage" UriSource="/Resources/picture.png"/>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.07*"/>
            <RowDefinition Height="0.1*"/>
            <RowDefinition/>
            <RowDefinition Height="0.07*"/>
        </Grid.RowDefinitions>
        <ListBox Name="LB_Product" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Grid.Row="2">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="#498C51" BorderThickness="3" CornerRadius="5" Uid="{Binding ProductArticleNumber}" Loaded="Border_Loaded">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.3*"/>
                                <ColumnDefinition Width="2*"/>
                                <ColumnDefinition Width="0.5*"/>
                                <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}" Uid="{Binding ProductArticleNumber}" Visibility="Collapsed" Loaded="countPr_Loaded_1" 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>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ContextMenu>
                <ContextMenu Loaded="ContextMenu_Loaded">
                    <MenuItem Name="AddOrder" Header="Добавить к заказу" Click="AddOrder_Click"/>
                    <MenuItem Name="EditProduct" Header="Редактировать" Loaded="EditProduct_Loaded" Click="EditProduct_Click"/>
                    <MenuItem Name="DeleteProduct" Header="Удалить" Loaded="DeleteProduct_Loaded" Click="DeleteProduct_Click"/>
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="7*"/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBox Name="SearchTB" TextChanged="SearchTB_TextChanged" Style="{StaticResource TextBox}" MaxHeight="60" Margin="6" DataContext="Поиск"/>
            <ComboBox Name="CB_Sort" SelectionChanged="CB_Sort_SelectionChanged" MaxHeight="60" Margin="6" Grid.Column="1" FontFamily="Comic Sans MS" FontSize="16" VerticalContentAlignment="Center" FontWeight="Light"/>
            <ComboBox Name="CB_Filtr" SelectionChanged="CB_Filtr_SelectionChanged" MaxHeight="60" Margin="6" Grid.Column="2" FontFamily="Comic Sans MS" FontSize="16" VerticalContentAlignment="Center" FontWeight="Light"/>
        </Grid>
        <StackPanel Grid.Row="3" HorizontalAlignment="Center" Orientation="Horizontal" VerticalAlignment="Center">
            <TextBlock Name="TB_CountActual" Style="{StaticResource TextBlock}"/>
            <TextBlock Text=" из " Style="{StaticResource TextBlock}"/>
            <TextBlock Name="TB_CountAll" Style="{StaticResource TextBlock}"/>
        </StackPanel>
        <TextBlock Name="UserSign" HorizontalAlignment="Right" VerticalAlignment="Center" Style="{StaticResource TextBlock}" Margin="30,0"/>
        <StackPanel Orientation="Horizontal">
            <Button Name="SignOf" Content="Выйти" Style="{StaticResource ButtonAct}" Margin="10,0" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="SignOf_Click" HorizontalAlignment="Left"/>
            <Button Name="NewProduct" Content="Добавить продукт" Style="{StaticResource ButtonSt}" Margin="10,0" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="NewProduct_Click" HorizontalAlignment="Left" Visibility="Collapsed" Loaded="NewProduct_Loaded"/>
            <Button Name="OrdersUser" Content="Заказы" Style="{StaticResource ButtonSt}" Margin="10,0" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="OrdersUser_Click" HorizontalAlignment="Left" Visibility="Collapsed" Loaded="OrdersUser_Loaded"/>
            <Button Name="OrderActUser" Content="Корзина" Style="{StaticResource ButtonSt}" Margin="10,0" MaxHeight="50" MinWidth="90" MaxWidth="150" Click="OrderActUser_Click"  HorizontalAlignment="Left" Visibility="Collapsed"/>
        </StackPanel>    
    </Grid>
</Page>
