FlowPipeV2.xaml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <UserControl x:Class="Aitex.Core.UI.Control.FlowPipeV2"
  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:ctrl="clr-namespace:Aitex.Core.Util"
  6. Name="flowPipeControl" Width="100" Height="8">
  7. <UserControl.RenderTransform>
  8. <RotateTransform Angle="0" x:Name="rotateTransform"/>
  9. </UserControl.RenderTransform>
  10. <Canvas MinHeight="4" MinWidth="100">
  11. <Canvas.Resources>
  12. <Style x:Key="AnimatingFlow" TargetType="{x:Type Path}">
  13. <Style.Triggers>
  14. <MultiDataTrigger>
  15. <MultiDataTrigger.Conditions>
  16. <Condition Value="true" >
  17. <Condition.Binding>
  18. <MultiBinding>
  19. <MultiBinding.Converter>
  20. <ctrl:FlowConverterForAllTrueMultiBinding></ctrl:FlowConverterForAllTrueMultiBinding>
  21. </MultiBinding.Converter>
  22. <MultiBinding.Bindings>
  23. <Binding Path="IsFlowing" ElementName="flowPipeControl"></Binding>
  24. <Binding Path="IsSlowFlowing" ElementName="flowPipeControl"></Binding>
  25. </MultiBinding.Bindings>
  26. </MultiBinding>
  27. </Condition.Binding>
  28. </Condition>
  29. <Condition Binding="{Binding ElementName=flowPipeControl, Path=IsReverse}" Value="true" />
  30. </MultiDataTrigger.Conditions>
  31. <MultiDataTrigger.EnterActions>
  32. <BeginStoryboard Name="FlowStoryboard">
  33. <Storyboard RepeatBehavior="Forever" Timeline.DesiredFrameRate="10">
  34. <!--<Gas flows from right to left or bottom to top>-->
  35. <DoubleAnimation Storyboard.TargetProperty="StrokeDashOffset" Duration="0:0:10" By="70" />
  36. </Storyboard>
  37. </BeginStoryboard>
  38. </MultiDataTrigger.EnterActions>
  39. <MultiDataTrigger.ExitActions>
  40. <BeginStoryboard>
  41. <Storyboard FillBehavior="Stop">
  42. <DoubleAnimation Storyboard.TargetProperty="StrokeDashOffset" Duration="0" />
  43. </Storyboard>
  44. </BeginStoryboard>
  45. <StopStoryboard BeginStoryboardName="FlowStoryboard" />
  46. </MultiDataTrigger.ExitActions>
  47. </MultiDataTrigger>
  48. <MultiDataTrigger>
  49. <MultiDataTrigger.Conditions>
  50. <Condition Value="true" >
  51. <Condition.Binding>
  52. <MultiBinding>
  53. <MultiBinding.Converter>
  54. <ctrl:FlowConverterForAllTrueMultiBinding></ctrl:FlowConverterForAllTrueMultiBinding>
  55. </MultiBinding.Converter>
  56. <MultiBinding.Bindings>
  57. <Binding Path="IsFlowing" ElementName="flowPipeControl"></Binding>
  58. <Binding Path="IsSlowFlowing" ElementName="flowPipeControl"></Binding>
  59. </MultiBinding.Bindings>
  60. </MultiBinding>
  61. </Condition.Binding>
  62. </Condition>
  63. <Condition Binding="{Binding ElementName=flowPipeControl, Path=IsReverse}" Value="false" />
  64. </MultiDataTrigger.Conditions>
  65. <MultiDataTrigger.EnterActions>
  66. <BeginStoryboard Name="ReverseFlowStoryboard">
  67. <Storyboard RepeatBehavior="Forever" Timeline.DesiredFrameRate="10">
  68. <!--<Gas flows from left to right or top to bottom>-->
  69. <DoubleAnimation Storyboard.TargetProperty="StrokeDashOffset" Duration="0:0:10" By="-70" />
  70. </Storyboard>
  71. </BeginStoryboard>
  72. </MultiDataTrigger.EnterActions>
  73. <MultiDataTrigger.ExitActions>
  74. <BeginStoryboard>
  75. <Storyboard FillBehavior="Stop">
  76. <DoubleAnimation Storyboard.TargetProperty="StrokeDashOffset" Duration="0" />
  77. </Storyboard>
  78. </BeginStoryboard>
  79. <StopStoryboard BeginStoryboardName="ReverseFlowStoryboard" />
  80. </MultiDataTrigger.ExitActions>
  81. </MultiDataTrigger>
  82. </Style.Triggers>
  83. </Style>
  84. </Canvas.Resources>
  85. <Path Name="path1" Fill="Red" Stretch="Fill"
  86. Width="{Binding ElementName=flowPipeControl,Path=Width}"
  87. Height="{Binding ElementName=flowPipeControl,Path=Height}"
  88. Stroke="Green" StrokeDashArray="1,3" StrokeDashCap="Round" StrokeThickness="5"
  89. Style="{StaticResource AnimatingFlow}">
  90. <Path.Data>
  91. <PathGeometry>
  92. <PathGeometry.Figures>
  93. <PathFigureCollection>
  94. <PathFigure StartPoint="0,0">
  95. <PathFigure.Segments>
  96. <LineSegment Point="80,0" />
  97. </PathFigure.Segments>
  98. </PathFigure>
  99. </PathFigureCollection>
  100. </PathGeometry.Figures>
  101. </PathGeometry>
  102. </Path.Data>
  103. </Path>
  104. <Border x:Name="border1" CornerRadius="1" BorderBrush="Gray" BorderThickness="1" Opacity="0.5"
  105. Width="{Binding ElementName=flowPipeControl,Path=Width}" Height="{Binding ElementName=flowPipeControl,Path=Height}">
  106. <Border.Background>
  107. <LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
  108. <GradientStop Color="Gray" Offset="0"/>
  109. <GradientStop Color="White" Offset="0.5"/>
  110. <GradientStop Color="Gray" Offset="1"/>
  111. </LinearGradientBrush>
  112. </Border.Background>
  113. </Border>
  114. </Canvas>
  115. </UserControl>