<UserControl x:Class="NEIntelligentControl2.Views.Alarm.WindturbineHistoryAlarm"
             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:NEIntelligentControl2.Views.Alarm"
             xmlns:ib="clr-namespace:NEIntelligentControl2.Views.Basic"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded">
    <UserControl.Resources>

        <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"/>
        </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="Red" 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>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <WrapPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="开始时间：" Style="{StaticResource TagTextBlockStyle}"/>
                <TextBox x:Name="_TBStartTime" Style="{StaticResource TagTextBoxStyle}" KeyDown="TextBox_KeyDown" VerticalAlignment="Center"/>
            </StackPanel>
            <StackPanel Style="{StaticResource TagStackPanelStyle}">
                <TextBlock Text="结束时间：" Style="{StaticResource TagTextBlockStyle}"/>
                <TextBox x:Name="_TBEndTime" Style="{StaticResource TagTextBoxStyle}" KeyDown="TextBox_KeyDown" VerticalAlignment="Center"/>
            </StackPanel>
            <Button Content="查 询" VerticalAlignment="Center" Padding="12,3" Click="Button_Click" Tag="ok" 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" SelectionUnit="CellOrRowHeader" ColumnWidth="*" Grid.Row="1" 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="2"/>
    </Grid>
</UserControl>
