Skip to content

Commit 708c22f

Browse files
committed
Update v2.4
1 parent 225c2cd commit 708c22f

15 files changed

Lines changed: 362 additions & 3 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"C:\Program Files (x86)\Windows Kits\10\bin\x64\fxc.exe" /T ps_2_0 /E main /Fo "FakeShader.ps" "FakeShader.fx"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Media.Effects;
7+
8+
namespace EmptyKeys.UserInterface.Designer.Effects
9+
{
10+
/// <summary>
11+
/// Implements empty class for custom effect shader - fake class for designer
12+
/// </summary>
13+
/// <seealso cref="System.Windows.Media.Effects.ShaderEffect" />
14+
public class CustomEffect : ShaderEffect
15+
{
16+
/// <summary>
17+
/// The effect asset property
18+
/// </summary>
19+
public static readonly DependencyProperty EffectAssetProperty =
20+
DependencyProperty.Register("EffectAsset", typeof(string), typeof(CustomEffect),
21+
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.None));
22+
23+
/// <summary>
24+
/// Gets or sets the effect asset.
25+
/// </summary>
26+
/// <value>
27+
/// The effect asset.
28+
/// </value>
29+
public string EffectAsset
30+
{
31+
get { return (string)GetValue(EffectAssetProperty); }
32+
set { SetValue(EffectAssetProperty, value); }
33+
}
34+
35+
/// <summary>
36+
/// Initializes a new instance of the <see cref="CustomEffect"/> class.
37+
/// </summary>
38+
public CustomEffect() : base()
39+
{
40+
var pixelShader = new PixelShader();
41+
var fileUri = new Uri("pack://application:,,,/EmptyKeys.UserInterface.Designer;component/Effects/FakeShader.ps", UriKind.RelativeOrAbsolute);
42+
pixelShader.UriSource = fileUri;
43+
PixelShader = pixelShader;
44+
}
45+
}
46+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Media.Effects;
7+
8+
namespace EmptyKeys.UserInterface.Designer.Effects
9+
{
10+
/// <summary>
11+
/// Implements Directional Blur effect
12+
/// </summary>
13+
public class DirectionalBlurEffect : ShaderEffect
14+
{
15+
private static Type typeOfThis = typeof(DirectionalBlurEffect);
16+
17+
/// <summary>
18+
/// The angle property
19+
/// </summary>
20+
public static readonly DependencyProperty AngleProperty =
21+
DependencyProperty.Register("Angle", typeof(float), typeOfThis,
22+
new FrameworkPropertyMetadata(0f, FrameworkPropertyMetadataOptions.AffectsRender));
23+
24+
/// <summary>
25+
/// Gets or sets the angle.
26+
/// </summary>
27+
/// <value>
28+
/// The angle.
29+
/// </value>
30+
public float Angle
31+
{
32+
get { return (float)GetValue(AngleProperty); }
33+
set { SetValue(AngleProperty, value); }
34+
}
35+
36+
/// <summary>
37+
/// The blur amount property
38+
/// </summary>
39+
public static readonly DependencyProperty BlurAmountProperty =
40+
DependencyProperty.Register("BlurAmount", typeof(float), typeOfThis,
41+
new FrameworkPropertyMetadata(0f, FrameworkPropertyMetadataOptions.AffectsRender));
42+
43+
/// <summary>
44+
/// Gets or sets the blur amount.
45+
/// </summary>
46+
/// <value>
47+
/// The blur amount.
48+
/// </value>
49+
public float BlurAmount
50+
{
51+
get { return (float)GetValue(BlurAmountProperty); }
52+
set { SetValue(BlurAmountProperty, value); }
53+
}
54+
55+
/// <summary>
56+
/// Initializes a new instance of the <see cref="DirectionalBlurEffect"/> class.
57+
/// </summary>
58+
public DirectionalBlurEffect() : base()
59+
{
60+
var pixelShader = new PixelShader();
61+
var fileUri = new Uri("pack://application:,,,/EmptyKeys.UserInterface.Designer;component/Effects/FakeShader.ps", UriKind.RelativeOrAbsolute);
62+
pixelShader.UriSource = fileUri;
63+
PixelShader = pixelShader;
64+
}
65+
}
66+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//--------------------------------------------------------------------------------------
2+
//
3+
// Fake shader
4+
//
5+
//--------------------------------------------------------------------------------------
6+
7+
//-----------------------------------------------------------------------------------------
8+
// Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.)
9+
//-----------------------------------------------------------------------------------------
10+
11+
//--------------------------------------------------------------------------------------
12+
// Sampler Inputs (Brushes, including ImplicitInput)
13+
//--------------------------------------------------------------------------------------
14+
15+
sampler2D implicitInputSampler : register(S0);
16+
17+
//--------------------------------------------------------------------------------------
18+
// Pixel Shader
19+
//--------------------------------------------------------------------------------------
20+
21+
float4 main(float2 uv : TEXCOORD) : COLOR
22+
{
23+
float4 color = tex2D(implicitInputSampler, uv);
24+
return color;
25+
}
216 Bytes
Binary file not shown.

EmptyKeys.UserInterface.Designer/EmptyKeys.UserInterface.Designer.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
<Compile Include="Charts\SeriesPointCollection.cs" />
6969
<Compile Include="DataGrid.cs" />
7070
<Compile Include="DragDrop.cs" />
71+
<Compile Include="Effects\CustomEffect.cs" />
72+
<Compile Include="Effects\DirectionalBlurEffect.cs" />
7173
<Compile Include="EventTrigger.cs" />
7274
<Compile Include="GeneratedBindingsMode.cs" />
7375
<Compile Include="GeneratedBindings.cs" />
@@ -113,13 +115,22 @@
113115
<Generator>ResXFileCodeGenerator</Generator>
114116
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
115117
</EmbeddedResource>
118+
<Resource Include="Effects\FakeShader.ps" />
116119
<None Include="Properties\Settings.settings">
117120
<Generator>SettingsSingleFileGenerator</Generator>
118121
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
119122
</None>
120123
<AppDesigner Include="Properties\" />
121124
</ItemGroup>
125+
<ItemGroup>
126+
<Content Include="Effects\FakeShader.fx" />
127+
<None Include="Effects\CompileShader.bat" />
128+
</ItemGroup>
122129
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
130+
<PropertyGroup>
131+
<PreBuildEvent>
132+
</PreBuildEvent>
133+
</PropertyGroup>
123134
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
124135
Other similar extension points exist, see Microsoft.Common.targets.
125136
<Target Name="BeforeBuild">

GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313

1414
[assembly: NeutralResourcesLanguage("en")]
1515

16-
[assembly: AssemblyVersion("2.3.0.0")]
17-
[assembly: AssemblyFileVersion("2.3.0.0")]
16+
[assembly: AssemblyVersion("2.4.0.0")]
17+
[assembly: AssemblyFileVersion("2.4.0.0")]

UIGenerator/CodeComHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ public static void GenerateTemplateStyleField(CodeTypeDeclaration parentClass, C
10661066
CodeExpression valueExpr = GetValueExpression(parentClass, method, value, name);
10671067
method.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(target, property.Name), valueExpr));
10681068
}
1069-
}
1069+
}
10701070

