<Window x:Class="KolekcjeWPF.MainWindow"
        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:KolekcjeWPF"
        xmlns:mw="clr-namespace:KolekcjeWPF.ModelWidoku"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="Kolekcje WPF" Height="700" Width="500">
    <Window.DataContext>
        <mw:Zadania />
    </Window.DataContext>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="b2v" />
        <local:KonwerterZadania x:Key="kz" />
        <Style x:Key="stylPrzycisku" TargetType="Button">
            <Setter Property="Margin" Value="10" />
            <Setter Property="VerticalAlignment" Value="Top" />
        </Style>
    </Window.Resources>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closed">
            <i:InvokeCommandAction Command="{Binding Zapisz}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid>
        <TextBlock Margin="10,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="Liczba zadań:">
            <Run Text="{Binding Path=ListaZadań.Count, Mode=OneWay}" />
        </TextBlock>
        <ListBox x:Name="lbListaZadań" Margin="10,35,10,200"
            ItemsSource="{Binding Path=ListaZadań}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" Margin="3">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Opis, Mode=OneWay}" FontSize="20" />
                            <Button Content="Zrealizowane" Command="{Binding Path=OznaczJakoZrealizowane}" 
                                    Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Mode=OneWay, Converter={StaticResource b2v}}" 
                                    Style="{StaticResource stylPrzycisku}"/>
                            <Button Content="Niezrealizowane" Command="{Binding Path=OznaczJakoNiezrealizowane}"
                                    Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Mode=OneWay, Converter={StaticResource b2v}}"
                                    Style="{StaticResource stylPrzycisku}"/>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Margin" Value="3"/>
                    <Setter Property="BorderBrush" Value="Black" />
                    <Setter Property="BorderThickness" Value="1" />
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <Button Content="Usuń zaznaczone zadanie" Margin="10,120,0,0" Width="200" Height="25" HorizontalAlignment="Left"
                Command="{Binding UsuńZadanie}"
                CommandParameter="{Binding ElementName=lbListaZadań, Path=SelectedIndex}"/>
        <GroupBox Header="Nowe zadanie" Margin="10,0,10,10" Height="180" VerticalAlignment="Bottom">
            <StackPanel>
                <Label Content="Opis zadania:" />
                <TextBox x:Name="tbOpis" Margin="10,0,10,0" />
                <Label Content="Priorytet:" Margin="10,0,10,0"/>
                <ComboBox x:Name="cbPriorytet" Margin="10,0,10,0">
                    <ComboBoxItem>MniejWażne</ComboBoxItem>
                    <ComboBoxItem>Standardowe</ComboBoxItem>
                    <ComboBoxItem>Ważne</ComboBoxItem>
                    <ComboBoxItem>Krytyczne</ComboBoxItem>
                </ComboBox>
                <StackPanel Orientation="Horizontal">
                    <StackPanel Width="300">
                        <Label Content="Data realizacji:" Margin="10,0,10,0"/>
                        <DatePicker x:Name="dpDataRealizacji" Margin="10,0,10,0" SelectedDate="{x:Static s:DateTime.Now}"/>
                    </StackPanel>
                    <StackPanel >
                        <Button FontSize="20" Content="Dodaj zadanie" Margin="10" VerticalAlignment="Bottom"
                                Command="{Binding DodajZadanie}">
                            <Button.CommandParameter>
                                <MultiBinding Converter="{StaticResource kz}">
                                    <Binding ElementName="tbOpis" Path="Text" />
                                    <Binding ElementName="dpDataRealizacji" Path="SelectedDate" />
                                    <Binding ElementName="cbPriorytet" Path="SelectedIndex" />
                                </MultiBinding>
                            </Button.CommandParameter>
                        </Button>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </GroupBox>
    </Grid>
</Window>
