<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm.ModuleAlarmView"
    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"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    xmlns:moduleAlarm="clr-namespace:MECF.Framework.UI.Client.CenterViews.Alarms.ModuleAlarm"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    d:DesignHeight="625"
    d:DesignWidth="1200"
    mc:Ignorable="d">
    <UserControl.Resources>
        <moduleAlarm:TypeColorConverter x:Key="TypeColorConverter" />

        <Style x:Key="localListBoxItem" TargetType="{x:Type xctk:SelectorItem}">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Margin" Value="0,0,20,0" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="BorderThickness" Value="0" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel
            Grid.Row="0"
            HorizontalAlignment="Left"
            VerticalAlignment="Top"
            Orientation="Horizontal">
            <Border
                Width="70"
                Height="40"
                Padding="5,1"
                Background="{DynamicResource Table_BG_Title}"
                BorderBrush="{DynamicResource Table_BD}"
                BorderThickness="1">
                <TextBlock
                    VerticalAlignment="Center"
                    Foreground="{DynamicResource FG_Black}"
                    Text="Modules:" />
            </Border>
            <Border
                Width="60"
                Height="40"
                Padding="5,1"
                Background="{DynamicResource Table_BG_Content}"
                BorderBrush="{DynamicResource Table_BD}"
                BorderThickness="0,1,1,1">
                <CheckBox
                    VerticalAlignment="Center"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Center"
                    Command="{Binding SelectAllChanged}"
                    Content="All"
                    FontSize="14"
                    IsChecked="{Binding IsAllSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            </Border>
            <Border
                Width="800"
                Height="40"
                Padding="5,1"
                Background="{DynamicResource Table_BG_Content}"
                BorderBrush="{DynamicResource Table_BD}"
                BorderThickness="0,1,1,1">
                <xctk:CheckListBox
                    VerticalAlignment="Center"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Center"
                    BorderThickness="0"
                    Command="{Binding SelectionChanged}"
                    DisplayMemberPath="ModuleName"
                    FontSize="14"
                    ItemContainerStyle="{DynamicResource localListBoxItem}"
                    ItemsSource="{Binding AllModules}"
                    SelectedItemsOverride="{Binding SelectedModules, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    SelectedMemberPath="IsSelected">
                    <xctk:CheckListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel
                                Margin="1,1,0,0"
                                IsItemsHost="True"
                                Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </xctk:CheckListBox.ItemsPanel>

                </xctk:CheckListBox>
            </Border>
        </StackPanel>

        <DataGrid
            Grid.Row="1"
            Width="Auto"
            Margin="0,5,0,0"
            HorizontalAlignment="Left"
            AutoGenerateColumns="False"
            CanUserAddRows="False"
            CanUserReorderColumns="False"
            CanUserSortColumns="False"
            FontSize="14"
            IsReadOnly="True"
            ItemsSource="{Binding FilteredAlarms}"
            ScrollViewer.CanContentScroll="True"
            ScrollViewer.HorizontalScrollBarVisibility="Auto"
            ScrollViewer.VerticalScrollBarVisibility="Auto">
            <DataGrid.Columns>


                <DataGridTemplateColumn
                    Width="90"
                    CanUserSort="True"
                    Header="Type"
                    SortMemberPath="Type">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Type" />
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Label
                                Background="{Binding Type, Converter={StaticResource TypeColorConverter}}"
                                Content="{Binding Type}"
                                FontSize="12" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


                <DataGridTextColumn
                    Width="150"
                    Binding="{Binding OccuringTime, Mode=OneWay}"
                    CanUserSort="True"
                    Header="Time"
                    IsReadOnly="True">
                    <DataGridTextColumn.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Time" />
                        </DataTemplate>
                    </DataGridTextColumn.HeaderTemplate>
                </DataGridTextColumn>

                <DataGridTextColumn
                    Width="150"
                    Binding="{Binding Source, Mode=OneWay}"
                    CanUserSort="True"
                    Header="Source"
                    IsReadOnly="True">
                    <DataGridTextColumn.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Source" />
                        </DataTemplate>
                    </DataGridTextColumn.HeaderTemplate>
                </DataGridTextColumn>

                <DataGridTemplateColumn
                    Width="*"
                    CanUserSort="True"
                    Header="Description"
                    SortMemberPath="Description">
                    <DataGridTemplateColumn.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="Description" />
                        </DataTemplate>
                    </DataGridTemplateColumn.HeaderTemplate>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock
                                FontSize="12"
                                Text="{Binding Description}"
                                TextWrapping="Wrap" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>


                <DataGridTemplateColumn Width="110">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button
                                Width="100"
                                Height="25"
                                Content="Reset"
                                FontSize="14">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <micro:ActionMessage MethodName="ResetAlarm">
                                            <micro:Parameter Value="{Binding}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

    </Grid>

    <!--<GroupBox Header="Alarm List" Margin="5,0,12,5">
            <DataGrid Grid.Row="1" Margin="0,5,0,0"
                      Width="Auto"

                      ScrollViewer.CanContentScroll="True"
                      ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto"
                      HorizontalAlignment="Left"
                      AutoGenerateColumns="False" Name="dataGrid1" ItemsSource="{Binding AlarmEvents,Mode=OneWay}"
                      FontFamily="Arial,SimSun"
                      CanUserReorderColumns="False" CanUserAddRows="False"
                      CanUserSortColumns="False"
                      IsReadOnly="True" FontSize="14">
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="Type" Width="90" CanUserSort="True" SortMemberPath="Type">
                        <DataGridTemplateColumn.HeaderTemplate >
                            <DataTemplate>
                                <TextBlock Text="Type" />
                            </DataTemplate>
                        </DataGridTemplateColumn.HeaderTemplate>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Label Content="{Binding Type}" Background="{Binding TextColor}" FontSize="12"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTextColumn Header="Time" Width="150" CanUserSort="True" IsReadOnly="True" Binding="{Binding OccuringTime,Mode=OneWay}">
                        <DataGridTextColumn.HeaderTemplate >
                            <DataTemplate>
                                <TextBlock Text="Time" />
                            </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Description" Width="*" CanUserSort="True" IsReadOnly="True" Binding="{Binding Description,Mode=OneWay}">
                        <DataGridTextColumn.HeaderTemplate >
                            <DataTemplate>
                                <TextBlock Text="Description" />
                            </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
        </GroupBox>-->
    <!--<GroupBox Grid.Column="1" Header="Detail" Margin="0,0,5,5">
            <TextBlock x:Name="AnalysisText" FontSize="14" Margin="5" Background="White" TextWrapping="Wrap" Style="{x:Null}"/>
        </GroupBox>-->
</UserControl>
