<Page x:Class="DemoExam.pages.agents.PageAgents"
      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:DemoExam.pages.agents"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="PageAgents">

    <Page.Resources>

        <Style x:Key="stlStackPanelDiscoind" TargetType="StackPanel">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ChangeBackground}" Value="True">
                    <Setter Property="Background" Value="Green"></Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding ChangeBackground}" Value="False">
                    <Setter Property="Background" Value="White"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="stlButtonChange" TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsVisibleButton}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding IsVisibleButton}" Value="False">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        
        <DataTemplate x:Key="listAgentTmpl">
            <StackPanel Orientation="Horizontal" Style="{StaticResource stlStackPanelDiscoind}" Width="1000">
                <Image Source="{Binding GetActualImage}" Width="200" Height="150"></Image>
                <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=AgentType.Title}"></TextBlock>
                        <TextBlock Text=" | "></TextBlock>
                        <TextBlock Text="{Binding Path=Title}"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding GetCountSaleOnYear}"></TextBlock>
                        <TextBlock Text=" продаж за год"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=Phone}"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Приоритетность: "></TextBlock>
                        <TextBlock Text="{Binding Path=Priority}"></TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="100,0,0,0">
                    <TextBlock Text="{Binding GetDiscountToString}"></TextBlock>
                </StackPanel>
            </StackPanel>
        </DataTemplate>


        
    </Page.Resources>
    
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*"></RowDefinition>
            <RowDefinition Height="10*"></RowDefinition>
        </Grid.RowDefinitions>


        <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                <ComboBox SelectedIndex="{Binding SetSortIndex}" Width="250" Height="30">
                    <ComboBoxItem>Название (возростание)</ComboBoxItem>
                    <ComboBoxItem>Размер скидки (возростание)</ComboBoxItem>
                    <ComboBoxItem>Приоритет агента (возростание)</ComboBoxItem>
                    <ComboBoxItem>Название (убывание)</ComboBoxItem>
                    <ComboBoxItem>Размер скидки (убывание)</ComboBoxItem>
                    <ComboBoxItem>Приоритет агента (убывание)</ComboBoxItem>
                </ComboBox>
                <ComboBox  Width="250" Height="30" ItemsSource="{Binding GetListTypeAgent}" SelectedValue="{Binding SetFiltValue}">
                </ComboBox>
                <TextBox Width="250" Height="30" Text="{Binding SearchText}"></TextBox>
            </StackPanel>


            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Content="Изменить на..." Style="{StaticResource stlButtonChange}" Width="250" Height="30" Click="Button_ChangePriority_Click"></Button>

                <Button Width="250" Height="30" Click="Button_AddAgent_Click">Добавить пользователя</Button>
            </StackPanel>
        </StackPanel>
        <ListBox x:Name="lstAgents" Grid.Row="1" ItemTemplate="{StaticResource listAgentTmpl}" ItemsSource="{Binding GetListAgent}" HorizontalContentAlignment="Center" SelectionMode="Extended" SelectionChanged="lstAgents_SelectionChanged" SelectedItem="{Binding SelectedAgent}" MouseDoubleClick="lstAgents_MouseDoubleClick"></ListBox>
    </Grid>
</Page>
