Change extension namespace.

Implement extended launcher with DI.
Test launching all effects.
This commit is contained in:
Alexandru Macocian
2021-04-01 14:00:35 +02:00
parent 166f9b499e
commit 34a37ce206
43 changed files with 482 additions and 223 deletions
-9
View File
@@ -1,9 +0,0 @@
<Application x:Class="WpfExtended.Test.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfExtended.Test"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
-11
View File
@@ -1,11 +0,0 @@
using System.Windows;
namespace WpfExtended.Test
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
@@ -0,0 +1,20 @@
<UserControl x:Class="WpfExtended.Tests.Controls.CaptionedImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfExtended.Tests.Controls"
mc:Ignorable="d"
x:Name="_this"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<Image Source="{Binding ElementName=_this, Path=ImageSource, Mode=OneWay}" Stretch="Fill"
Effect="{Binding ElementName=_this, Path=ImageEffect, Mode=OneWay}"></Image>
<TextBlock HorizontalAlignment="Center" FontSize="12" Foreground="{Binding ElementName=_this, Path=Foreground, Mode=OneWay}"
Text="{Binding ElementName=_this, Path=Caption, Mode=OneWay}" Grid.Row="1" TextWrapping="Wrap"></TextBlock>
</Grid>
</UserControl>
@@ -0,0 +1,46 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Extensions;
using System.Windows.Media;
using System.Windows.Media.Effects;
namespace WpfExtended.Tests.Controls
{
/// <summary>
/// Interaction logic for CaptionedImage.xaml
/// </summary>
public partial class CaptionedImage : UserControl
{
public readonly static DependencyProperty ImageEffectProperty =
DependencyPropertyExtensions.Register<CaptionedImage, Effect>(nameof(ImageEffect));
public readonly static DependencyProperty ImageSourceProperty =
DependencyPropertyExtensions.Register<CaptionedImage, ImageSource>(nameof(ImageSource));
public readonly static DependencyProperty CaptionProperty =
DependencyPropertyExtensions.Register<CaptionedImage, string>(nameof(Caption));
public Effect ImageEffect
{
get => this.GetTypedValue<Effect>(ImageEffectProperty);
set => this.SetTypedValue(ImageEffectProperty, value);
}
public ImageSource ImageSource
{
get => this.GetTypedValue<ImageSource>(ImageSourceProperty);
set => this.SetTypedValue(ImageSourceProperty, value);
}
public string Caption
{
get => this.GetTypedValue<string>(CaptionProperty);
set => this.SetTypedValue(CaptionProperty, value);
}
public CaptionedImage()
{
InitializeComponent();
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using Slim;
using System;
using System.Windows.Extensions;
using WpfExtended.Test;
namespace WpfExtended.Tests
{
public class Launcher : ExtendedApplication<MainWindow>
{
private static Launcher Instance { get; } = new Launcher();
[STAThread]
public static int Main()
{
return Instance.Run();
}
protected override bool HandleException(Exception e)
{
return false;
}
protected override void RegisterServices(IServiceProducer serviceProducer)
{
}
}
}
+3 -1
View File
@@ -7,6 +7,8 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<ScrollViewer>
<WrapPanel x:Name="WrapPanel" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></WrapPanel>
</ScrollViewer>
</Grid>
</Window>
+39 -3
View File
@@ -1,5 +1,13 @@
using System.Windows;
using System;
using System.Extensions;
using System.IO;
using System.Windows;
using System.Windows.Extensions;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using WpfExtended.Tests.Controls;
using WpfExtended.Tests.Utilities;
namespace WpfExtended.Test
{
@@ -8,11 +16,39 @@ namespace WpfExtended.Test
/// </summary>
public partial class MainWindow : Window
{
public static DependencyProperty ImageSourceProperty =
DependencyProperty.Register(nameof(ImageSource), typeof(ImageSource), typeof(MainWindow));
public readonly static DependencyProperty ImageSourceProperty =
DependencyPropertyExtensions.Register<MainWindow, ImageSource>(nameof(ImageSource));
public ImageSource ImageSource
{
get => this.GetTypedValue<ImageSource>(ImageSourceProperty);
set => this.SetTypedValue(ImageSourceProperty, value);
}
public MainWindow()
{
InitializeComponent();
this.ImageSource = new BitmapImage(new Uri(Path.GetFullPath("Images/Test.jpg")));
this.BuildEffectsView();
}
private void BuildEffectsView()
{
foreach(var effectType in TypeCrawler.GetTypes<ShaderEffect>())
{
var effect = Activator.CreateInstance(effectType).As<ShaderEffect>();
var image = new CaptionedImage()
{
Width = 300,
Height = 300,
ImageSource = this.ImageSource,
Caption = effect.GetType().Name,
ImageEffect = effect,
BorderBrush = Brushes.LightGray,
BorderThickness = new Thickness(1)
};
this.WrapPanel.Children.Add(image);
}
}
}
}
+3 -3
View File
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media.Effects;
namespace WpfExtended.Tests.Utilities
{
internal static class TypeCrawler
{
public static IEnumerable<Type> GetEffectTypes<T>()
public static IEnumerable<Type> GetTypes<T>()
{
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes()
.Where(t => t.IsAssignableTo(typeof(T))));
.Where(t => t.IsAssignableTo(typeof(T)))
.Where(t => t.IsAbstract is false));
}
}
}
@@ -6,6 +6,14 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SystemExtensions.NetStandard" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WpfExtended\WpfExtended.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Images\Test.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -10,21 +10,21 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata;
#endif
public class BandedSwirlEffect : ShaderEffect
public class BandedSwirl : ShaderEffect
{
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(BandedSwirlEffect), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty SwirlStrengthProperty = DependencyProperty.Register("SwirlStrength", typeof(double), typeof(BandedSwirlEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty DistanceThresholdProperty = DependencyProperty.Register("DistanceThreshold", typeof(double), typeof(BandedSwirlEffect), new UIPropertyMetadata(0.2, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(BandedSwirlEffect), 0);
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(BandedSwirl), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty SwirlStrengthProperty = DependencyProperty.Register("SwirlStrength", typeof(double), typeof(BandedSwirl), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty DistanceThresholdProperty = DependencyProperty.Register("DistanceThreshold", typeof(double), typeof(BandedSwirl), new UIPropertyMetadata(0.2, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(BandedSwirl), 0);
private readonly static PixelShader pixelShader;
static BandedSwirlEffect()
static BandedSwirl()
{
pixelShader = PixelShaderUtility.LoadPixelShader("BandedSwirl/BandedSwirl.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<BandedSwirl>();
}
public BandedSwirlEffect()
public BandedSwirl()
{
this.PixelShader = pixelShader;
@@ -10,27 +10,27 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class BloomEffect : ShaderEffect
public class Bloom : ShaderEffect
{
public static readonly DependencyProperty InputProperty =
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(BloomEffect), 0);
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Bloom), 0);
public static readonly DependencyProperty BloomIntensityProperty =
DependencyProperty.Register("BloomIntensity", typeof(double), typeof(BloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(0)));
DependencyProperty.Register("BloomIntensity", typeof(double), typeof(Bloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BaseIntensityProperty =
DependencyProperty.Register("BaseIntensity", typeof(double), typeof(BloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
DependencyProperty.Register("BaseIntensity", typeof(double), typeof(Bloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty BloomSaturationProperty =
DependencyProperty.Register("BloomSaturation", typeof(double), typeof(BloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
DependencyProperty.Register("BloomSaturation", typeof(double), typeof(Bloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty BaseSaturationProperty =
DependencyProperty.Register("BaseSaturation", typeof(double), typeof(BloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(3)));
DependencyProperty.Register("BaseSaturation", typeof(double), typeof(Bloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(3)));
private readonly static PixelShader pixelShader = new PixelShader();
static BloomEffect()
static Bloom()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Bloom/Bloom.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Bloom>();
}
public BloomEffect()
public Bloom()
{
this.PixelShader = pixelShader;
@@ -10,21 +10,21 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class BrightExtractEffect : ShaderEffect
public class BrightExtract : ShaderEffect
{
public static readonly DependencyProperty InputProperty =
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(BrightExtractEffect), 0);
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(BrightExtract), 0);
public static readonly DependencyProperty ThresholdProperty =
DependencyProperty.Register("Threshold", typeof(double), typeof(BrightExtractEffect), new UIPropertyMetadata(0.25, PixelShaderConstantCallback(0)));
DependencyProperty.Register("Threshold", typeof(double), typeof(BrightExtract), new UIPropertyMetadata(0.25, PixelShaderConstantCallback(0)));
private readonly static PixelShader pixelShader = new PixelShader();
static BrightExtractEffect()
static BrightExtract()
{
pixelShader = PixelShaderUtility.LoadPixelShader("BrightExtract/BrightExtract.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<BrightExtract>();
}
public BrightExtractEffect()
public BrightExtract()
{
this.PixelShader = pixelShader;
@@ -7,18 +7,18 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class InvertColorEffect : ShaderEffect
public class ColorKeyAlpha : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(InvertColorEffect), 0);
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorKeyAlpha), 0);
private readonly static PixelShader pixelShader;
static InvertColorEffect()
static ColorKeyAlpha()
{
pixelShader = PixelShaderUtility.LoadPixelShader("InvertColor/InvertColor.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<ColorKeyAlpha>();
}
public InvertColorEffect()
public ColorKeyAlpha()
{
this.PixelShader = pixelShader;
@@ -10,27 +10,27 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class ColorToneEffect : ShaderEffect
public class ColorTone : ShaderEffect
{
public static readonly DependencyProperty InputProperty =
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorToneEffect), 0);
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorTone), 0);
public static readonly DependencyProperty DesaturationProperty =
DependencyProperty.Register("Desaturation", typeof(double), typeof(ColorToneEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
DependencyProperty.Register("Desaturation", typeof(double), typeof(ColorTone), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty TonedProperty =
DependencyProperty.Register("Toned", typeof(double), typeof(ColorToneEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
DependencyProperty.Register("Toned", typeof(double), typeof(ColorTone), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty LightColorProperty =
DependencyProperty.Register("LightColor", typeof(Color), typeof(ColorToneEffect), new UIPropertyMetadata(Color.FromArgb(255, 255, 229, 128), PixelShaderConstantCallback(2)));
DependencyProperty.Register("LightColor", typeof(Color), typeof(ColorTone), new UIPropertyMetadata(Color.FromArgb(255, 255, 229, 128), PixelShaderConstantCallback(2)));
public static readonly DependencyProperty DarkColorProperty =
DependencyProperty.Register("DarkColor", typeof(Color), typeof(ColorToneEffect), new UIPropertyMetadata(Color.FromArgb(255, 51, 128, 0), PixelShaderConstantCallback(3)));
DependencyProperty.Register("DarkColor", typeof(Color), typeof(ColorTone), new UIPropertyMetadata(Color.FromArgb(255, 51, 128, 0), PixelShaderConstantCallback(3)));
private readonly static PixelShader pixelShader = new PixelShader();
static ColorToneEffect()
static ColorTone()
{
pixelShader = PixelShaderUtility.LoadPixelShader("ColorTone/ColorTone.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<ColorTone>();
}
public ColorToneEffect()
public ColorTone()
{
this.PixelShader = pixelShader;
@@ -10,20 +10,20 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class ContrastAdjustEffect : ShaderEffect
public class ContrastAdjust : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ContrastAdjustEffect), 0);
public static readonly DependencyProperty BrightnessProperty = DependencyProperty.Register("Brightness", typeof(double), typeof(ContrastAdjustEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(ContrastAdjustEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ContrastAdjust), 0);
public static readonly DependencyProperty BrightnessProperty = DependencyProperty.Register("Brightness", typeof(double), typeof(ContrastAdjust), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty ContrastProperty = DependencyProperty.Register("Contrast", typeof(double), typeof(ContrastAdjust), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
private readonly static PixelShader pixelShader = new PixelShader();
static ContrastAdjustEffect()
static ContrastAdjust()
{
pixelShader = PixelShaderUtility.LoadPixelShader("ContrastAdjust/ContrastAdjust.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<ContrastAdjust>();
}
public ContrastAdjustEffect()
public ContrastAdjust()
{
this.PixelShader = pixelShader;
@@ -10,20 +10,20 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class DirectionalBlurEffect : ShaderEffect
public class DirectionalBlur : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(DirectionalBlurEffect), 0);
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(DirectionalBlurEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BlurAmountProperty = DependencyProperty.Register("BlurAmount", typeof(double), typeof(DirectionalBlurEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(DirectionalBlur), 0);
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(DirectionalBlur), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BlurAmountProperty = DependencyProperty.Register("BlurAmount", typeof(double), typeof(DirectionalBlur), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
private readonly static PixelShader pixelShader;
static DirectionalBlurEffect()
static DirectionalBlur()
{
pixelShader = PixelShaderUtility.LoadPixelShader("DirectionalBlur/DirectionalBlur.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<DirectionalBlur>();
}
public DirectionalBlurEffect()
public DirectionalBlur()
{
this.PixelShader = pixelShader;
UpdateShaderValue(InputProperty);
@@ -10,20 +10,20 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class EmbossedEffect : ShaderEffect
public class Embossed : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(EmbossedEffect), 0, SamplingMode.Bilinear);
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(EmbossedEffect), new UIPropertyMetadata(15.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(EmbossedEffect), new UIPropertyMetadata(0.0001, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Embossed), 0, SamplingMode.Bilinear);
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(Embossed), new UIPropertyMetadata(15.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(Embossed), new UIPropertyMetadata(0.0001, PixelShaderConstantCallback(1)));
private readonly static PixelShader pixelShader = new PixelShader();
static EmbossedEffect()
static Embossed()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Embossed/Embossed.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Embossed>();
}
public EmbossedEffect()
public Embossed()
{
this.PixelShader = pixelShader;
@@ -10,22 +10,22 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class GloomEffect : ShaderEffect
public class Gloom : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GloomEffect), 0);
public static readonly DependencyProperty GloomIntensityProperty = DependencyProperty.Register("GloomIntensity", typeof(double), typeof(GloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BaseIntensityProperty = DependencyProperty.Register("BaseIntensity", typeof(double), typeof(GloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty GloomSaturationProperty = DependencyProperty.Register("GloomSaturation", typeof(double), typeof(GloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty BaseSaturationProperty = DependencyProperty.Register("BaseSaturation", typeof(double), typeof(GloomEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Gloom), 0);
public static readonly DependencyProperty GloomIntensityProperty = DependencyProperty.Register("GloomIntensity", typeof(double), typeof(Gloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BaseIntensityProperty = DependencyProperty.Register("BaseIntensity", typeof(double), typeof(Gloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty GloomSaturationProperty = DependencyProperty.Register("GloomSaturation", typeof(double), typeof(Gloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty BaseSaturationProperty = DependencyProperty.Register("BaseSaturation", typeof(double), typeof(Gloom), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(3)));
private readonly static PixelShader pixelShader = new PixelShader();
static GloomEffect()
static Gloom()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Gloom/Gloom.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Gloom>();
}
public GloomEffect()
public Gloom()
{
this.PixelShader = pixelShader;
@@ -10,21 +10,21 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class GrowablePoissonDiskEffect : ShaderEffect
public class GrowablePoissonDisk : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GrowablePoissonDiskEffect), 0);
public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(GrowablePoissonDiskEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(GrowablePoissonDiskEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty HeightProperty = DependencyProperty.Register("Height", typeof(double), typeof(GrowablePoissonDiskEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GrowablePoissonDisk), 0);
public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(GrowablePoissonDisk), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(GrowablePoissonDisk), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty HeightProperty = DependencyProperty.Register("Height", typeof(double), typeof(GrowablePoissonDisk), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(2)));
private readonly static PixelShader pixelShader = new PixelShader();
static GrowablePoissonDiskEffect()
static GrowablePoissonDisk()
{
pixelShader = PixelShaderUtility.LoadPixelShader("GrowablePoissonDisk/GrowablePoissonDisk.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<GrowablePoissonDisk>();
}
public GrowablePoissonDiskEffect()
public GrowablePoissonDisk()
{
this.PixelShader = pixelShader;
@@ -7,18 +7,18 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class ColorKeyAlphaEffect : ShaderEffect
public class InvertColor : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorKeyAlphaEffect), 0);
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(InvertColor), 0);
private readonly static PixelShader pixelShader;
static ColorKeyAlphaEffect()
static InvertColor()
{
pixelShader = PixelShaderUtility.LoadPixelShader("ColorKeyAlpha/ColorKeyAlpha.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<InvertColor>();
}
public ColorKeyAlphaEffect()
public InvertColor()
{
this.PixelShader = pixelShader;
@@ -10,21 +10,21 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class LightStreakEffect : ShaderEffect
public class LightStreak : 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 UIPropertyMetadata(0.25, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register("Scale", typeof(double), typeof(LightStreakEffect), new UIPropertyMetadata(0.75, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty AttenuationProperty = DependencyProperty.Register("Attenuation", typeof(double), typeof(LightStreakEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(LightStreak), 0);
public static readonly DependencyProperty BrightThresholdProperty = DependencyProperty.Register("BrightThreshold", typeof(double), typeof(LightStreak), new UIPropertyMetadata(0.25, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register("Scale", typeof(double), typeof(LightStreak), new UIPropertyMetadata(0.75, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty AttenuationProperty = DependencyProperty.Register("Attenuation", typeof(double), typeof(LightStreak), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(2)));
private readonly static PixelShader pixelShader = new PixelShader();
static LightStreakEffect()
static LightStreak()
{
pixelShader = PixelShaderUtility.LoadPixelShader("LightStreak/LightStreak.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<LightStreak>();
}
public LightStreakEffect()
public LightStreak()
{
this.PixelShader = pixelShader;
@@ -11,22 +11,22 @@ namespace System.Windows.Media.Extensions.Effects
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
using Vector = System.Windows.Point ;
#endif
public class MagnifyEffect : ShaderEffect
public class Magnify : ShaderEffect
{
public static readonly DependencyProperty RadiiProperty = DependencyProperty.Register("Radii", typeof(Size), typeof(MagnifyEffect), new UIPropertyMetadata(new Size(0.2, 0.2), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(MagnifyEffect), new UIPropertyMetadata(new Point(0.25, 0.25), PixelShaderConstantCallback(1)));
public static readonly DependencyProperty ShrinkFactorProperty = DependencyProperty.Register("ShrinkFactor", typeof(double), typeof(MagnifyEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(MagnifyEffect), 0);
public static readonly DependencyProperty RadiiProperty = DependencyProperty.Register("Radii", typeof(Size), typeof(Magnify), new UIPropertyMetadata(new Size(0.2, 0.2), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(Magnify), new UIPropertyMetadata(new Point(0.25, 0.25), PixelShaderConstantCallback(1)));
public static readonly DependencyProperty ShrinkFactorProperty = DependencyProperty.Register("ShrinkFactor", typeof(double), typeof(Magnify), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Magnify), 0);
private readonly static PixelShader pixelShader;
private readonly MagnifyGeneralTransform generalTransform;
static MagnifyEffect()
static Magnify()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Magnify/Magnify.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Magnify>();
}
public MagnifyEffect()
public Magnify()
{
this.PixelShader = pixelShader;
@@ -70,10 +70,10 @@ namespace System.Windows.Media.Extensions.Effects
private class MagnifyGeneralTransform : GeneralTransform
{
private readonly MagnifyEffect effect;
private readonly Magnify effect;
private bool thisIsInverse;
private MagnifyGeneralTransform inverseTransform;
public MagnifyGeneralTransform(MagnifyEffect fx)
public MagnifyGeneralTransform(Magnify fx)
{
this.effect = fx;
}
@@ -10,18 +10,18 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class MonochromeEffect : ShaderEffect
public class Monochrome : ShaderEffect
{
public static readonly DependencyProperty FilterColorProperty = DependencyProperty.Register("FilterColor", typeof(Color), typeof(MonochromeEffect), new UIPropertyMetadata(Colors.White, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(MonochromeEffect), 0);
public static readonly DependencyProperty FilterColorProperty = DependencyProperty.Register("FilterColor", typeof(Color), typeof(Monochrome), new UIPropertyMetadata(Colors.White, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Monochrome), 0);
private readonly static PixelShader pixelShader;
static MonochromeEffect()
static Monochrome()
{
pixelShader = PixelShaderUtility.LoadPixelShader("MonoChrome/Monochrome.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Monochrome>();
}
public MonochromeEffect()
public Monochrome()
{
this.PixelShader = pixelShader;
@@ -24,13 +24,13 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class MotionBlurEffect : ShaderEffect
public class MotionBlur : ShaderEffect
{
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(MotionBlurEffect), 0);
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(MotionBlur), 0);
public static readonly DependencyProperty BlurAngleProperty =
DependencyProperty.Register(nameof(BlurAngle), typeof(double), typeof(MotionBlurEffect), new UIPropertyMetadata(0d, PixelShaderConstantCallback(0)));
DependencyProperty.Register(nameof(BlurAngle), typeof(double), typeof(MotionBlur), new UIPropertyMetadata(0d, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BlurMagnitudeProperty =
DependencyProperty.Register(nameof(BlurMagnitude), typeof(double), typeof(MotionBlurEffect), new UIPropertyMetadata(10d, PixelShaderConstantCallback(1)));
DependencyProperty.Register(nameof(BlurMagnitude), typeof(double), typeof(MotionBlur), new UIPropertyMetadata(10d, PixelShaderConstantCallback(1)));
public Brush Input
{
@@ -48,9 +48,9 @@ namespace System.Windows.Media.Extensions.Effects
set => SetValue(BlurMagnitudeProperty, value);
}
public MotionBlurEffect()
public MotionBlur()
{
PixelShader = PixelShaderUtility.LoadPixelShader("MotionBlur/MotionBlurEffect.ps");
PixelShader = PixelShaderUtility.LoadPixelShader<MotionBlur>();
UpdateShaderValue(InputProperty);
UpdateShaderValue(BlurAngleProperty);
@@ -24,9 +24,9 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class NegativeEffect : ShaderEffect
public class Negative : ShaderEffect
{
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(NegativeEffect), 0);
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(Negative), 0);
public Brush Input
{
@@ -34,9 +34,9 @@ namespace System.Windows.Media.Extensions.Effects
set => SetValue(InputProperty, value);
}
public NegativeEffect()
public Negative()
{
PixelShader = PixelShaderUtility.LoadPixelShader("Negative/NegativeEffect.ps");
PixelShader = PixelShaderUtility.LoadPixelShader<Negative>();
UpdateShaderValue(InputProperty);
}
}
@@ -10,21 +10,21 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class PinchEffect : ShaderEffect
public class Pinch : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(PinchEffect), 0);
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(PinchEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(PinchEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(PinchEffect), new UIPropertyMetadata(0.25, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(PinchEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Pinch), 0);
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(Pinch), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(Pinch), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(Pinch), new UIPropertyMetadata(0.25, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(Pinch), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(3)));
private readonly static PixelShader pixelShader = new PixelShader();
static PinchEffect()
static Pinch()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Pinch/Pinch.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Pinch>();
}
public PinchEffect()
public Pinch()
{
this.PixelShader = pixelShader;
+12 -8
View File
@@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.IO;
using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
@@ -37,15 +37,19 @@ namespace System.Windows.Media.Extensions.Effects
.Name;
}
public static PixelShader LoadPixelShader(string shaderFile)
public static PixelShader LoadPixelShader<T>()
where T : ShaderEffect
{
string uriString = $"pack://application:,,,/{AssemblyShortName};component/{shaderFile}";
PixelShader pixelShader = new PixelShader
{
UriSource = new Uri(uriString)
};
var pixelShaderName = typeof(T).Name;
var resourceName = $"{AssemblyShortName}.Effects.{pixelShaderName}.{pixelShaderName}.ps";
var pixelShader = new PixelShader();
pixelShader.SetStreamSource(GetShaderStream(resourceName));
return pixelShader;
}
internal static Stream GetShaderStream(string name)
{
return typeof(PixelShaderUtility).Assembly.GetManifestResourceStream(name) ?? throw new InvalidOperationException($"Could not find shader resource for {name}");
}
}
}
@@ -10,20 +10,20 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class PixelateEffect : ShaderEffect
public class Pixelate : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(PixelateEffect), 0);
public static readonly DependencyProperty HorizontalPixelCountsProperty = DependencyProperty.Register("HorizontalPixelCounts", typeof(double), typeof(PixelateEffect), new UIPropertyMetadata(80.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty VerticalPixelCountsProperty = DependencyProperty.Register("VerticalPixelCounts", typeof(double), typeof(PixelateEffect), new UIPropertyMetadata(80.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Pixelate), 0);
public static readonly DependencyProperty HorizontalPixelCountsProperty = DependencyProperty.Register("HorizontalPixelCounts", typeof(double), typeof(Pixelate), new UIPropertyMetadata(80.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty VerticalPixelCountsProperty = DependencyProperty.Register("VerticalPixelCounts", typeof(double), typeof(Pixelate), new UIPropertyMetadata(80.0, PixelShaderConstantCallback(1)));
private readonly static PixelShader pixelShader = new PixelShader();
static PixelateEffect()
static Pixelate()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Pixelate/Pixelate.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Pixelate>();
}
public PixelateEffect()
public Pixelate()
{
this.PixelShader = pixelShader;
@@ -10,22 +10,22 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class RippleEffect : ShaderEffect
public class Ripple : ShaderEffect
{
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(RippleEffect), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty AmplitudeProperty = DependencyProperty.Register("Amplitude", typeof(double), typeof(RippleEffect), new UIPropertyMetadata(0.1, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(RippleEffect), new UIPropertyMetadata(50.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(RippleEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(RippleEffect), 0);
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(Ripple), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty AmplitudeProperty = DependencyProperty.Register("Amplitude", typeof(double), typeof(Ripple), new UIPropertyMetadata(0.1, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register("Frequency", typeof(double), typeof(Ripple), new UIPropertyMetadata(50.0, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty PhaseProperty = DependencyProperty.Register("Phase", typeof(double), typeof(Ripple), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Ripple), 0);
private static readonly PixelShader pixelShader;
static RippleEffect()
static Ripple()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Ripple/Ripple.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Ripple>();
}
public RippleEffect()
public Ripple()
{
this.PixelShader = pixelShader;
@@ -10,20 +10,20 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class SharpenEffect : ShaderEffect
public class Sharpen : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(SharpenEffect), 0);
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(SharpenEffect), new UIPropertyMetadata(15.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(SharpenEffect), new UIPropertyMetadata(0.0001, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Sharpen), 0);
public static readonly DependencyProperty AmountProperty = DependencyProperty.Register("Amount", typeof(double), typeof(Sharpen), new UIPropertyMetadata(15.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty WidthProperty = DependencyProperty.Register("Width", typeof(double), typeof(Sharpen), new UIPropertyMetadata(0.0001, PixelShaderConstantCallback(1)));
private readonly static PixelShader pixelShader = new PixelShader();
static SharpenEffect()
static Sharpen()
{
pixelShader = PixelShaderUtility.LoadPixelShader("Sharpen/Sharpen.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Sharpen>();
}
public SharpenEffect()
public Sharpen()
{
this.PixelShader = pixelShader;
@@ -10,22 +10,22 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class SmoothMagnifyEffect : ShaderEffect
public class SmoothMagnify : ShaderEffect
{
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(SmoothMagnifyEffect), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty InnerRadiusProperty = DependencyProperty.Register("InnerRadius", typeof(double), typeof(SmoothMagnifyEffect), new UIPropertyMetadata(.2, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty MagnificationProperty = DependencyProperty.Register("Magnification", typeof(double), typeof(SmoothMagnifyEffect), new UIPropertyMetadata(2.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty OuterRadiusProperty = DependencyProperty.Register("OuterRadius", typeof(double), typeof(SmoothMagnifyEffect), new UIPropertyMetadata(.27, PixelShaderConstantCallback(4)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(SmoothMagnifyEffect), 0);
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(SmoothMagnify), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty InnerRadiusProperty = DependencyProperty.Register("InnerRadius", typeof(double), typeof(SmoothMagnify), new UIPropertyMetadata(.2, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty MagnificationProperty = DependencyProperty.Register("Magnification", typeof(double), typeof(SmoothMagnify), new UIPropertyMetadata(2.0, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty OuterRadiusProperty = DependencyProperty.Register("OuterRadius", typeof(double), typeof(SmoothMagnify), new UIPropertyMetadata(.27, PixelShaderConstantCallback(4)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(SmoothMagnify), 0);
private readonly static PixelShader pixelShader;
static SmoothMagnifyEffect()
static SmoothMagnify()
{
pixelShader = PixelShaderUtility.LoadPixelShader("SmoothMagnify/SmoothMagnify.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<SmoothMagnify>();
}
public SmoothMagnifyEffect()
public SmoothMagnify()
{
this.PixelShader = pixelShader;
@@ -11,22 +11,22 @@ namespace System.Windows.Media.Extensions.Effects
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
using Vector = System.Windows.Point ;
#endif
public class SwirlEffect : ShaderEffect
public class Swirl : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(SwirlEffect), 0);
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(SwirlEffect), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty SwirlStrengthProperty = DependencyProperty.Register("SwirlStrength", typeof(double), typeof(SwirlEffect), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty AngleFrequencyProperty = DependencyProperty.Register("AngleFrequency", typeof(Vector), typeof(SwirlEffect), new UIPropertyMetadata(new Vector(1, 1), PixelShaderConstantCallback(2)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(Swirl), 0);
public static readonly DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point), typeof(Swirl), new UIPropertyMetadata(new Point(0.5, 0.5), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty SwirlStrengthProperty = DependencyProperty.Register("SwirlStrength", typeof(double), typeof(Swirl), new UIPropertyMetadata(0.5, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty AngleFrequencyProperty = DependencyProperty.Register("AngleFrequency", typeof(Vector), typeof(Swirl), new UIPropertyMetadata(new Vector(1, 1), PixelShaderConstantCallback(2)));
private readonly static PixelShader pixelShader;
private readonly SwirlGeneralTransform generalTransform;
static SwirlEffect()
static Swirl()
{
pixelShader = PixelShaderUtility.LoadPixelShader("SwirlEffect/SwirlEffect.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<Swirl>();
}
public SwirlEffect()
public Swirl()
{
this.PixelShader = pixelShader;
@@ -68,10 +68,10 @@ namespace System.Windows.Media.Extensions.Effects
}
private class SwirlGeneralTransform : GeneralTransform
{
private readonly SwirlEffect theEffect;
private readonly Swirl theEffect;
private bool thisIsInverse;
private SwirlGeneralTransform inverseTransform;
public SwirlGeneralTransform(SwirlEffect eff)
public SwirlGeneralTransform(Swirl eff)
{
this.theEffect = eff;
}
@@ -10,25 +10,25 @@ namespace System.Windows.Media.Extensions.Effects
#if SILVERLIGHT
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
#endif
public class ToneMappingEffect : ShaderEffect
public class ToneMapping : ShaderEffect
{
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ToneMappingEffect), 0);
public static readonly DependencyProperty ExposureProperty = DependencyProperty.Register("Exposure", typeof(double), typeof(ToneMappingEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty DefogProperty = DependencyProperty.Register("Defog", typeof(double), typeof(ToneMappingEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty GammaProperty = DependencyProperty.Register("Gamma", typeof(double), typeof(ToneMappingEffect), new UIPropertyMetadata(0.454545, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty FogColorProperty = DependencyProperty.Register("FogColor", typeof(Color), typeof(ToneMappingEffect), new UIPropertyMetadata(Colors.White, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty VignetteRadiusProperty = DependencyProperty.Register("VignetteRadius", typeof(double), typeof(ToneMappingEffect), new UIPropertyMetadata(0.35, PixelShaderConstantCallback(4)));
public static readonly DependencyProperty VignetteCenterProperty = DependencyProperty.Register("VignetteCenter", typeof(Point), typeof(ToneMappingEffect), new UIPropertyMetadata( new Point(0.5, 0.5), PixelShaderConstantCallback(5)));
public static readonly DependencyProperty BlueShiftProperty = DependencyProperty.Register("BlueShift", typeof(double), typeof(ToneMappingEffect), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(6)));
public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ToneMapping), 0);
public static readonly DependencyProperty ExposureProperty = DependencyProperty.Register("Exposure", typeof(double), typeof(ToneMapping), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
public static readonly DependencyProperty DefogProperty = DependencyProperty.Register("Defog", typeof(double), typeof(ToneMapping), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
public static readonly DependencyProperty GammaProperty = DependencyProperty.Register("Gamma", typeof(double), typeof(ToneMapping), new UIPropertyMetadata(0.454545, PixelShaderConstantCallback(2)));
public static readonly DependencyProperty FogColorProperty = DependencyProperty.Register("FogColor", typeof(Color), typeof(ToneMapping), new UIPropertyMetadata(Colors.White, PixelShaderConstantCallback(3)));
public static readonly DependencyProperty VignetteRadiusProperty = DependencyProperty.Register("VignetteRadius", typeof(double), typeof(ToneMapping), new UIPropertyMetadata(0.35, PixelShaderConstantCallback(4)));
public static readonly DependencyProperty VignetteCenterProperty = DependencyProperty.Register("VignetteCenter", typeof(Point), typeof(ToneMapping), new UIPropertyMetadata( new Point(0.5, 0.5), PixelShaderConstantCallback(5)));
public static readonly DependencyProperty BlueShiftProperty = DependencyProperty.Register("BlueShift", typeof(double), typeof(ToneMapping), new UIPropertyMetadata(1.0, PixelShaderConstantCallback(6)));
private readonly static PixelShader pixelShader;
static ToneMappingEffect()
static ToneMapping()
{
pixelShader = PixelShaderUtility.LoadPixelShader("ToneMapping/ToneMapping.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<ToneMapping>();
}
public ToneMappingEffect()
public ToneMapping()
{
this.PixelShader = pixelShader;
@@ -7,16 +7,16 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class ToonShaderEffect : ShaderEffect
public class ToonShader : ShaderEffect
{
public static readonly DependencyProperty InputProperty =
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ToonShaderEffect), 0);
ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ToonShader), 0);
private static readonly PixelShader pixelShader;
static ToonShaderEffect()
static ToonShader()
{
pixelShader = PixelShaderUtility.LoadPixelShader("ToonShader/ToonShader.ps");
pixelShader = PixelShaderUtility.LoadPixelShader<ToonShader>();
// Just saying hardware only for now since our drop of sw doesn't have sin/cos in
// it, and thus we can't validate against that.
@@ -26,7 +26,7 @@ namespace System.Windows.Media.Extensions.Effects
#endif
}
public ToonShaderEffect()
public ToonShader()
{
this.PixelShader = pixelShader;
UpdateShaderValue(InputProperty);
@@ -24,13 +24,13 @@ using System.Windows.Media.Effects;
namespace System.Windows.Media.Extensions.Effects
{
public class ZoomBlurEffect : ShaderEffect
public class ZoomBlur : ShaderEffect
{
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(ZoomBlurEffect), 0);
public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(nameof(Input), typeof(ZoomBlur), 0);
public static readonly DependencyProperty BlurCenterProperty =
DependencyProperty.Register(nameof(BlurCenter), typeof(Point), typeof(ZoomBlurEffect), new UIPropertyMetadata(new Point(0.5D, 0.5D), PixelShaderConstantCallback(0)));
DependencyProperty.Register(nameof(BlurCenter), typeof(Point), typeof(ZoomBlur), new UIPropertyMetadata(new Point(0.5D, 0.5D), PixelShaderConstantCallback(0)));
public static readonly DependencyProperty BlurMagnitudeProperty =
DependencyProperty.Register(nameof(BlurMagnitude), typeof(double), typeof(ZoomBlurEffect), new UIPropertyMetadata(5D, PixelShaderConstantCallback(1)));
DependencyProperty.Register(nameof(BlurMagnitude), typeof(double), typeof(ZoomBlur), new UIPropertyMetadata(5D, PixelShaderConstantCallback(1)));
public Brush Input
{
@@ -48,9 +48,9 @@ namespace System.Windows.Media.Extensions.Effects
set => SetValue(BlurMagnitudeProperty, value);
}
public ZoomBlurEffect()
public ZoomBlur()
{
PixelShader = PixelShaderUtility.LoadPixelShader("ZoomBlur/ZoomBlurEffect.ps");
PixelShader = PixelShaderUtility.LoadPixelShader<ZoomBlur>();
UpdateShaderValue(InputProperty);
UpdateShaderValue(BlurCenterProperty);
+75
View File
@@ -0,0 +1,75 @@
using Slim;
using System.Extensions;
using System.Threading.Tasks;
using System.Windows.Navigation;
namespace System.Windows.Extensions
{
/// <summary>
/// Extended application class.
/// </summary>
/// <typeparam name="T">Type of window to be launched after initialization.</typeparam>
public abstract class ExtendedApplication<T> : Application
where T : Window
{
protected IServiceManager ServiceManager { get; } = new ServiceManager();
public ExtendedApplication()
{
this.RegisterInternals();
}
/// <summary>
/// Register services into the <see cref="IServiceProducer"/>.
/// </summary>
/// <param name="serviceProducer"></param>
protected abstract void RegisterServices(IServiceProducer serviceProducer);
/// <summary>
/// Handle a caught exception.
/// </summary>
/// <param name="e">Exception to be handled.</param>
/// <returns>True if exception is handled. Otherwise, return false.</returns>
protected abstract bool HandleException(Exception e);
protected sealed override void OnStartup(StartupEventArgs e)
{
this.SetupExceptionHandling();
this.RegisterServices(this.ServiceManager);
this.LaunchWindow();
}
private void LaunchWindow()
{
var window = this.ServiceManager.GetService<T>();
window.Show();
}
private void RegisterInternals()
{
this.ServiceManager.RegisterServiceManager();
this.ServiceManager.RegisterSingleton<T, T>();
}
private void SetupExceptionHandling()
{
this.DispatcherUnhandledException += (_, e) =>
{
e.Handled = this.HandleException(e.Exception);
};
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
if (this.HandleException(e.ExceptionObject.As<Exception>()) is false && e.IsTerminating is false)
{
throw e.ExceptionObject.As<Exception>();
}
};
TaskScheduler.UnobservedTaskException += (_, e) =>
{
if (this.HandleException(e.Exception))
{
e.SetObserved();
}
};
}
}
}
+61
View File
@@ -12,11 +12,72 @@
<RepositoryUrl>https://github.com/AlexMacocian/WpfExtended</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<None Remove="Effects\BandedSwirl\BandedSwirl.ps" />
<None Remove="Effects\Bloom\Bloom.ps" />
<None Remove="Effects\BrightExtract\BrightExtract.ps" />
<None Remove="Effects\ColorKeyAlpha\ColorKeyAlpha.ps" />
<None Remove="Effects\ColorTone\ColorTone.ps" />
<None Remove="Effects\ContrastAdjust\ContrastAdjust.ps" />
<None Remove="Effects\DirectionalBlur\DirectionalBlur.ps" />
<None Remove="Effects\Embossed\Embossed.ps" />
<None Remove="Effects\Gloom\Gloom.ps" />
<None Remove="Effects\GrowablePoissonDisk\GrowablePoissonDisk.ps" />
<None Remove="Effects\InvertColor\InvertColor.ps" />
<None Remove="Effects\LightStreak\LightStreak.ps" />
<None Remove="Effects\Magnify\Magnify.ps" />
<None Remove="Effects\Monochrome\Monochrome.ps" />
<None Remove="Effects\MotionBlur\MotionBlur.ps" />
<None Remove="Effects\Negative\Negative.ps" />
<None Remove="Effects\Pinch\Pinch.ps" />
<None Remove="Effects\Pixelate\Pixelate.ps" />
<None Remove="Effects\Ripple\Ripple.ps" />
<None Remove="Effects\Sharpen\Sharpen.ps" />
<None Remove="Effects\SmoothMagnify\SmoothMagnify.ps" />
<None Remove="Effects\Swirl\Swirl.ps" />
<None Remove="Effects\ToneMapping\ToneMapping.ps" />
<None Remove="Effects\ToonShader\ToonShader.ps" />
<None Remove="Effects\ZoomBlur\ZoomBlur.ps" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Effects\BandedSwirl\BandedSwirl.ps" />
<EmbeddedResource Include="Effects\Bloom\Bloom.ps" />
<EmbeddedResource Include="Effects\BrightExtract\BrightExtract.ps" />
<EmbeddedResource Include="Effects\ColorKeyAlpha\ColorKeyAlpha.ps" />
<EmbeddedResource Include="Effects\ColorTone\ColorTone.ps" />
<EmbeddedResource Include="Effects\ContrastAdjust\ContrastAdjust.ps" />
<EmbeddedResource Include="Effects\DirectionalBlur\DirectionalBlur.ps" />
<EmbeddedResource Include="Effects\Embossed\Embossed.ps" />
<EmbeddedResource Include="Effects\Gloom\Gloom.ps" />
<EmbeddedResource Include="Effects\GrowablePoissonDisk\GrowablePoissonDisk.ps" />
<EmbeddedResource Include="Effects\InvertColor\InvertColor.ps" />
<EmbeddedResource Include="Effects\LightStreak\LightStreak.ps" />
<EmbeddedResource Include="Effects\Magnify\Magnify.ps" />
<EmbeddedResource Include="Effects\Monochrome\Monochrome.ps" />
<EmbeddedResource Include="Effects\MotionBlur\MotionBlur.ps" />
<EmbeddedResource Include="Effects\Negative\Negative.ps" />
<EmbeddedResource Include="Effects\Pinch\Pinch.ps" />
<EmbeddedResource Include="Effects\Pixelate\Pixelate.ps" />
<EmbeddedResource Include="Effects\Ripple\Ripple.ps" />
<EmbeddedResource Include="Effects\Sharpen\Sharpen.ps" />
<EmbeddedResource Include="Effects\SmoothMagnify\SmoothMagnify.ps" />
<EmbeddedResource Include="Effects\Swirl\Swirl.ps" />
<EmbeddedResource Include="Effects\ToneMapping\ToneMapping.ps" />
<EmbeddedResource Include="Effects\ToonShader\ToonShader.ps" />
<EmbeddedResource Include="Effects\ZoomBlur\ZoomBlur.ps" />
</ItemGroup>
<ItemGroup>
<None Include="License.txt">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Slim" Version="1.2.1" />
<PackageReference Include="SystemExtensions.NetStandard" Version="1.1.1" />
</ItemGroup>
<Import Project="ShaderCompiler.target" />
</Project>