<Window x:Class="NEIntelligentControl2.Windows.Alarm.DeviceDetailAlarmWindow"
        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"
        mc:Ignorable="d"
        x:Name="window"
        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="GenerateButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="Background" Value="#FFFE8864"/>
                <Setter Property="Foreground" Value="WhiteSmoke"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Padding" Value="17,6"/>
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Margin" Value="20,0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" CornerRadius="3">
                                <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="#FFFE9777"/>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="#FFFE8864"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="ConfirmButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="Background" Value="#FF006ACC"/>
                <Setter Property="Foreground" Value="WhiteSmoke"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Padding" Value="17,6"/>
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Margin" Value="20,0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" CornerRadius="3">
                                <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="#FF2E81CC"/>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="#FF006ACC"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </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/>
            <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>

        <DataGrid x:Name="_DGMain" Grid.Row="1" ColumnWidth="*" Background="#FFABABAB" AutoGenerateColumns="False" HorizontalGridLinesBrush="#FFA4A4A4" VerticalGridLinesBrush="#FFA4A4A4" SelectionUnit="Cell" CanUserAddRows="False" FontSize="14" SelectedCellsChanged="_DGMain_SelectedCellsChanged">
            <DataGrid.Columns>
                <DataGridCheckBoxColumn Binding="{Binding IsSelected}" Width="Auto"/>
                <DataGridTextColumn Header="时间" Binding="{Binding LastUpdateTimeString}" IsReadOnly="True"/>
                <DataGridTextColumn Header="报警信息" Binding="{Binding AlertText}" IsReadOnly="True" MinWidth="450"/>
                <DataGridTextColumn Header="级别" Binding="{Binding RankName}" IsReadOnly="True"/>
                <DataGridTextColumn Header="报警类型" IsReadOnly="True" Binding="{Binding CategoryName}"/>
               <!-- <DataGridTextColumn Header="停机类型" IsReadOnly="True" Binding="{Binding FaultCategory}"/>
                <DataGridTextColumn Header="故障类型" IsReadOnly="True" Binding="{Binding HaltType}"/>
                <DataGridTextColumn Header="故障原因" IsReadOnly="True" Binding="{Binding FaultCause}"/>-->
            </DataGrid.Columns>
        </DataGrid>

        <StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" Orientation="Horizontal">
            <StackPanel.Style>
                <Style TargetType="StackPanel">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=IsConfirm}" Value="True">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}, Path=IsConfirm}" Value="False">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
            <Button Content="生成缺陷单" Style="{DynamicResource GenerateButtonStyle}" Click="Button_Click" Tag="generate"/>
            <Button Content="确 认" Style="{DynamicResource ConfirmButtonStyle}" Click="Button_Click" Tag="ok"/>
        </StackPanel>
    </Grid>
</Window>
