<UserControl x:Class="NEIntelligentControl2.Views.Alarm.AlarmShowView"
             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"
             mc:Ignorable="d" 
             d:DesignHeight="581" d:DesignWidth="319" Width="319" MaxHeight="581" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <ControlTemplate x:Key="unfixed">
            <Viewbox>
                <Canvas Width="1024" Height="1024" Background="#01FFFFFF">
                    <Path Fill="#CC464646" Data="M187.690667 874.709333h-0.277334a37.504 37.504 0 0 1-26.602666-11.264 37.845333 37.845333 0 0 1-3.904-49.877333l166.762666-229.76-125.013333-125.056a38.229333 38.229333 0 0 1-6.058667-46.336 140.8 140.8 0 0 1 53.504-45.674667 154.24 154.24 0 0 1 67.84-15.552 161.792 161.792 0 0 1 51.84 8.533334l6.4 0.661333c5.781333 0.405333 10.901333 0.981333 15.701334 1.749333a161.877333 161.877333 0 0 0 104.277333-47.253333 144.874667 144.874667 0 0 0 58.474667-90.346667c0-5.802667 0-11.904-0.234667-17.664a80.576 80.576 0 0 1 15.658667-74.858666A84.949333 84.949333 0 0 1 626.858667 106.666667a85.525333 85.525333 0 0 1 54.08 19.328l1.962666 1.941333c18.88 18.432 207.253333 206.933333 209.066667 208.746667A85.930667 85.930667 0 0 1 917.333333 397.888a85.973333 85.973333 0 0 1-25.6 61.205333 67.456 67.456 0 0 1-46.549333 16.874667 199.210667 199.210667 0 0 1-30.229333-3.008 226.176 226.176 0 0 0-15.701334-0.362667h-1.493333a115.605333 115.605333 0 0 0-77.930667 45.205334 210.752 210.752 0 0 0-59.456 118.976c0.917333 7.850667 2.56 21.333333 2.858667 23.125333a144.298667 144.298667 0 0 1-57.258667 165.056 38.229333 38.229333 0 0 1-20.138666 5.717333 38.058667 38.058667 0 0 1-27.093334-11.2l-123.562666-123.733333L209.92 866.986667a36.266667 36.266667 0 0 1-22.229333 7.722666z"/>
                </Canvas>
            </Viewbox>
        </ControlTemplate>

        <ControlTemplate x:Key="fixed">
            <Viewbox>
                <Canvas Width="1024" Height="1024" Background="#01FFFFFF">
                    <Path Fill="#CC464646" Data="m559.42 1006.7-0.19651 0.1957a37.504 37.504 45 0 1-26.798 10.792 37.845 37.845 0 0 1-37.963-32.585l-43.975-280.47-176.83-0.3904a38.229 38.229 0 0 1-36.991-28.556 140.8 140.8 0 0 1 5.679-70.118 154.24 154.24 0 0 1 37.093-58.892 161.79 161.79 0 0 1 42.753-30.535l5.0014-4.0477c4.3824-3.7925 8.4166-6.9974 12.36-9.8404a161.88 161.88 0 0 0 40.54-107.07 144.87 144.87 0 0 0-22.322-105.28c-4.0947-4.1115-8.4002-8.4345-12.631-12.35a80.576 80.576 0 0 1-41.73-64.091 84.949 84.949 0 0 1 25.195-60.862 85.525 85.525 0 0 1 51.957-24.468l2.7606-9e-3c26.384-0.26304 292.87 0.37037 295.44 0.37559a85.931 85.931 0 0 1 61.163 25.467 85.973 85.973 0 0 1 25.052 61.432 67.456 67.456 0 0 1-21.074 44.805 199.21 199.21 0 0 1-23.542 19.2 226.18 226.18 0 0 0-11.381 10.823l-1.0581 1.0538a115.61 115.61 0 0 0-23.318 87.023 210.75 210.75 0 0 0 41.83 126.26c6.1899 4.9152 16.868 13.309 18.344 14.368a144.3 144.3 45 0 1 75.904 157.36 38.229 38.229 0 0 1-10.235 18.262 38.059 38.059 0 0 1-27.1 11.183l-174.86-0.47738-38.766 280.29a36.267 36.267 0 0 1-10.301 21.158z"/>
                </Canvas>
            </Viewbox>
        </ControlTemplate>
        
        <ControlTemplate x:Key="map">
            <Viewbox>
                <Canvas Width="1024" Height="1024" Background="#01FFFFFF">
                    <Path Fill="WhiteSmoke" Data="M129.28 911.36a40.94976 40.94976 0 0 1-40.96-40.96V256a40.96512 40.96512 0 0 1 25.74848-38.03136l256-102.4A40.96 40.96 0 0 1 426.24 153.6v614.4a40.96512 40.96512 0 0 1-25.74848 38.03136l-256 102.4a40.86784 40.86784 0 0 1-15.21152 2.92864z m40.96-627.63008v526.17216l174.08-69.632V214.09792l-174.08 69.632z"/>
                    <Path Fill="WhiteSmoke" Data="M638.71488 911.36a40.8576 40.8576 0 0 1-15.2064-2.92864l-256-102.4A40.96 40.96 0 0 1 341.76 768V153.6a40.97024 40.97024 0 0 1 56.17152-38.03136l256 102.4A40.96 40.96 0 0 1 679.68 256v614.4a40.96 40.96 0 0 1-40.96512 40.96zM423.68 740.27008l174.08 69.632V283.72992l-174.08-69.632v526.17216z"/>
                    <Path Fill="WhiteSmoke" Data="M638.72512 911.36a40.97024 40.97024 0 0 1-40.96512-40.96V256a40.96 40.96 0 0 1 25.74848-38.03136l256-102.4A40.97024 40.97024 0 0 1 935.68 153.6v614.4a40.96 40.96 0 0 1-25.74848 38.03136l-256 102.4a40.8576 40.8576 0 0 1-15.2064 2.92864z m40.95488-627.63008v526.17216l174.08-69.632V214.09792l-174.08 69.632z"/>
                </Canvas>
            </Viewbox>
        </ControlTemplate>

        <ControlTemplate x:Key="ok">
            <Viewbox>
                <Canvas Width="1024" Height="1024" Background="#01FFFFFF">
                    <Path Fill="WhiteSmoke" Data="M1001.216 128a2407.936 2407.936 0 0 0-559.104 480.384L224.384 438.912 128 515.84 503.808 896A2291.456 2291.456 0 0 1 1024 181.248l-22.784-52.992"/>
                </Canvas>
            </Viewbox>
        </ControlTemplate>
        
        <!--铃铛-->
        <ControlTemplate x:Key="bell">
            <Viewbox>
                <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="bell" Width="829.333" Height="922.667" Clip="F1 M 0,0L 829.333,0L 829.333,922.667L 0,922.667L 0,0">
                    <Canvas x:Name="bell_0" Width="829.333" Height="922.667" Canvas.Left="0" Canvas.Top="0">
                        <Path x:Name="Path" Width="818.366" Height="910.282" Canvas.Left="5.79712" Canvas.Top="8.43347" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M 802.735,609.532L 720.813,527.157L 720.813,324.177C 723.068,168.319 610.016,34.6774 455.937,11.0627C 368.459,-0.462646 280.251,26.2507 213.855,84.3707C 147.459,142.485 109.308,226.381 109.147,314.62L 109.147,527.157L 27.224,609.532C 6.18803,630.917 2.98818e-005,662.824 11.5214,690.527C 23.0374,718.224 50.0214,736.339 80.016,736.505L 232.937,736.505L 232.937,751.98C 237.36,848.177 318.771,922.667 414.98,918.553C 511.188,922.667 592.6,848.177 597.027,751.98L 597.027,736.505L 749.943,736.505C 779.943,736.339 806.923,718.224 818.443,690.527C 829.959,662.824 823.771,630.917 802.735,609.532 Z M 506,751.98C 500.761,797.459 460.647,830.756 414.98,827.532C 369.313,830.756 329.204,797.459 323.959,751.98L 323.959,736.505L 506,736.505"/>
                    </Canvas>
                </Canvas>
            </Viewbox>
        </ControlTemplate>
        
        <Style x:Key="ButtonStyleMain" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="bd" CornerRadius="3" Background="#FFDB5447">
                            <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 TargetName="bd" Property="Background" Value="#FFEC6254"/>
                            </Trigger>
                            <Trigger Property="IsMouseCaptured" Value="True">
                                <Setter TargetName="bd" Property="Background" Value="#FFDB5447"/>
                            </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="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>

        <DataTemplate x:Key="ListViewItemTemplate">
            <Grid x:Name="gbcenter" Background="#FFFE7A6F" Margin="0,2" Width="298" MinHeight="120">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid x:Name="gbtitle" Background="#FFE56155">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <ContentControl Template="{StaticResource bell}" HorizontalAlignment="Left" Width="19" Margin="3"/>
                    <TextBlock x:Name="tbtitle"  Grid.Column="1" Text="{Binding Title}" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="White" FontSize="14"/>
                    <TextBlock x:Name="tbtime" Grid.Column="1" Text="{Binding Time}" HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="White" Margin="2,0"/>
                </Grid>

                <TextBlock Grid.Row="1" x:Name="tbmsg" Text="{Binding Message}" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" TextWrapping="Wrap"/>

                <Grid Grid.Row="2" Margin="2">
                    <Button HorizontalAlignment="Left" Style="{DynamicResource ButtonStyleMain}" Tag="{Binding}" Click="Button_Click">
                        <StackPanel Orientation="Horizontal" Margin="7,2">
                            <ContentControl Width="24" Height="24" Template="{StaticResource map}" Margin="0,0,5,0"/>
                            <TextBlock Text="生成缺陷单" FontSize="14" VerticalAlignment="Center" Foreground="WhiteSmoke"/>
                        </StackPanel>
                    </Button>
                    <Button HorizontalAlignment="Right" Style="{DynamicResource ButtonStyleMain}" Tag="{Binding}" Click="Button_Click">
                        <StackPanel Orientation="Horizontal" Margin="7,2">
                            <ContentControl Width="24" Height="24" Template="{StaticResource ok}" Margin="0,0,5,0"/>
                            <TextBlock Text="确认" FontSize="14" VerticalAlignment="Center" Foreground="WhiteSmoke"/>
                        </StackPanel>
                    </Button>
                </Grid>
            </Grid>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsOpened}" Value="False">
                    <Setter TargetName="gbtitle" Property="Background" Value="#FFFF958C"/>
                    <Setter TargetName="gbcenter" Property="Background" Value="#FFFFC0BB"/>

                    <Setter TargetName="tbtitle" Property="Foreground" Value="Black"/>
                    <Setter TargetName="tbtime" Property="Foreground" Value="Black"/>
                    <Setter TargetName="tbmsg" Property="Foreground" Value="Black"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
        
        <Style x:Key="ListBoxItemContainerStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="Padding" Value="4,1"/>
            <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <UserControl.ContentTemplate>
        <DataTemplate>
            <Grid x:Name="_GDMain">
                <Grid x:Name="gdmain" Background="#FFA0A0A0" MinHeight="370">
                    <ListBox x:Name="_LBMain" ItemContainerStyle="{DynamicResource ListBoxItemContainerStyle}" ItemTemplate="{DynamicResource ListViewItemTemplate}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=Alarms}" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" Margin="0,25,0,0"/>
                </Grid>
                <ContentControl x:Name="cc" HorizontalAlignment="Right" VerticalAlignment="Top" MouseLeftButtonUp="cc_MouseLeftButtonUp" Width="25" Height="25" ToolTip="打开报警"/>
            </Grid>

            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=IsFixed}" Value="True">
                    <Setter TargetName="cc" Property="Template" Value="{DynamicResource fixed}"/>
                    <Setter TargetName="gdmain" Property="Visibility" Value="Visible"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=IsFixed}" Value="False">
                    <Setter TargetName="cc" Property="Template" Value="{DynamicResource unfixed}"/>
                    <Setter TargetName="gdmain" Property="Visibility" Value="Hidden"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </UserControl.ContentTemplate>
</UserControl>
