<UserControl x:Class="NEIntelligentControl2.Views.Matrix.WindBlock"
             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="120" d:DesignWidth="300" SizeChanged="UserControl_SizeChanged" MinHeight="108" MouseRightButtonUp="UserControl_MouseRightButtonUp" MouseLeftButtonDown="UserControl_MouseLeftButtonDown" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Res/Matrix.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <SolidColorBrush x:Key="StopedTextColor" 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"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.ContentTemplate>
        <DataTemplate>
            <Grid x:Name="_GDMain" Margin="5" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=ToolTipValue}">
                <Grid x:Name="_GDContent">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <TextBlock x:Name="_WindturbineName" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=WindturbineName}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="17" Grid.RowSpan="3" FontWeight="Bold" Margin="17,0,0,0"/>
                        <!--风速-->
                        <TextBlock x:Name="_WindSpeed" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=WindSpeed}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" Margin="0,0,17,0" FontWeight="Bold"/>
                        <!--功率-->
                        <TextBlock x:Name="_Power" Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=Power}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" Margin="0,0,17,0" FontWeight="Bold"/>
                        <!--转速-->
                        <TextBlock x:Name="_RollSpeed" Grid.Row="2" Grid.Column="1" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=RotateSpeed}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" Margin="0,0,17,0" FontWeight="Bold"/>
                    </Grid>
                    <Grid Grid.Row="1" x:Name="_GBottom" MinHeight="24">
                        <StackPanel x:Name="_SPNormal" Visibility="Collapsed" Orientation="Horizontal">
                            <ContentControl Width="17" Height="17" Template="{StaticResource time}" Margin="2,0"/>

                            <ContentControl Visibility="Collapsed" Margin="2,0" x:Name="start1"  Width="19" Height="17" Template="{StaticResource start1}"/>
                            <ContentControl Visibility="Collapsed" Margin="2,0" x:Name="start2" Width="19" Height="17" Template="{StaticResource start2}"/>
                            <ContentControl Margin="2,0" Visibility="Collapsed" x:Name="locked" Width="16" Height="16" Template="{StaticResource lock2}"/>
                        </StackPanel>
                        <StackPanel x:Name="_SPMouseOver" Visibility="Collapsed" Orientation="Horizontal">
                            <StackPanel.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#CC000000" Offset="1"/>
                                    <GradientStop Color="#7F000000" Offset="0.7"/>
                                    <GradientStop Color="Transparent" Offset="0"/>
                                </LinearGradientBrush>
                            </StackPanel.Background>
                            <ContentControl MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown" Width="17" Height="17" Margin="2,0" ToolTip="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=ToolTipValue}" Template="{StaticResource time}" Tag="time"/>
                            <ContentControl x:Name="start"  Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="启动" Tag="Start" Template="{StaticResource start}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="stop" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="停机" Tag="Stop" Template="{StaticResource stop}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="reset" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="复位" Tag="Reset" Template="{StaticResource reset}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="maintain" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="维护" Tag="Maintain" Template="{StaticResource maintain}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="unmaintain" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="取消维护" Tag="UnMaintain" Template="{StaticResource unmaintain}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="send" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="发送" Tag="" Template="{StaticResource send}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="lock" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="挂牌" Tag="Lock" Template="{StaticResource lock}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                            <ContentControl x:Name="unlock" Width="17" Height="17" Visibility="Collapsed" Margin="2,0" ToolTip="取消挂牌" Tag="UnLock" Template="{StaticResource unlock}" MouseLeftButtonUp="ContentControl_MouseLeftButtonUp" MouseLeftButtonDown="ContentControl_MouseLeftButtonDown"/>
                        </StackPanel>
                    </Grid>
                    <!--风机名称-->
                </Grid>
                <TextBlock x:Name="_WindturbineName2" Text="{Binding RelativeSource={ RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=WindturbineName}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Grid.RowSpan="3" FontWeight="Bold"/>
            </Grid>
            <!--卡片颜色-->
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=IsSelected}" Value="True">
                    <Setter TargetName="_GDContent" Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=IsSelected}" Value="False">
                    <Setter TargetName="_WindturbineName2" Property="Visibility" Value="Collapsed"/>
                </DataTrigger>

                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="_SPMouseOver" Property="Visibility" Value="Visible"/>
                </Trigger>

                <Trigger Property="IsMouseOver" Value="False">
                    <Setter TargetName="_SPNormal" Property="Visibility" Value="Visible"/>
                </Trigger>

                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="Stoped">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFB0973F"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF7E7935"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource StopedTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource StopedTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource StopedTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource StopedTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource StopedTextColor}"/>


                    <!--<Setter TargetName="start" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="maintain" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/>-->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="PowerOn">

                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC8EAFF"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF88CBE3"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>

                    <Setter TargetName="start2" Property="Visibility" Value="Visible"/>

                    <!--<Setter TargetName="stop" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="Standby">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC8EAFF"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF88CBE3"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    
                    <!--<Setter TargetName="start" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="maintain" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="StartUp">

                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC8EAFF"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FF88CBE3"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource GridConnectedTextColor}"/>

                    <Setter TargetName="start1" Property="Visibility" Value="Visible"/>

                    <!--<Setter TargetName="stop" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="GridConnected">

                    <Setter TargetName="_GDMain" Property="Background" Value="#FFCFF1E8"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFA7E094"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource StandbyTextColor}"/>

                    <!--<Setter TargetName="stop" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="Malfunction">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFDB3333"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFBA2424"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource WiteTextColor}"/>

                    <!--<Setter TargetName="reset" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="Maintain">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFFF720E"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFD35902"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource WiteTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource WiteTextColor}"/>

                    <!--<Setter TargetName="unmaintain" Property="Visibility" Value="Visible"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Visible"/> -->
                </DataTrigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=CardState}" Value="Offline">
                    <Setter TargetName="_GDMain" Property="Background" Value="#FFC7D3DD"/>
                    <Setter TargetName="_GBottom" Property="Background" Value="#FFB6C3CE"/>

                    <Setter TargetName="_WindturbineName" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="_WindSpeed" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="_Power" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="_RollSpeed" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                    <Setter TargetName="_WindturbineName2" Property="Foreground" Value="{StaticResource OfflineTextColor}"/>
                </DataTrigger>


                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=IsLocked}" Value="True">
                    <Setter TargetName="locked" Property="Visibility" Value="Visible"/>

                    <Setter TargetName="start" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="reset" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="maintain" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="unmaintain" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="send" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="lock" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="stop" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="unlock" Property="Visibility" Value="Visible"/>
                </DataTrigger>

                <!--2MW 没有维护操作-->
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=ModelId}" Value="UP105-2000-S">
                    <Setter TargetName="maintain" Property="Visibility" Value="Collapsed"/>
                    <Setter TargetName="unmaintain" Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </UserControl.ContentTemplate>
</UserControl>
