AITGasValve.xaml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <UserControl x:Class="Aitex.Core.UI.DeviceControl.AITGasValve"
  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:sys="clr-namespace:System;assembly=mscorlib"
  7. xmlns:converters="clr-namespace:Aitex.Core.UI.Converters"
  8. mc:Ignorable="d"
  9. Height="32" Width="32" Loaded="AITGasValve_OnLoaded"
  10. Name="GasValve">
  11. <UserControl.Resources>
  12. <Storyboard x:Key="OpenValveStoryBoard">
  13. <DoubleAnimation
  14. Storyboard.TargetName="rotateTransform"
  15. Storyboard.TargetProperty="Angle"
  16. To="90" Duration="0:0:0.3" FillBehavior="HoldEnd"></DoubleAnimation>
  17. <DoubleAnimation
  18. Storyboard.TargetName="imgValveClose"
  19. Storyboard.TargetProperty="Opacity"
  20. To="0" Duration="0:0:0.3" FillBehavior="HoldEnd"></DoubleAnimation>
  21. </Storyboard>
  22. <Storyboard x:Key="CloseValveStoryBoard">
  23. <DoubleAnimation
  24. Storyboard.TargetName="rotateTransform"
  25. Storyboard.TargetProperty="Angle"
  26. To="0" Duration="0:0:0.3" FillBehavior="HoldEnd"></DoubleAnimation>
  27. <DoubleAnimation
  28. Storyboard.TargetName="imgValveClose"
  29. Storyboard.TargetProperty="Opacity"
  30. To="100" Duration="0:0:0.3" FillBehavior="HoldEnd"></DoubleAnimation>
  31. </Storyboard>
  32. <converters:RotateTransformConverter x:Key="transformConvert"/>
  33. </UserControl.Resources>
  34. <UserControl.RenderTransform>
  35. <RotateTransform x:Name="rotateTransform" CenterX="{Binding ElementName=GasValve,Path=Width,Converter={StaticResource transformConvert}}"
  36. CenterY="{Binding ElementName=GasValve,Path=Height,Converter={StaticResource transformConvert}}"/>
  37. </UserControl.RenderTransform>
  38. <Canvas>
  39. <Image Name="imgValveOpen" Width="{Binding ElementName=GasValve,Path=Width}" Height="{Binding ElementName=GasValve,Path=Height}">
  40. </Image>
  41. <Image Name="imgValveClose" Width="{Binding ElementName=GasValve,Path=Width}" Height="{Binding ElementName=GasValve,Path=Height}">
  42. <Image.ContextMenu>
  43. <ContextMenu Visibility="{Binding MenuVisibility}">
  44. <MenuItem Header="Open Valve" Click="OpenValve" />
  45. <MenuItem Header="Close Valve" Click="CloseValve" />
  46. </ContextMenu>
  47. </Image.ContextMenu>
  48. </Image>
  49. </Canvas>
  50. </UserControl>