From 6a79133cc109a28c9216d0604ed7b954b18c41ab Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 14 Dec 2019 13:47:05 +0800 Subject: [PATCH] add GrayScaleEffect --- README.md | 8 ++- .../HandyControlDemo_Core30.csproj | 3 ++ .../HandyControl_Core_30.csproj | 5 ++ .../HandyControlDemo_Net_40.csproj | 3 ++ .../HandyControl_Net_40.csproj | 5 ++ .../HandyControlDemo_Net_GE45.csproj | 3 ++ .../HandyControl_Net_GE45.csproj | 5 ++ .../Data/DemoInfo.json | 3 +- .../HandyControlDemo_Shared.projitems | 7 +++ .../Properties/Langs/Lang.Designer.cs | 9 ++++ .../Properties/Langs/Lang.en.resx | 3 ++ .../Properties/Langs/Lang.fa.resx | 3 ++ .../Properties/Langs/Lang.fr.resx | 3 ++ .../Properties/Langs/Lang.resx | 3 ++ .../Img/LeftMainContent/Effects_16x.png | Bin 0 -> 369 bytes .../UserControl/Tools/EffectsDemoCtl.xaml | 26 ++++++++++ .../UserControl/Tools/EffectsDemoCtl.xaml.cs | 10 ++++ .../HandyControl_Shared.projitems | 1 + .../Media/Effects/ColorComplementEffect.cs | 1 + .../Media/Effects/GrayScaleEffect.cs | 46 ++++++++++++++++++ .../Resources/Effects/GrayScaleEffect.ps | Bin 0 -> 384 bytes 21 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Effects_16x.png create mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml create mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml.cs create mode 100644 src/Shared/HandyControl_Shared/Media/Effects/GrayScaleEffect.cs create mode 100644 src/Shared/HandyControl_Shared/Resources/Effects/GrayScaleEffect.ps diff --git a/README.md b/README.md index 62aca62e..8b8986d6 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ Step 4:enjoy coding ## Latest examples +### Effects + +![Effects](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/Effects.png) + ### RelativePanel ![RelativePanel](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/RelativePanel.png) @@ -107,12 +111,12 @@ Step 4:enjoy coding ![Divider](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/Divider.png) +## History publication + ### GeometryAnimation ![GeometryAnimation](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/GeometryAnimation.gif) -## History publication - ### SplitButton ![SplitButton](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/SplitButton.png) diff --git a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj index bd93971a..b343a399 100644 --- a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj +++ b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj @@ -451,6 +451,9 @@ Resources\Img\LeftMainContent\TransformRelative_16x.png + + Resources\Img\LeftMainContent\Effects_16x.png + diff --git a/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj b/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj index ce527ed8..97e75628 100644 --- a/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj +++ b/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj @@ -56,8 +56,13 @@ Resources\dropper.cur + + Resources\Effects\ColorComplementEffect.ps + + Resources\Effects\GrayScaleEffect.ps + \ No newline at end of file diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj index 65e72972..dad16ae2 100644 --- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj +++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj @@ -430,6 +430,9 @@ TextTemplatingFileGenerator MessageToken.cs + + Resources\Img\LeftMainContent\Effects_16x.png + Resources\Img\LeftMainContent\TransformRelative_16x.png diff --git a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj index 3017e107..f6d5903f 100644 --- a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj +++ b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj @@ -108,9 +108,14 @@ Resources\dropper.cur + + Resources\Effects\ColorComplementEffect.ps + + Resources\Effects\GrayScaleEffect.ps + diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj index 8a6b97f4..3577548d 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj @@ -496,6 +496,9 @@ TextTemplatingFileGenerator MessageToken.cs + + Resources\Img\LeftMainContent\Effects_16x.png + Resources\Img\LeftMainContent\TransformRelative_16x.png diff --git a/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj b/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj index 5c685b76..8ad765a1 100644 --- a/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj +++ b/src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj @@ -179,9 +179,14 @@ Resources\dropper.cur + + Resources\Effects\ColorComplementEffect.ps + + Resources\Effects\GrayScaleEffect.ps + diff --git a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json index 92439c37..18f69028 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json +++ b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json @@ -101,7 +101,8 @@ "title": "Tools", "demoItemList": [ [ "HatchBrushGenerator", "HatchBrushGeneratorDemoCtl", "DataGenerator_16x", "" ], - [ "Morphing Animation", "GeometryAnimationDemoCtl", "Animation_16x", "1" ] + [ "Morphing Animation", "GeometryAnimationDemoCtl", "Animation_16x", "" ], + [ "Effects", "EffectsDemoCtl", "Effects_16x", "1" ] ] } ] \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems index 4fe569a5..c1fd7462 100644 --- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems +++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems @@ -347,6 +347,9 @@ TreeViewDemoCtl.xaml + + EffectsDemoCtl.xaml + GeometryAnimationDemoCtl.xaml @@ -863,6 +866,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs index 0aa76e77..0d469540 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs @@ -519,6 +519,15 @@ namespace HandyControlDemo.Properties.Langs { } } + /// + /// 查找类似 效果 的本地化字符串。 + /// + public static string Effects { + get { + return ResourceManager.GetString("Effects", resourceCulture); + } + } + /// /// 查找类似 邮箱 的本地化字符串。 /// diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx index 95647270..561df37e 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx @@ -690,4 +690,7 @@ Drawer + + Effects + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx index f7c92746..b0c64b31 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx @@ -690,4 +690,7 @@ Drawer + + Effects + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx index cd855df0..17878747 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx @@ -690,4 +690,7 @@ Drawer + + Effects + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx index 813ca2e5..ca3e4807 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx @@ -690,4 +690,7 @@ 抽屉 + + 效果 + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Effects_16x.png b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Effects_16x.png new file mode 100644 index 0000000000000000000000000000000000000000..67d9e6142c4d2cfa4811ea3c4f3f65cb2394c687 GIT binary patch literal 369 zcmV-%0gnEOP)pGBS}O-RCr$1lCO?~KoEy{gg!zap^wnuNwByIJRWrld%=^OM4rG? zjjF*Hk66J!xwqeBm*%zxbK*!w%JTb_Hh_(7zXb4=Y>uH z5OP2P0)8N{*#Sb3*#l?f1hg;oS0^x?;OrLbFWNr~aCXSh%=3H+{?+#b?i8jaD+S}f P00000NkvXXu0mjf;3T4< literal 0 HcmV?d00001 diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml new file mode 100644 index 00000000..312cec54 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml.cs new file mode 100644 index 00000000..7f56b93f --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/EffectsDemoCtl.xaml.cs @@ -0,0 +1,10 @@ +namespace HandyControlDemo.UserControl +{ + public partial class EffectsDemoCtl + { + public EffectsDemoCtl() + { + InitializeComponent(); + } + } +} diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index f5f1e48d..e8fea193 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -59,6 +59,7 @@ + diff --git a/src/Shared/HandyControl_Shared/Media/Effects/ColorComplementEffect.cs b/src/Shared/HandyControl_Shared/Media/Effects/ColorComplementEffect.cs index bae72b0d..f9871671 100644 --- a/src/Shared/HandyControl_Shared/Media/Effects/ColorComplementEffect.cs +++ b/src/Shared/HandyControl_Shared/Media/Effects/ColorComplementEffect.cs @@ -22,6 +22,7 @@ namespace HandyControl.Media.Effects public ColorComplementEffect() { PixelShader = Shader; + UpdateShaderValue(InputProperty); } diff --git a/src/Shared/HandyControl_Shared/Media/Effects/GrayScaleEffect.cs b/src/Shared/HandyControl_Shared/Media/Effects/GrayScaleEffect.cs new file mode 100644 index 00000000..2a972ea9 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Media/Effects/GrayScaleEffect.cs @@ -0,0 +1,46 @@ +using System; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Effects; +using HandyControl.Data; + +namespace HandyControl.Media.Effects +{ + public class GrayScaleEffect : ShaderEffect + { + public static readonly DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty("Input", typeof(GrayScaleEffect), 0); + + private static readonly PixelShader Shader; + + static GrayScaleEffect() + { + Shader = new PixelShader + { + UriSource = new Uri("pack://application:,,,/HandyControl;component/Resources/Effects/GrayScaleEffect.ps") + }; + } + + public GrayScaleEffect() + { + PixelShader = Shader; + + UpdateShaderValue(InputProperty); + UpdateShaderValue(ScaleProperty); + } + + public Brush Input + { + get => (Brush)GetValue(InputProperty); + set => SetValue(InputProperty, value); + } + + public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register( + "Scale", typeof(double), typeof(GrayScaleEffect), new PropertyMetadata(ValueBoxes.Double1Box, PixelShaderConstantCallback(0))); + + public double Scale + { + get => (double) GetValue(ScaleProperty); + set => SetValue(ScaleProperty, value); + } + } +} diff --git a/src/Shared/HandyControl_Shared/Resources/Effects/GrayScaleEffect.ps b/src/Shared/HandyControl_Shared/Resources/Effects/GrayScaleEffect.ps new file mode 100644 index 0000000000000000000000000000000000000000..3b4ab0a9640df2e608132d8f95dbf5c708cacf3f GIT binary patch literal 384 zcmYjMu};G<5Pfl5k)cw40EvvSM3pOqx`1dIKxzkQJ6Ba&gr$^3P1qPB@dJEwn*>{F8=GR1+EbhnW0KVv;CKxP-2YfO-&^wL_EEuhA=(f(|nOK3Q zc3GlgRXn|C9|h{Vi$3#qwU)>0WJ}$?cB*IjO0EW&sd%5}>1z>QzFdWm)A=-S@vALaF}_0%9+<)fcuPh8~eViv;8=S(~JTB E0HJn62><{9 literal 0 HcmV?d00001