Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/Silverlight/CS/ControlsDemo/Effects/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/Silverlight/CS/ControlsDemo/Effects/Effects.cs

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace ControlsDemo {
    public class RippleEffect : ShaderEffect {
        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(RippleEffect), 0);
        public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(RippleEffect), new PropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
        public static readonly DependencyProperty AmplitudeProperty = DependencyProperty.Register("Amplitude", typeof(double), typeof(RippleEffect), new PropertyMetadata(0.1, PixelShaderConstantCallback(1)));
        public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(RippleEffect), new PropertyMetadata(0.0, PixelShaderConstantCallback(2)));
        public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(RippleEffect), new PropertyMetadata(0.0, PixelShaderConstantCallback(3)));
        public static readonly DependencyProperty AspectRatioProperty = DependencyProperty.Register("AspectRatio", typeof(double), typeof(RippleEffect), new PropertyMetadata(1.0, PixelShaderConstantCallback(4)));

        public Brush Input { get { return (Brush)GetValue(InputProperty); } set { SetValue(InputProperty, value); } }
        public Point Center { get { return (Point)GetValue(CenterProperty); } set { SetValue(CenterProperty, value); } }
        public double Amplitude { get { return (double)GetValue(AmplitudeProperty); } set { SetValue(AmplitudeProperty, value); } }
        public double Frequency { get { return (double)GetValue(FrequencyProperty); } set { SetValue(FrequencyProperty, value); } }
        public double Phase { get { return (double)GetValue(PhaseProperty); } set { SetValue(PhaseProperty, value); } }
        public double AspectRatio { get { return (double)GetValue(AspectRatioProperty); } set { SetValue(AspectRatioProperty, value); } }

        public RippleEffect() {
            PixelShader pixelShader = new PixelShader();
            pixelShader.UriSource = new Uri("/ControlsDemo;component/Effects/Shaders/Ripple.ps", UriKind.Relative);
            PixelShader = pixelShader;
            UpdateShaderValue(InputProperty);
            UpdateShaderValue(CenterProperty);
            UpdateShaderValue(AmplitudeProperty);
            UpdateShaderValue(FrequencyProperty);
            UpdateShaderValue(PhaseProperty);
            UpdateShaderValue(AspectRatioProperty);
        }
    }
    public class LightStreakEffect : ShaderEffect {
        public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(LightStreakEffect), 0);
        public static readonly DependencyProperty BrightThresholdProperty = DependencyProperty.Register("BrightThreshold", typeof(double), typeof(LightStreakEffect), new PropertyMetadata(((double)(0.5)), PixelShaderConstantCallback(0)));
        public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register("Scale", typeof(double), typeof(LightStreakEffect), new PropertyMetadata(((double)(0.5)), PixelShaderConstantCallback(1)));
        public static readonly DependencyProperty AttenuationProperty = DependencyProperty.Register("Attenuation", typeof(double), typeof(LightStreakEffect), new PropertyMetadata(((double)(0.25)), PixelShaderConstantCallback(2)));
        public static readonly DependencyProperty DirectionProperty = DependencyProperty.Register("Direction", typeof(Point), typeof(LightStreakEffect), new PropertyMetadata(new Point(0.5, 1), PixelShaderConstantCallback(3)));
        public static readonly DependencyProperty InputSizeProperty = DependencyProperty.Register("InputSize", typeof(Size), typeof(LightStreakEffect), new PropertyMetadata(new Size(800, 600), PixelShaderConstantCallback(4)));

        public Brush Input { get { return ((Brush)(GetValue(InputProperty))); } set { SetValue(InputProperty, value); } }
        public double BrightThreshold { get { return ((double)(GetValue(BrightThresholdProperty))); } set { SetValue(BrightThresholdProperty, value); } }
        public double Scale { get { return ((double)(GetValue(ScaleProperty))); } set { SetValue(ScaleProperty, value); } }
        public double Attenuation { get { return ((double)(GetValue(AttenuationProperty))); } set { SetValue(AttenuationProperty, value); } }
        public Point Direction { get { return ((Point)(GetValue(DirectionProperty))); } set { SetValue(DirectionProperty, value); } }
        public Size InputSize { get { return ((Size)(GetValue(InputSizeProperty))); } set { SetValue(InputSizeProperty, value); } }

        public LightStreakEffect() {
            PixelShader pixelShader = new PixelShader();
            pixelShader.UriSource = new Uri("/ControlsDemo;component/Effects/Shaders/LightStreak.ps", UriKind.Relative);
            PixelShader = pixelShader;
            UpdateShaderValue(InputProperty);
            UpdateShaderValue(BrightThresholdProperty);
            UpdateShaderValue(ScaleProperty);
            UpdateShaderValue(AttenuationProperty);
            UpdateShaderValue(DirectionProperty);
            UpdateShaderValue(InputSizeProperty);
        }
    }
}