<Page x:Class="SWRIS.Pages.RealTime.FourRopesPage"
      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:SWRIS.Pages.RealTime" 
      xmlns:vm="clr-namespace:SWRIS.Models.ViewModel" 
      xmlns:cvt="clr-namespace:SWRIS.Converters"
      xmlns:ctr="clr-namespace:SWRIS.Controls" 
      xmlns:enum="clr-namespace:SWRIS.Enums"
      mc:Ignorable="d"  FontSize="20"
      Foreground="#FFFFFF"
      FontFamily="{StaticResource PuHuiTiRegular}"
      d:DesignHeight="900" d:DesignWidth="1920" 
      Title="FourRopesPage">
    <Page.DataContext>
        <vm:FourRopesViewModel/>
    </Page.DataContext>
    <Page.Resources>
        <cvt:RiskLevelToColorConverter x:Key="RiskLevelToColorConverter"/>
        <cvt:RiskLevelToTextConverter x:Key="RiskLevelToTextConverter"/>
        <cvt:ConnectivityFaultToColorConverter x:Key="ConnectivityFaultConverter"/>
        <cvt:CollectionCountToVisibilityConverter x:Key="CollectionCountToVisibilityConverter"/>
        <cvt:ConnectivityToVisibilityConverter x:Key="ConnectivityToVisibilityConverter"/>
        <cvt:StringEmptyToVisibilityConverter x:Key="StringEmptyToVisibilityConverter"/>
    </Page.Resources>
    <Grid Margin="25,30,25,7">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="370"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Grid.Column="0" CornerRadius="10"  Margin="0,0,15,15" DataContext="{Binding FirstEquipmentData}">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#2a2956" Offset="0"/>
                    <GradientStop Color="#161536" Offset="0.40"/>
                    <GradientStop Color="#1f1e44" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="200"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="210"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0" Margin="30,20,10,0">
                    <DockPanel>
                        <!--钢丝绳状态及名称-->
                        <Rectangle Height="20" Width="16" RadiusX="6" RadiusY="6">
                            <Rectangle.Fill>
                                <MultiBinding Converter="{StaticResource ConnectivityFaultConverter}">
                                    <Binding Path="IsConnect"/>
                                    <Binding Path="Faults"/>
                                </MultiBinding>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Text="{Binding RopeName}" FontSize="24" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" 
                                   Margin="10,0" VerticalAlignment="Center"/>
                        <StackPanel Orientation="Horizontal" MouseLeftButtonDown="FirstParameterSetting_MouseDown" Cursor="Hand">
                            <Image Source="/Resources/eqSet.png" Margin="10,0,5,0" Width="20" Height="20"/>
                            <TextBlock Text="参数设置" FontSize="18" VerticalAlignment="Center" Foreground="#8D86E5" FontWeight="Regular"/>
                        </StackPanel>
                        <!--消息通知-->
                        <ctr:NotificationBar Height="35" MaxWidth="240" FontSize="20" HorizontalAlignment="Right"
                                      Messages="{Binding Messages}" Margin="0,0,-120,0"/>
                    </DockPanel>
                    <StackPanel Margin="0,20">
                        <UniformGrid Columns="2" Rows="2" Width="400" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="风险等级" Foreground="#7886B2"/>
                                <TextBlock  FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" 
                                           Text="{Binding RiskLevel,Converter={StaticResource RiskLevelToTextConverter}}" 
                                           Foreground="{Binding RiskLevel,Converter={StaticResource RiskLevelToColorConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="起升高度"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="40,0">
                                    <Run Text="{Binding LiftHeight,StringFormat=#0.0}"/>
                                    <Run Text="m"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="损伤数量"  Foreground="#7886B2"/>
                                <TextBlock Text="{Binding DamageCount}"   Foreground="#FFFFFF" FontWeight="Bold"  
                                           FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" />
                                <TextBlock Text="详情" Foreground="#7F74FF" FontSize="18" FontWeight="Regular"
                                           Cursor="Hand"  MouseLeftButtonDown="FirstEquipmentAlarm_MouseDown" 
                                           Visibility="{Binding DamageCount,Converter={StaticResource CollectionCountToVisibilityConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="最大损伤值"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0">
                                    <Run Text="{Binding MaxDamageValue,StringFormat=#0.0}"/>
                                    <Run Text="%"/>
                                </TextBlock>
                            </StackPanel>
                        </UniformGrid>
                        <ctr:DamageRangeControl HorizontalAlignment="Stretch" Height="40" FontSize="16" Margin="0,20,30,0" 
                                                MildCount="{Binding MildCount}" LightCount="{Binding LightCount}" 
                                                ModerateCount="{Binding ModerateCount}" SevereCount="{Binding SevereCount}"
                                                CriticalCount="{Binding CriticalCount}" ExtremeCount="{Binding ExtremeCount}"/>
                    </StackPanel>
                </StackPanel>
                <ctr:RopeEquipmentControl Grid.RowSpan="2" Grid.Column="1" Grid.Row="0"
                                          PanelMargin="-80,30,0,0"
                                          EquipmentTopPosition="160"
                                          PanelNameFontSize="18"
                                          PanelValueFontSize="20"
                                          RopeImageSource="/Resources/rope_block.png" 
                                          EquipmentImageSource="/Resources/equipment.png"
                                          AnimationDuration="0.5" RopeHeight="435">
                    <ctr:RopeEquipmentControl.Style>
                        <Style TargetType="ctr:RopeEquipmentControl">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Stoped}">
                                    <Setter Property="IsAnimationRunning" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Forward}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Reverse}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ctr:RopeEquipmentControl.Style>
                </ctr:RopeEquipmentControl>

                <ctr:RealTimeLineChart x:Name="firstChartLine" Grid.Row="1" 
                               Margin="0,0,-90,-5"  
                               SensorCount="{Binding SensorCount}"
                               SamplingStep="{Binding SamplingStep,Mode=TwoWay}"
                               RopeLength="{Binding RopeLength}"/>

                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="20,-5,-100,3" 
                            Visibility="{Binding DebugMessage.Message,Converter={StaticResource StringEmptyToVisibilityConverter}}">
                    <TextBlock Style="{StaticResource HeartbeatTextBlockStyle}"  FontSize="17"
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding  DebugMessage.DateTime,StringFormat=HH:mm:ss}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center" 
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding DebugMessage.Message}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                </StackPanel>
            </Grid>
        </Border>
        <Border Grid.Row="0" Grid.Column="1" CornerRadius="10"  Margin="15,0,0,15" DataContext="{Binding SecondEquipmentData}">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#2a2956" Offset="0"/>
                    <GradientStop Color="#161536" Offset="0.40"/>
                    <GradientStop Color="#1f1e44" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="200"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="210"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0"  Margin="30,20,10,0">
                    <DockPanel>
                        <!--钢丝绳状态及名称-->
                        <Rectangle Height="20" Width="16" RadiusX="6" RadiusY="6">
                            <Rectangle.Fill>
                                <MultiBinding Converter="{StaticResource ConnectivityFaultConverter}">
                                    <Binding Path="IsConnect"/>
                                    <Binding Path="Faults"/>
                                </MultiBinding>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Text="{Binding RopeName}" FontSize="24" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" 
                                   Margin="13,0" VerticalAlignment="Center"/>
                            <StackPanel Orientation="Horizontal" MouseLeftButtonDown="SecondParameterSetting_MouseDown" Cursor="Hand">
                            <Image Source="/Resources/eqSet.png" Margin="10,0,5,0" Width="20" Height="20"/>
                            <TextBlock Text="参数设置" FontSize="18" VerticalAlignment="Center" Foreground="#8D86E5" FontWeight="Regular"/>
                        </StackPanel>
                        <!--消息通知-->
                        <ctr:NotificationBar Height="35" MaxWidth="240" FontSize="20" HorizontalAlignment="Right"
                                Messages="{Binding Messages}"/>
                    </DockPanel>
                    <StackPanel Margin="0,20">
                        <UniformGrid Columns="2" Rows="2" Width="400" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="风险等级"  Foreground="#7886B2"/>
                                <TextBlock  FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" 
                                           Text="{Binding RiskLevel,Converter={StaticResource RiskLevelToTextConverter}}" 
                                           Foreground="{Binding RiskLevel,Converter={StaticResource RiskLevelToColorConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="起升高度"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="40,0">
                                    <Run Text="{Binding LiftHeight,StringFormat=#0.0}"/>
                                    <Run Text="m"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="损伤数量"  Foreground="#7886B2"/>
                                <TextBlock Text="{Binding DamageCount}"   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" />
                                <TextBlock Text="详情" Foreground="#7F74FF" FontSize="18" FontWeight="Regular"
                                           Cursor="Hand"  MouseLeftButtonDown="SecondEquipmentAlarm_MouseDown" 
                                           Visibility="{Binding DamageCount,Converter={StaticResource CollectionCountToVisibilityConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="最大损伤值"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0">
                                    <Run Text="{Binding MaxDamageValue,StringFormat=#0.0}"/>
                                    <Run Text="%"/>
                                </TextBlock>
                            </StackPanel>
                        </UniformGrid>
                        <ctr:DamageRangeControl HorizontalAlignment="Stretch" Height="40" FontSize="16" Margin="0,20,30,0"
                                                MildCount="{Binding MildCount}" LightCount="{Binding LightCount}" 
                                                ModerateCount="{Binding ModerateCount}" SevereCount="{Binding SevereCount}"
                                                CriticalCount="{Binding CriticalCount}" ExtremeCount="{Binding ExtremeCount}"/>
                    </StackPanel>
                </StackPanel>
                <ctr:RopeEquipmentControl Grid.RowSpan="2" Grid.Column="1" Grid.Row="0"
                                          PanelMargin="-80,30,0,0"
                                          EquipmentTopPosition="160"
                                          PanelNameFontSize="18"
                                          PanelValueFontSize="20"
                                          RopeImageSource="/Resources/rope_block.png" 
                                          EquipmentImageSource="/Resources/equipment.png"
                                          AnimationDuration="0.5" RopeHeight="435">
                    <ctr:RopeEquipmentControl.Style>
                        <Style TargetType="ctr:RopeEquipmentControl">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Stoped}">
                                    <Setter Property="IsAnimationRunning" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Forward}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Reverse}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ctr:RopeEquipmentControl.Style>
                </ctr:RopeEquipmentControl>
                <ctr:RealTimeLineChart x:Name="secondChartLine" Grid.Row="1" 
                               Margin="0,0,-90,-5"  
                               SensorCount="{Binding SensorCount}"
                               SamplingStep="{Binding SamplingStep,Mode=TwoWay}"
                               RopeLength="{Binding RopeLength}"/>

                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="20,-5,-100,3" 
                            Visibility="{Binding DebugMessage.Message,Converter={StaticResource StringEmptyToVisibilityConverter}}">
                    <TextBlock Style="{StaticResource HeartbeatTextBlockStyle}"  FontSize="17"
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding  DebugMessage.DateTime,StringFormat=HH:mm:ss}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center" 
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding DebugMessage.Message}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                </StackPanel>

            </Grid>
        </Border>
        <Border Grid.Row="1" Grid.Column="0" CornerRadius="10"  Margin="0,15,15,0" DataContext="{Binding ThirdEquipmentData}">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#2a2956" Offset="0"/>
                    <GradientStop Color="#161536" Offset="0.40"/>
                    <GradientStop Color="#1f1e44" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="200"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="210"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0" Margin="30,20,10,0">
                    <DockPanel>
                        <!--钢丝绳状态及名称-->
                        <Rectangle Height="20" Width="16" RadiusX="6" RadiusY="6">
                            <Rectangle.Fill>
                                <MultiBinding Converter="{StaticResource ConnectivityFaultConverter}">
                                    <Binding Path="IsConnect"/>
                                    <Binding Path="Faults"/>
                                </MultiBinding>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Text="{Binding RopeName}" FontSize="24" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="13,0" VerticalAlignment="Center"/>
                        <StackPanel Orientation="Horizontal" MouseLeftButtonDown="ThirdParameterSetting_MouseDown" Cursor="Hand">
                            <Image Source="/Resources/eqSet.png" Margin="10,0,5,0" Width="20" Height="20"/>
                            <TextBlock Text="参数设置" FontSize="18" VerticalAlignment="Center" Foreground="#8D86E5" FontWeight="Regular"/>
                        </StackPanel>
                        <!--消息通知-->
                        <ctr:NotificationBar Height="35" MaxWidth="240" FontSize="20" HorizontalAlignment="Right" Messages="{Binding Messages}"/>
                    </DockPanel>
                    <StackPanel Margin="0,20">
                        <UniformGrid Columns="2" Rows="2" Width="400" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="风险等级"  Foreground="#7886B2"/>
                                <TextBlock  FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" 
                                           Text="{Binding RiskLevel,Converter={StaticResource RiskLevelToTextConverter}}" 
                                           Foreground="{Binding RiskLevel,Converter={StaticResource RiskLevelToColorConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="起升高度"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="40,0">
                                    <Run Text="{Binding LiftHeight,StringFormat=#0.0}"/>
                                    <Run Text="m"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="损伤数量"  Foreground="#7886B2"/>
                                <TextBlock Text="{Binding DamageCount}"   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" />
                                <TextBlock Text="详情" Foreground="#7F74FF" FontSize="18" FontWeight="Regular"
                                           Cursor="Hand"  MouseLeftButtonDown="ThirdEquipmentAlarm_MouseDown" 
                                           Visibility="{Binding DamageCount,Converter={StaticResource CollectionCountToVisibilityConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="最大损伤值"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0">
                                    <Run Text="{Binding MaxDamageValue,StringFormat=#0.0}"/>
                                    <Run Text="%"/>
                                </TextBlock>
                            </StackPanel>
                        </UniformGrid>
                        <ctr:DamageRangeControl HorizontalAlignment="Stretch" Height="40" FontSize="16" Margin="0,20,30,0"
                                                MildCount="{Binding MildCount}" LightCount="{Binding LightCount}" 
                                                ModerateCount="{Binding ModerateCount}" SevereCount="{Binding SevereCount}"
                                                CriticalCount="{Binding CriticalCount}" ExtremeCount="{Binding ExtremeCount}"/>
                    </StackPanel>
                </StackPanel>
                <ctr:RopeEquipmentControl Grid.RowSpan="2" Grid.Column="1" Grid.Row="0"
                                          PanelMargin="-80,30,0,0"
                                          EquipmentTopPosition="160"
                                          PanelNameFontSize="18"
                                          PanelValueFontSize="20"
                                          RopeImageSource="/Resources/rope_block.png" 
                                          EquipmentImageSource="/Resources/equipment.png"
                                          AnimationDuration="0.5" RopeHeight="435">
                    <ctr:RopeEquipmentControl.Style>
                        <Style TargetType="ctr:RopeEquipmentControl">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Stoped}">
                                    <Setter Property="IsAnimationRunning" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Forward}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Reverse}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ctr:RopeEquipmentControl.Style>
                </ctr:RopeEquipmentControl>
                <ctr:RealTimeLineChart x:Name="thirdChartLine" Grid.Row="1"  Margin="0,0,-90,-5"  
                                       SensorCount="{Binding SensorCount}"
                                       SamplingStep="{Binding SamplingStep,Mode=TwoWay}"
                                       RopeLength="{Binding RopeLength}"/>

                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="20,-5,-100,3"
                            Visibility="{Binding DebugMessage.Message,Converter={StaticResource StringEmptyToVisibilityConverter}}">
                    <TextBlock Style="{StaticResource HeartbeatTextBlockStyle}"  FontSize="17"
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding DebugMessage.DateTime,StringFormat=HH:mm:ss}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center" 
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding DebugMessage.Message}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                </StackPanel>
            </Grid>
        </Border>
        <Border Grid.Row="1" Grid.Column="1" CornerRadius="10" Margin="15,15,0,0" DataContext="{Binding FourthEquipmentData}">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#2a2956" Offset="0"/>
                    <GradientStop Color="#161536" Offset="0.40"/>
                    <GradientStop Color="#1f1e44" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="200"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="210"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0"  Margin="30,20,10,0">
                    <DockPanel>
                        <!--钢丝绳状态及名称-->
                        <Rectangle Height="20" Width="16" RadiusX="6" RadiusY="6">
                            <Rectangle.Fill>
                                <MultiBinding Converter="{StaticResource ConnectivityFaultConverter}">
                                    <Binding Path="IsConnect"/>
                                    <Binding Path="Faults"/>
                                </MultiBinding>
                            </Rectangle.Fill>
                        </Rectangle>
                        <TextBlock Text="{Binding RopeName}" FontSize="24" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="13,0" VerticalAlignment="Center"/>
                        <StackPanel Orientation="Horizontal" MouseLeftButtonDown="FourthParameterSetting_MouseDown" Cursor="Hand">
                            <Image Source="/Resources/eqSet.png" Margin="10,0,5,0" Width="20" Height="20"/>
                            <TextBlock Text="参数设置" FontSize="18" VerticalAlignment="Center" Foreground="#8D86E5" FontWeight="Regular"/>
                        </StackPanel>
                        <!--消息通知-->
                        <ctr:NotificationBar Height="35" MaxWidth="250" FontSize="20" Margin="0,0,-120,0" TextPadding="8,4"
                                             CornerRadius="15"
                                             HorizontalAlignment="Right" Messages="{Binding Messages}"/>
                    </DockPanel>
                    <StackPanel Margin="0,20">
                        <UniformGrid Columns="2" Rows="2" Width="400" HorizontalAlignment="Left">
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="风险等级"  Foreground="#7886B2"/>
                                <TextBlock  FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" 
                                           Text="{Binding RiskLevel,Converter={StaticResource RiskLevelToTextConverter}}" 
                                           Foreground="{Binding RiskLevel,Converter={StaticResource RiskLevelToColorConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="起升高度"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="40,0">
                                    <Run Text="{Binding LiftHeight,StringFormat=#0.0}"/>
                                    <Run Text="m"/>
                                </TextBlock>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="损伤数量"  Foreground="#7886B2"/>
                                <TextBlock Text="{Binding DamageCount}"   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0" />
                                <TextBlock Text="详情" Foreground="#7F74FF" FontSize="18" FontWeight="Regular"
                                           Cursor="Hand"  MouseLeftButtonDown="FourthEquipmentAlarm_MouseDown" 
                                           Visibility="{Binding DamageCount,Converter={StaticResource CollectionCountToVisibilityConverter}}"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,2">
                                <TextBlock Text="最大损伤值"  Foreground="#7886B2"/>
                                <TextBlock   Foreground="#FFFFFF" FontWeight="Bold"  FontFamily="{StaticResource PuHuiTiBold}" Margin="20,0">
                                    <Run Text="{Binding MaxDamageValue,StringFormat=#0.0}"/>
                                    <Run Text="%"/>
                                </TextBlock>
                            </StackPanel>
                        </UniformGrid>
                        <ctr:DamageRangeControl HorizontalAlignment="Stretch" Height="40" FontSize="16" Margin="0,20,30,0"
                                                MildCount="{Binding MildCount}" LightCount="{Binding LightCount}" 
                                                ModerateCount="{Binding ModerateCount}" SevereCount="{Binding SevereCount}"
                                                CriticalCount="{Binding CriticalCount}" ExtremeCount="{Binding ExtremeCount}"/>
                    </StackPanel>
                </StackPanel>
                <ctr:RopeEquipmentControl Grid.RowSpan="2" Grid.Column="1" Grid.Row="0" 
                                          PanelMargin="-80,30,0,0"
                                          EquipmentTopPosition="160"
                                          PanelNameFontSize="18"
                                          PanelValueFontSize="20"
                                          RopeImageSource="/Resources/rope_block.png" 
                                          EquipmentImageSource="/Resources/equipment.png"
                                          AnimationDuration="0.5" RopeHeight="435">
                    <ctr:RopeEquipmentControl.Style>
                        <Style TargetType="ctr:RopeEquipmentControl">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Stoped}">
                                    <Setter Property="IsAnimationRunning" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Forward}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="False"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Direction}" Value="{x:Static enum:DirectionState.Reverse}">
                                    <Setter Property="IsAnimationRunning" Value="True"/>
                                    <Setter Property="IsAnimationReversed" Value="True"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ctr:RopeEquipmentControl.Style>
                </ctr:RopeEquipmentControl>
                <ctr:RealTimeLineChart x:Name="fourthChartLine" Grid.Row="1" 
                                       Margin="0,0,-90,-5"
                                       SensorCount="{Binding SensorCount}"
                                       SamplingStep="{Binding SamplingStep,Mode=TwoWay}"
                                       RopeLength="{Binding RopeLength}"/>

                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="20,-5,-100,3" 
                            Visibility="{Binding DebugMessage.Message,Converter={StaticResource StringEmptyToVisibilityConverter}}">
                    <TextBlock Style="{StaticResource HeartbeatTextBlockStyle}"  FontSize="17"
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding  DebugMessage.DateTime,StringFormat=HH:mm:ss}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center" 
                               Foreground="#7F74FF"/>
                    <TextBlock Text="{Binding DebugMessage.Message}" FontSize="16" Margin="5,0" 
                               VerticalAlignment="Center"
                               Foreground="#7F74FF"/>
                </StackPanel>
            </Grid>
        </Border>
        <ctr:DamageRecordControl Grid.Column="2" Grid.RowSpan="2" Margin="25,0,0,0" Records="{Binding Records}" Title="近期记录"/>
    </Grid>
</Page>
