<UserControl x:Class="ProximaAnalizer.Controls.AlarmPicker"
             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:ProximaAnalizer.Controls"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <!--<ResourceDictionary Source="/UICommon;component/Resources.xaml"/>-->
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Background="White">
        <Button BorderBrush="{StaticResource DarkBorderColor}"  Click="Pop_Click" BorderThickness="1" HorizontalContentAlignment="Left" Background="Transparent">
            <TextBlock Background="Transparent" Text="{Binding SelectedAlarm.Value}" Margin="4,0,0,0" VerticalAlignment="Center"/>
        </Button>
        <Popup PopupAnimation="Slide" StaysOpen="False" IsOpen="{Binding ElementName=This, Path=IsPopOpen, Mode=TwoWay}">
            <Border BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="1">
                <Grid  Background="White">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="4"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ItemsControl Grid.Row="2" ItemsSource="{Binding ElementName=This, Path=Display}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button MinWidth="800" BorderThickness="0,1,0,0" Background="Transparent" BorderBrush="{StaticResource BackgroundDarkColor}" HorizontalContentAlignment="Left" Click="Button_Click" CommandParameter="{Binding}">
                                    <Grid Margin="0,2">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto"/>
                                            <RowDefinition Height="8"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <TextBlock Text="{Binding Key, StringFormat=HH:mm:ss}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                        <TextBlock Grid.Row="2" Text="{Binding Value}" HorizontalAlignment="Left" TextWrapping="Wrap"></TextBlock>
                                    </Grid>
                                </Button>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Vertical" HorizontalAlignment="Left"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>

                    <Grid Grid.Row="0" Margin="8">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="4"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="4"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="4"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="4"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" Width="48" Height="24" Style="{StaticResource FunctionButton}" Click="Home_Click">&lt;&lt;</Button>
                        <Button Grid.Column="2" Width="48" Height="24"  Style="{StaticResource FunctionButton}" Click="Prev_Click">&lt;</Button>

                        <StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Center">

                            <TextBox VerticalAlignment="Center" HorizontalAlignment="Center" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="48">
                                <TextBox.Text>
                                    <Binding ElementName="This" Path="SelectedPage" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
                                </TextBox.Text>
                            </TextBox>

                            <TextBlock Margin="8,0" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <Run>/</Run>
                                <Run Text="{Binding ElementName=This, Path=TotalPage}"/>
                            </TextBlock>
                        </StackPanel>

                        <Button Grid.Column="6" Width="48" Height="24"  Style="{StaticResource FunctionButton}" Click="Next_Click">&gt;</Button>
                        <Button Grid.Column="8" Width="48" Height="24"  Style="{StaticResource FunctionButton}" Click="End_Click">&gt;&gt;</Button>
                    </Grid>
                </Grid>
            </Border>
        </Popup>
    </Grid>
</UserControl>