10711071
/// <summary>
10721072
/// Gets the resource key expression.

UIGenerator/EffectAssets.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using System.CodeDom;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace EmptyKeys.UserInterface.Generator
9+
{
10+
/// <summary>
11+
/// Implements Effect Assets store
12+
/// </summary>
13+
public sealed class EffectAssets
14+
{
15+
private static EffectAssets singleton = new EffectAssets();
16+
17+
/// <summary>
18+
/// Gets the instance.
19+
/// </summary>
20+
/// <value>
21+
/// The instance.
22+
/// </value>
23+
public static EffectAssets Instance
24+
{
25+
get
26+
{
27+
return singleton;
28+
}
29+
}
30+
31+
private List<string> effectAssets = new List<string>();
32+
33+
/// <summary>
34+
/// Prevents a default instance of the <see cref="EffectAssets"/> class from being created.
35+
/// </summary>
36+
private EffectAssets()
37+
{
38+
}
39+
40+
/// <summary>
41+
/// Adds the effect.
42+
/// </summary>
43+
/// <param name="assetName">Name of the asset.</param>
44+
public void AddEffect(string assetName)
45+
{
46+
if (!effectAssets.Contains(assetName))
47+
{
48+
effectAssets.Add(assetName);
49+
}
50+
}
51+
52+
/// <summary>
53+
/// Generates the manager code.
54+
/// </summary>
55+
/// <param name="method">The method.</param>
56+
public void GenerateManagerCode(CodeMemberMethod method)
57+
{
58+
foreach (var asset in effectAssets)
59+
{
60+
method.Statements.Add(new CodeMethodInvokeExpression(
61+
new CodeFieldReferenceExpression(
62+
new CodeTypeReferenceExpression("EffectManager"), "Instance"),
63+
"AddEffect",
64+
new CodePrimitiveExpression(asset)));
65+
}
66+
}
67+
68+
/// <summary>
69+
/// Clears the assets.
70+
/// </summary>
71+
public void ClearAssets()
72+
{
73+
effectAssets.Clear();
74+
}
75+
}
76+
}

UIGenerator/EmptyKeys.UserInterface.Generator.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
</Compile>
5757
<Compile Include="BindingGenerator.cs" />
5858
<Compile Include="CodeComHelper.cs" />
59+
<Compile Include="EffectAssets.cs" />
5960
<Compile Include="FontGenerator.cs" />
6061
<Compile Include="FontInfo.cs" />
6162
<Compile Include="IGeneratorValue.cs" />
@@ -137,6 +138,8 @@
137138
<Compile Include="Values\BrushGeneratorValue.cs" />
138139
<Compile Include="Values\ColorGeneratorValue.cs" />
139140
<Compile Include="Values\DoubleAnimationGeneratorValue.cs" />
141+
<Compile Include="Values\Effects\CustomEffectGeneratorValue.cs" />
142+
<Compile Include="Values\Effects\DirectionalBlurEffectGeneratorValue.cs" />
140143
<Compile Include="Values\EllipseGeometryGeneratorValue.cs" />
141144
<Compile Include="Values\FontFamilyGeneratorValue.cs" />
142145
<Compile Include="Values\LineGeometryGeneratorValue.cs" />

0 commit comments

Comments
 (0)