<UserControl
    x:Class="BPASmartClient.Control.AlarmView"
    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:local="clr-namespace:BPASmartClient.Control"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">

    <UserControl.DataContext>
        <vm:AlarmViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <!--<convert:TextDisplayConvert x:Key="textDisplayConvert" />
                    <convert:IsEnableConvert x:Key="isEnableConvert" />
                    <convert:AnalogAlarmConvert x:Key="analogAlarmConvert" />
                    <convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" />
                    <convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />-->
                    <SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" />
                    <SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" />
                    <SolidColorBrush x:Key="TitleFontColor" Color="#ddd" />
                    <SolidColorBrush x:Key="CursorColor" Color="Aqua" />
                    <SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" />

                    <Style x:Key="TextBlockStyle" TargetType="TextBlock">
                        <Setter Property="FontFamily" Value="楷体" />
                        <Setter Property="FontSize" Value="18" />
                        <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                        <Setter Property="HorizontalAlignment" Value="Center" />
                    </Style>

                    <Style x:Key="TextBoxStyle" TargetType="TextBox">
                        <Setter Property="FontFamily" Value="楷体" />
                        <Setter Property="FontSize" Value="22" />
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" />
                        <Setter Property="BorderBrush" Value="#FF23CACA" />
                        <Setter Property="CaretBrush" Value="Aqua" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>

                    <Style x:Key="DataTextBlockStyle" TargetType="TextBlock">
                        <Setter Property="HorizontalAlignment" Value="Center" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Foreground" Value="Red" />
                        <Setter Property="FontSize" Value="14" />
                    </Style>

                    <ControlTemplate x:Key="ButTemplate" TargetType="Button">
                        <Border
                            x:Name="br"
                            Background="Transparent"
                            BorderBrush="#FF19B7EC"
                            BorderThickness="2">
                            <StackPanel
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Orientation="Horizontal">
                                <ContentControl
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Content="{TemplateBinding Content}"
                                    Foreground="{TemplateBinding Foreground}" />
                            </StackPanel>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="br" Property="Background" Value="#2219B7EC" />
                            </Trigger>

                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="br" Property="Background" Value="#2219B7EC" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="30" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel
            Margin="0,8"
            HorizontalAlignment="Right"
            Orientation="Horizontal">

            <DatePicker
                Background="Transparent"
                BorderBrush="#aa3aa7f3"
                BorderThickness="2"
                SelectedDate="{Binding StartDateTime}"
                Style="{StaticResource PickerStyle}"
                Text="请输入开始时间"
                Visibility="{Binding IsVisibility}" />

            <DatePicker
                Margin="20,0,20,0"
                Background="Transparent"
                BorderBrush="#aa3aa7f3"
                BorderThickness="2"
                SelectedDate="{Binding EndDateTime}"
                Style="{StaticResource PickerStyle}"
                Text="请输入结束时间"
                Visibility="{Binding IsVisibility}" />

            <Button
                Width="140"
                Height="30"
                Background="#FF19B7EC"
                Command="{Binding ControlCommand}"
                Content="{Binding ControlButText}"
                FontFamily="楷体"
                FontSize="18"
                Template="{StaticResource ButTemplate}">
                <Button.Foreground>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#FFBB662A" />
                        <GradientStop Offset="1" Color="White" />
                    </LinearGradientBrush>
                </Button.Foreground>
            </Button>

            <Button
                Width="140"
                Height="30"
                Margin="20,0,0,0"
                Background="#FF19B7EC"
                Command="{Binding SwitchCommand}"
                Content="{Binding ButContent}"
                FontFamily="楷体"
                FontSize="18"
                Template="{StaticResource ButTemplate}">
                <Button.Foreground>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#FFBB662A" />
                        <GradientStop Offset="1" Color="White" />
                    </LinearGradientBrush>
                </Button.Foreground>
            </Button>

        </StackPanel>

        <!--#region 表格标题栏设置-->
        <Grid Grid.Row="1" Background="#dd2AB2E7">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.3*" />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition />
                <ColumnDefinition Width="0.7*" />
                <ColumnDefinition Width="0.5*" />
            </Grid.ColumnDefinitions>
            <TextBlock
                Grid.Column="0"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="ID" />

            <Grid Grid.Column="1">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="报警日期" />
                <Border
                    BorderBrush="{StaticResource TitleBorderColor}"
                    BorderThickness="1,0,1,0"
                    Cursor="SizeWE" />
            </Grid>

            <TextBlock
                Grid.Column="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="报警时间" />

            <Grid Grid.Column="3">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="报警信息" />
                <Border
                    BorderBrush="{StaticResource TitleBorderColor}"
                    BorderThickness="1,0,1,0"
                    Cursor="SizeWE" />
            </Grid>

            <TextBlock
                Grid.Column="4"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontSize="16"
                Foreground="{StaticResource TitleFontColor}"
                Text="报警值" />

            <Grid Grid.Column="5">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Foreground="{StaticResource TitleFontColor}"
                    Text="报警等级" />
                <Border
                    BorderBrush="{StaticResource TitleBorderColor}"
                    BorderThickness="1,0,1,0"
                    Cursor="SizeWE" />
            </Grid>
        </Grid>
        <!--#endregion-->

        <!--#region 表格数据显示-->
        <ScrollViewer
            Grid.Row="2"
            HorizontalScrollBarVisibility="Hidden"
            VerticalScrollBarVisibility="Hidden">

            <Grid>
                <!--#region 实时报警信息-->
                <ItemsControl ItemsSource="{Binding AlarmInfos}" Visibility="{Binding CurrentDataVis}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid x:Name="gr" Height="30">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.3*" />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition Width="0.5*" />
                                </Grid.ColumnDefinitions>

                                <TextBlock
                                    Grid.Column="0"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding NumId}" />

                                <Grid Grid.Column="1">
                                    <TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <TextBlock
                                    Grid.Column="2"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding Time}" />

                                <Grid Grid.Column="3">
                                    <TextBlock
                                        Margin="10,0,0,0"
                                        HorizontalAlignment="Left"
                                        Style="{StaticResource DataTextBlockStyle}"
                                        Text="{Binding Info}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <TextBlock
                                    Grid.Column="4"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding Value}" />

                                <Grid Grid.Column="5">
                                    <TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <Border
                                    Grid.ColumnSpan="6"
                                    BorderBrush="{StaticResource BorderSolid}"
                                    BorderThickness="1" />

                            </Grid>

                            <DataTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
                                </Trigger>
                            </DataTemplate.Triggers>

                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <!--#endregion-->

                <!--#region  历史报警信息-->
                <ItemsControl ItemsSource="{Binding HistoryAlarm}" Visibility="{Binding HistoryDataVis}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid x:Name="gr" Height="30">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.3*" />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="0.7*" />
                                    <ColumnDefinition Width="0.5*" />
                                </Grid.ColumnDefinitions>

                                <TextBlock
                                    Grid.Column="0"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding Id}" />

                                <Grid Grid.Column="1">
                                    <TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <TextBlock
                                    Grid.Column="2"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding Time}" />

                                <Grid Grid.Column="3">
                                    <TextBlock
                                        Margin="10,0,0,0"
                                        HorizontalAlignment="Left"
                                        Style="{StaticResource DataTextBlockStyle}"
                                        Text="{Binding Info}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <TextBlock
                                    Grid.Column="4"
                                    Style="{StaticResource DataTextBlockStyle}"
                                    Text="{Binding Value}" />

                                <Grid Grid.Column="5">
                                    <TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" />
                                    <Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />
                                </Grid>

                                <Border
                                    Grid.ColumnSpan="6"
                                    BorderBrush="{StaticResource BorderSolid}"
                                    BorderThickness="1" />

                            </Grid>

                            <DataTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
                                </Trigger>
                            </DataTemplate.Triggers>

                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <!--#endregion-->
            </Grid>
        </ScrollViewer>
        <!--#endregion-->


    </Grid>
</UserControl>
