<UserControl x:Class="HistoryView.Views.Regions.Alarm"
             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:HistoryView.Views.Regions"
             mc:Ignorable="d" 
             xmlns:controls="clr-namespace:HistoryView.Controls"
             xmlns:converter="clr-namespace:HistoryView.Converters"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:resource="clr-namespace:HistoryView.Resources"
             prism:ViewModelLocator.AutoWireViewModel="True"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <converter:DateTimeToString x:Key="Datetime"/>
        <converter:AuthorityToVis x:Key="Authority"/>
    </UserControl.Resources>
    <Grid Background="DarkGray">
        <Border Background="{StaticResource BackgroundColor}" Margin="4">
            <Border.Effect>
                <DropShadowEffect BlurRadius="20" Color="Black" Opacity="0.6"  ShadowDepth="5"/>
            </Border.Effect>
            <Grid Margin="16">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="8"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <Grid Margin="4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="64"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="90"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="88"/>
                        <ColumnDefinition Width="auto"/>
                  
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <!--<TextBlock Grid.Column="0" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="{DynamicResource AlarmInfo}"/>-->
                    <TextBlock Grid.Column="2" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="{DynamicResource AlarmTime}"/>
                    <TextBlock Grid.Column="4" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="{DynamicResource AlarmMini8}"/>
                    <TextBlock Grid.Column="6" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="{DynamicResource AlarmChannel}"/>
                    <TextBlock Grid.Column="8" VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="{DynamicResource AlarmDetail}"/>
                </Grid>

                <StackPanel Grid.Row="2" Panel.ZIndex="1" VerticalAlignment="Center" Visibility="{Binding NoAlarm}">
                    <Image Source="{StaticResource Icon_NoData}" Width="140"/>
                    <TextBlock Margin="16" FontWeight="Bold" FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{StaticResource DarkBorderColor}" Text="{DynamicResource AlarmNone}"/>
                </StackPanel>

                <resource:TouchableScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Hidden">
                    <ItemsControl ItemsSource="{Binding Alarms.DisplayAlarm}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <controls:WarningItemCollection Alarms="{Binding Value}" Margin="0,4" 
                                         Clear="{Binding RelativeSource={RelativeSource Mode=FindAncestor ,AncestorType=local:Alarm}, Path=DataContext.ClearSingleCommand}"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel VerticalAlignment="Top" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </resource:TouchableScrollViewer>

                <Button Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="16,0" MinWidth="100" Height="32" Style="{StaticResource FunctionButton}" Command="{Binding HistoryCommand}" Content="{DynamicResource AlarmHistory}"/>

                <Button Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="16,0" MinWidth="100" Height="32" Style="{StaticResource FunctionButton}" Command="{Binding ClearCommand}" Background="{StaticResource EmergencyColor}" Content="{DynamicResource ClearAll}"  Visibility="{Binding UserInfo.Authority, Converter={StaticResource Authority}, ConverterParameter=Operator}"/>
            </Grid>
        </Border>
    </Grid>
</UserControl>
