<Window x:Class="NEIntelligentControl2.Windows.Alarm.HistoryAlarmWindow"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:NEIntelligentControl2.Windows.Alarm"
        xmlns:alarm="clr-namespace:NEIntelligentControl2.Views.Alarm"
        xmlns:ib="clr-namespace:NEIntelligentControl2.Views.Basic"
        mc:Ignorable="d"
        Title="历史报警" Height="662" Width="1200" Background="#FFE3E3E3" WindowStyle="None" WindowStartupLocation="CenterOwner" Loaded="Window_Loaded">
    <WindowChrome.WindowChrome>
        <WindowChrome/>
    </WindowChrome.WindowChrome>
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Res/Alarm.xaml"/>
            </ResourceDictionary.MergedDictionaries>


            <Style x:Key="TagStackPanelStyle" TargetType="StackPanel">
                <Setter Property="Orientation" Value="Horizontal"/>
                <Setter Property="Margin" Value="10"/>
            </Style>

            <Style x:Key="TagTextBlockStyle" TargetType="TextBlock">
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>

            <Style x:Key="TagComboBoxStyle" TargetType="ComboBox">
                <Setter Property="MinWidth" Value="100"/>
            </Style>

            <Style x:Key="TagTextBoxStyle" TargetType="TextBox">
                <Setter Property="MinWidth" Value="120"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Style>


            <Style TargetType="{x:Type ScrollBar}">
                <Setter Property="Background" Value="#77F0F8FF"/>
                <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
                <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
                <!--滚动条宽度-->
                <Setter Property="Width" Value="8"/>
                <Setter Property="MinWidth" Value="6"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <!--滚动条背景色-->
                            <Grid x:Name="Bg" Background="#77DDDDDD" SnapsToDevicePixels="true" Width="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="Orientation" Value="Horizontal">
                        <Setter Property="Width" Value="Auto"/>
                        <Setter Property="MinWidth" Value="0"/>
                        <Setter Property="Height" Value="6"/>
                        <Setter Property="MinHeight" Value="6"/>
                        <Setter Property="Background" Value="#77F0F8FF"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ScrollBar}">
                                    <Grid x:Name="Bg" Background="#77DDDDDD" SnapsToDevicePixels="true">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Track x:Name="PART_Track"  IsEnabled="{TemplateBinding IsMouseOver}">
                                            <Track.DecreaseRepeatButton>
                                                <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                            </Track.DecreaseRepeatButton>
                                            <Track.IncreaseRepeatButton>
                                                <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                            </Track.IncreaseRepeatButton>
                                            <Track.Thumb>
                                                <Thumb Style="{StaticResource ScrollBarThumb}" />
                                            </Track.Thumb>
                                        </Track>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsEnabled" Value="false">
                                            <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Window.Resources>

    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Border Background="#FF3A4E66" CornerRadius="9,0,0,0">
            <Grid Margin="0,10">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <ContentControl Template="{StaticResource title_icon}" Width="24" Height="24" Margin="5,5,0,5"/>
                    <TextBlock x:Name="_TBTitle"  Text="历史报警查询" FontSize="16" Foreground="WhiteSmoke" Margin="5"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <ContentControl Width="24" Height="24" Margin="5" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" Tag="maximized" ToolTip="最大最小化" WindowChrome.IsHitTestVisibleInChrome="True">
                        <ContentControl.Style>
                            <Style TargetType="ContentControl">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=WindowState}" Value="Maximized">
                                        <Setter Property="Template" Value="{StaticResource unmaximize}"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=WindowState}" Value="Normal">
                                        <Setter Property="Template" Value="{StaticResource maximize}"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                    </ContentControl>
                    <ContentControl Width="24" Height="24" Template="{StaticResource close}" Background="WhiteSmoke" Margin="5" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" Tag="close" ToolTip="关闭" WindowChrome.IsHitTestVisibleInChrome="True"/>
                </StackPanel>
            </Grid>
        </Border>

        <WrapPanel Grid.Row="1" Background="#FFDDE6EF">
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="开始时间：" Style="{StaticResource TagTextBlockStyle}"/>
                <TextBox x:Name="_TBStartTime" Style="{StaticResource TagTextBoxStyle}" KeyDown="TextBox_KeyDown"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="结束时间：" Style="{StaticResource TagTextBlockStyle}"/>
                <TextBox x:Name="_TBEndTime" Style="{StaticResource TagTextBoxStyle}" KeyDown="TextBox_KeyDown"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="场站：" Style="{StaticResource TagTextBlockStyle}"/>
                <ComboBox x:Name="_CBStation" DisplayMemberPath="FullName" Style="{StaticResource TagComboBoxStyle}" SelectionChanged="_CBStation_SelectionChanged" SelectedIndex="0"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="级别：" Style="{StaticResource TagTextBlockStyle}"/>
                <ComboBox x:Name="_CBClass" DisplayMemberPath="Name" Style="{StaticResource TagComboBoxStyle}" SelectedIndex="0" SelectionChanged="_CBClass_SelectionChanged"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="类型：" Style="{StaticResource TagTextBlockStyle}"/>
                <ComboBox x:Name="_CBType" DisplayMemberPath="Name" Style="{StaticResource TagComboBoxStyle}" SelectedIndex="0" SelectionChanged="_CBType_SelectionChanged"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="子类型：" Style="{StaticResource TagTextBlockStyle}"/>
                <ComboBox x:Name="_CBSType" Style="{StaticResource TagComboBoxStyle}" DisplayMemberPath="Name" SelectionChanged="_CBSType_SelectionChanged"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="风机：" Style="{StaticResource TagTextBlockStyle}"/>
                <ComboBox x:Name="_CBWindturbine" Style="{StaticResource TagComboBoxStyle}" SelectionChanged="_CBWindturbine_SelectionChanged"/>
            </StackPanel>

            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="关键字：" Style="{StaticResource TagTextBlockStyle}"/>
                <TextBox x:Name="_CBKeyString" Style="{StaticResource TagTextBoxStyle}" LostFocus="_CBKeyString_LostFocus" VerticalAlignment="Stretch"/>
            </StackPanel>

            <Button Content="开始查询" VerticalAlignment="Center" Margin="10" Padding="12,3" Click="Button_Click" Tag="search" Style="{StaticResource ConfirmButtonStyle}"/>

            <Button Content="导出" VerticalAlignment="Center" Margin="10" Padding="12,3" Click="Button_Click" Tag="output" Style="{StaticResource ConfirmButtonStyle}"/>
        </WrapPanel>

        <DataGrid x:Name="_DGMain" FontSize="14" ColumnWidth="*" Grid.Row="2" Background="#FFABABAB" IsReadOnly="True" AutoGenerateColumns="False" HorizontalGridLinesBrush="#FF9E9E9E" VerticalGridLinesBrush="#FF9E9E9E">
            <DataGrid.Columns>
                <DataGridTextColumn Header="时间" Binding="{Binding AlertTimeTimeString}" Width="150"/>
                <DataGridTextColumn Header="设备" Binding="{Binding ObjectName}"/>
                <DataGridTextColumn Header="报警信息" Binding="{Binding AlertText}" MinWidth="300"/>
                <DataGridTextColumn Header="级别" Binding="{Binding RankString}"/>
                <DataGridTextColumn Header="报警类型" Binding="{Binding Category1String}"/>
                <DataGridTextColumn Header="停机类型"/>
                <DataGridTextColumn Header="故障类型"/>
                <DataGridTextColumn Header="故障原因"/>
            </DataGrid.Columns>
        </DataGrid>


        <ib:InfoBar x:Name="_IBMain" Grid.Row="3"/>
    </Grid>
</Window>
