TransitionEffect.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Windows;
  2. using System.Windows.Media;
  3. using System.Windows.Media.Effects;
  4. namespace HandyControl.Interactivity;
  5. public abstract class TransitionEffect : ShaderEffect
  6. {
  7. // Fields
  8. public static readonly DependencyProperty InputProperty =
  9. RegisterPixelShaderSamplerProperty("Input", typeof(TransitionEffect), 0, SamplingMode.NearestNeighbor);
  10. public static readonly DependencyProperty OldImageProperty =
  11. RegisterPixelShaderSamplerProperty("OldImage", typeof(TransitionEffect), 1, SamplingMode.NearestNeighbor);
  12. public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register("Progress",
  13. typeof(double), typeof(TransitionEffect), new PropertyMetadata(0.0, PixelShaderConstantCallback(0)));
  14. // Methods
  15. protected TransitionEffect()
  16. {
  17. UpdateShaderValue(InputProperty);
  18. UpdateShaderValue(OldImageProperty);
  19. UpdateShaderValue(ProgressProperty);
  20. }
  21. // Properties
  22. public Brush Input
  23. {
  24. get =>
  25. (Brush) GetValue(InputProperty);
  26. set => SetValue(InputProperty, value);
  27. }
  28. public Brush OldImage
  29. {
  30. get =>
  31. (Brush) GetValue(OldImageProperty);
  32. set => SetValue(OldImageProperty, value);
  33. }
  34. public double Progress
  35. {
  36. get =>
  37. (double) GetValue(ProgressProperty);
  38. set => SetValue(ProgressProperty, value);
  39. }
  40. public new TransitionEffect CloneCurrentValue()
  41. {
  42. return (TransitionEffect) base.CloneCurrentValue();
  43. }
  44. protected abstract TransitionEffect DeepCopy();
  45. }