<UserControl
    x:Class="SicUI.Models.PMs.PMAlarmView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:alarm="clr-namespace:MECF.Framework.UI.Client.CenterViews.Alarms.Alarm;assembly=MECF.Framework.UI.Client"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="325"
    d:DesignWidth="1200"
    lex:LocalizeDictionary.DesignCulture="zh"
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
    mc:Ignorable="d">
    <UserControl.Resources>
        <alarm:EventLevelToBackgroundConverter x:Key="EventLevelToBackgroundConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="7*" />
            <ColumnDefinition Width="5*" />
        </Grid.ColumnDefinitions>
        <GroupBox Margin="5,0,12,5" Header="{lex:Loc ID_TXT_Alarm}">
            <DataGrid
                Name="eventList"
                Margin="5"
                AutoGenerateColumns="False"
                Background="White"
                BorderThickness="0.1"
                CanUserAddRows="True"
                CanUserDeleteRows="True"
                FontFamily="Arial,SimSun"
                FontSize="13"
                IsReadOnly="True"
                ItemsSource="{Binding AlarmEvents, Mode=OneWay}"
                SelectionChanged="listView1_SelectionChanged"
                SelectionMode="Single"
                SelectionUnit="FullRow">
                <DataGrid.Columns>
                    <DataGridTemplateColumn
                        Width="90"
                        CanUserSort="True"
                        Header="Type"
                        SortMemberPath="Type">
                        <DataGridTemplateColumn.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock Text="{lex:Loc ID_TXT_Type}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.HeaderTemplate>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Border Margin="-2" Background="{Binding Level, Converter={StaticResource EventLevelToBackgroundConverter}}">
                                    <TextBlock
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Text="{Binding LevelString}" />
                                </Border>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTextColumn
                        Width="150"
                        Binding="{Binding OccuringTime, Mode=OneWay}"
                        CanUserSort="True"
                        Header="Time"
                        IsReadOnly="True">
                        <DataGridTextColumn.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock Text="{lex:Loc ID_TXT_Date}" />
                            </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="TextAlignment" Value="Left" />
                                <Setter Property="VerticalAlignment" Value="Center" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn
                        Width="*"
                        Binding="{Binding Description, Mode=OneWay}"
                        CanUserSort="True"
                        Header="Description"
                        IsReadOnly="True">
                        <DataGridTextColumn.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock Text="{lex:Loc ID_TXT_Description}" />
                            </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="TextAlignment" Value="Left" />
                                <Setter Property="VerticalAlignment" Value="Center" />
                                <Setter Property="Margin" Value="2,1" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>
        <GroupBox
            Grid.Column="1"
            Margin="0,0,5,5"
            Header="{lex:Loc ID_TXT_Detail}">
            <TextBlock
                x:Name="AnalysisText"
                Margin="5"
                Background="White"
                FontSize="14"
                Style="{x:Null}"
                TextWrapping="Wrap" />
        </GroupBox>
    </Grid>
</UserControl>
