BrightnessEffect.cs 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Media.Effects;
  4. using HandyControl.Data;
  5. namespace HandyControl.Media.Effects;
  6. public class BrightnessEffect : EffectBase
  7. {
  8. private static readonly PixelShader Shader;
  9. static BrightnessEffect()
  10. {
  11. Shader = new PixelShader
  12. {
  13. UriSource = new Uri("pack://application:,,,/HandyControl;component/Resources/Effects/BrightnessEffect.ps")
  14. };
  15. }
  16. public BrightnessEffect()
  17. {
  18. PixelShader = Shader;
  19. UpdateShaderValue(InputProperty);
  20. UpdateShaderValue(BrightnessProperty);
  21. }
  22. public static readonly DependencyProperty BrightnessProperty = DependencyProperty.Register(
  23. nameof(Brightness), typeof(double), typeof(BrightnessEffect), new PropertyMetadata(ValueBoxes.Double1Box, PixelShaderConstantCallback(0)));
  24. public double Brightness
  25. {
  26. get => (double) GetValue(BrightnessProperty);
  27. set => SetValue(BrightnessProperty, value);
  28. }
  29. }