DamageRecordControl.xaml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <UserControl x:Class="SWRIS.Controls.DamageRecordControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:SWRIS.Controls" xmlns:cvt="clr-namespace:SWRIS.Converters"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800">
  9. <UserControl.Resources>
  10. <cvt:RiskLevelToColorConverter x:Key="RiskLevelToColorConverter"/>
  11. <cvt:RiskLevelToTextConverter x:Key="RiskLevelToTextConverter"/>
  12. <cvt:SubtractConverter x:Key="SubtractConverter"/>
  13. <Storyboard x:Key="NewItemGlowAnimation" RepeatBehavior="3x">
  14. <DoubleAnimation
  15. Storyboard.TargetProperty="Effect.Opacity"
  16. From="0" To="0.7" Duration="0:0:0.20"
  17. AutoReverse="True"/>
  18. </Storyboard>
  19. </UserControl.Resources>
  20. <Border CornerRadius="10" Background="#1e1d43">
  21. <StackPanel Orientation="Vertical">
  22. <Border CornerRadius="10">
  23. <Border.Background>
  24. <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
  25. <GradientStop Color="#1f1e44" Offset="0"/>
  26. <GradientStop Color="#36366d" Offset="1"/>
  27. </LinearGradientBrush>
  28. </Border.Background>
  29. <TextBlock Text="{Binding Title, RelativeSource={RelativeSource AncestorType=UserControl}}"
  30. HorizontalAlignment="Center" FontSize="22" FontFamily="{StaticResource PuHuiTiBold}" FontWeight="Bold" Margin="14" />
  31. </Border>
  32. <ScrollViewer VerticalScrollBarVisibility="Hidden" Margin="25,8,25,0"
  33. MaxHeight="{Binding RelativeSource={RelativeSource AncestorType=UserControl},
  34. Path=ActualHeight, Converter={StaticResource SubtractConverter}, ConverterParameter=67.5}">
  35. <StackPanel Orientation="Vertical">
  36. <ItemsControl ItemsSource="{Binding Records, RelativeSource={RelativeSource AncestorType=UserControl}}">
  37. <ItemsControl.ItemTemplate>
  38. <DataTemplate>
  39. <Border Background="{Binding RiskLevel, Converter={StaticResource RiskLevelToColorConverter}, ConverterParameter=0.15}"
  40. CornerRadius="10" Height="110" Width="295" Margin="0,7">
  41. <Border.Effect>
  42. <DropShadowEffect x:Name="GlowEffect"
  43. ShadowDepth="0"
  44. BlurRadius="1"
  45. Color="#00ffff"
  46. Opacity="0"/>
  47. </Border.Effect>
  48. <!-- 新项发光触发器 -->
  49. <Border.Style>
  50. <Style TargetType="Border">
  51. <Style.Triggers>
  52. <DataTrigger Binding="{Binding IsNew}" Value="True">
  53. <DataTrigger.EnterActions>
  54. <BeginStoryboard Storyboard="{StaticResource NewItemGlowAnimation}"/>
  55. </DataTrigger.EnterActions>
  56. </DataTrigger>
  57. </Style.Triggers>
  58. </Style>
  59. </Border.Style>
  60. <!-- 鼠标悬停触发器 -->
  61. <Border.Triggers>
  62. <EventTrigger RoutedEvent="MouseEnter">
  63. <BeginStoryboard>
  64. <Storyboard>
  65. <DoubleAnimation
  66. Storyboard.TargetProperty="Effect.Opacity"
  67. From="0" To="0.7" Duration="0:0:0.20"
  68. AutoReverse="True" RepeatBehavior="1x"/>
  69. </Storyboard>
  70. </BeginStoryboard>
  71. </EventTrigger>
  72. <EventTrigger RoutedEvent="MouseLeave">
  73. <BeginStoryboard>
  74. <Storyboard>
  75. <DoubleAnimation
  76. Storyboard.TargetProperty="Effect.Opacity"
  77. To="0" Duration="0:0:0.1"/>
  78. </Storyboard>
  79. </BeginStoryboard>
  80. </EventTrigger>
  81. </Border.Triggers>
  82. <StackPanel Orientation="Horizontal">
  83. <!-- 风险等级指示器 -->
  84. <Border CornerRadius="10" Width="35" Height="110"
  85. Background="{Binding RiskLevel, Converter={StaticResource RiskLevelToColorConverter}, ConverterParameter=0.8}">
  86. <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
  87. <TextBlock FontSize="18" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiBold}"
  88. Text="{Binding RiskLevel, Converter={StaticResource RiskLevelToTextConverter}, ConverterParameter=0}"/>
  89. <TextBlock FontSize="18" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiBold}"
  90. Text="{Binding RiskLevel, Converter={StaticResource RiskLevelToTextConverter}, ConverterParameter=1}"/>
  91. </StackPanel>
  92. </Border>
  93. <!-- 内容区域 -->
  94. <StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="18,0" Tag="{Binding Id}"
  95. MouseLeftButtonDown="Record_MouseDown" Cursor="Hand">
  96. <TextBlock Text="{Binding RopeName}" FontSize="18" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiBold}"
  97. Margin="0,5,0,8"
  98. Foreground="{Binding RiskLevel, Converter={StaticResource RiskLevelToColorConverter}}"/>
  99. <TextBlock Text="{Binding Time, StringFormat='yyyy/MM/dd HH:mm:ss'}" FontSize="18"
  100. Foreground="{Binding RiskLevel, Converter={StaticResource RiskLevelToColorConverter}}"/>
  101. <TextBlock Text="{Binding Description}" FontSize="18" Margin="0,0,0,3"
  102. Foreground="{Binding RiskLevel, Converter={StaticResource RiskLevelToColorConverter}}"/>
  103. </StackPanel>
  104. </StackPanel>
  105. </Border>
  106. </DataTemplate>
  107. </ItemsControl.ItemTemplate>
  108. </ItemsControl>
  109. </StackPanel>
  110. </ScrollViewer>
  111. </StackPanel>
  112. </Border>
  113. </UserControl>