<UserControl xmlns="https://github.com/avaloniaui"
             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:controls="clr-namespace:DHT.Desktop.Main.Controls"
             mc:Ignorable="d"
             x:Class="DHT.Desktop.Main.Controls.FilterPanel">

    <Design.DataContext>
        <controls:FilterPanelModel />
    </Design.DataContext>

    <UserControl.Styles>
        <Style Selector="WrapPanel > StackPanel">
            <Setter Property="Margin" Value="0 20 40 0" />
            <Setter Property="Spacing" Value="4" />
        </Style>
        <Style Selector="WrapPanel > StackPanel:nth-last-child(1)">
            <Setter Property="Margin" Value="0 20 0 0" />
        </Style>
        <Style Selector="Grid > Label">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style Selector="Grid > CalendarDatePicker">
            <Setter Property="CornerRadius" Value="0" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="IsTodayHighlighted" Value="True" />
            <Setter Property="SelectedDateFormat" Value="Short" />
        </Style>
        <Style Selector="Button">
            <Setter Property="Margin" Value="0 0 0 8" />
        </Style>
    </UserControl.Styles>

    <WrapPanel>
        <StackPanel>
            <CheckBox IsChecked="{Binding FilterByDate}">Filter by Date</CheckBox>
            <Grid ColumnDefinitions="Auto, 4, 125" RowDefinitions="Auto, 4, Auto" Margin="4 0">
                <Label Grid.Row="0" Grid.Column="0">From:</Label>
                <CalendarDatePicker Grid.Row="0" Grid.Column="2" x:Name="StartDatePicker" IsEnabled="{Binding FilterByDate}" SelectedDateChanged="CalendarDatePicker_OnSelectedDateChanged" />
                <Label Grid.Row="2" Grid.Column="0">To:</Label>
                <CalendarDatePicker Grid.Row="2" Grid.Column="2" x:Name="EndDatePicker" IsEnabled="{Binding FilterByDate}" SelectedDateChanged="CalendarDatePicker_OnSelectedDateChanged" />
            </Grid>
        </StackPanel>
        <StackPanel>
            <CheckBox IsChecked="{Binding FilterByChannel}">Filter by Channel</CheckBox>
            <Button Command="{Binding OpenChannelFilterDialog}" IsEnabled="{Binding FilterByChannel}">Select Channels...</Button>
            <TextBlock Text="{Binding ChannelFilterLabel}" />
        </StackPanel>
        <StackPanel>
            <CheckBox IsChecked="{Binding FilterByUser}">Filter by User</CheckBox>
            <Button Command="{Binding OpenUserFilterDialog}" IsEnabled="{Binding FilterByUser}">Select Users...</Button>
            <TextBlock Text="{Binding UserFilterLabel}" />
        </StackPanel>
    </WrapPanel>

</UserControl>
