<UserControl x:Class="NEIntelligentControl2.Views.Matrix.PVBlock"
             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.Matrix"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" MouseLeftButtonUp="UserControl_MouseLeftButtonUp">
    <UserControl.Resources>
        <SolidColorBrush x:Key="PowerRestrictionTextColor" Color="#FF7E7935"/>
        <SolidColorBrush x:Key="StandbyTextColor" Color="#FF69A953"/>
        <SolidColorBrush x:Key="GridConnectedTextColor" Color="#FF4B7F9E"/>
        <SolidColorBrush x:Key="WiteTextColor" Color="WhiteSmoke"/>
        <SolidColorBrush x:Key="OfflineTextColor" Color="#FF606C75"/>
    </UserControl.Resources>
    <UserControl.ContentTemplate>
        <DataTemplate>
            <Grid x:Name="_GDMain" ToolTip="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=ToolTipValue}">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="2.1*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="1">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <!--电流-->
                        <TextBlock x:Name="tbcurrent" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Current}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="12" Margin="0,0,3,0"/>
                        <!--电压-->
                        <TextBlock x:Name="tbvoltage" Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Voltage}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="12" Margin="0,0,3,0"/>
                        <!--功率-->
                        <TextBlock x:Name="tbpower" Grid.Row="2" Grid.Column="1" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Power}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="12" Margin="0,0,3,0"/>
                    </Grid>
                    <TextBlock x:Name="tbname" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=PVName}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13" Grid.RowSpan="3" FontWeight="Bold" Margin="5,0,0,0" TextWrapping="Wrap"/>
                </Grid>
                <Border x:Name="_GBottom" Grid.Row="1">
                    <TextBlock x:Name="tbstate" Foreground="WhiteSmoke" Margin="1"/>
                </Border>
            </Grid>
            <DataTemplate.Triggers>

                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=IsSmallModel}" Value="True">
                    <Setter TargetName="tbname" Property="FontSize" Value="10"/>
                    <Setter TargetName="tbcurrent" Property="FontSize" Value="10"/>
                    <Setter TargetName="tbvoltage" Property="FontSize" Value="10"/>
                    <Setter TargetName="tbpower" Property="FontSize" Value="10"/>

                    <Setter TargetName="_GDMain" Property="Margin" Value="2"/>
                    <Setter TargetName="_GDMain" Property="MaxWidth" Value="103"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=IsSmallModel}" Value="False">
                    <Setter TargetName="_GDMain" Property="Margin" Value="5"/>
                    <Setter TargetName="_GDMain" Property="MinHeight" Value="77"/>
                </DataTrigger>

                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="UnKnow">
                    <Setter TargetName="_GDMain" Property="Background" Value="DarkGray"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="DarkGray"/>


                    <Setter TargetName="tbname" Property="Foreground" Value="DarkGray"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="DarkGray"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="DarkGray"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="DarkGray"/>

                    <Setter TargetName="tbstate" Property="Text" Value="状态未知"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="Standby">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFCFF1E8"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFA7E094"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="待机状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="GridConnected">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC8EAFF"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF88CBE3"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="并网状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="Malfunction">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFDB3333"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFBA2424"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="故障状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="Offline">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC7D3DD"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFB6C3CE"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="离线状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="Maintain">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFFF720E"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFD35902"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="维护状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="Restriction">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFB0973F"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF7E7935"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="限电状态"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Status}" Value="RestrictionShutdown">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFB0973F"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF7E7935"/>

                    <Setter TargetName="tbname" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbcurrent" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbvoltage" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbpower" Property="Foreground" Value="{StaticResource PowerRestrictionTextColor}"/>
                    <Setter TargetName="tbstate" Property="Text" Value="限电停机状态"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </UserControl.ContentTemplate>
</UserControl>
