Skip to content

Commit 3135ba8

Browse files
committed
Update version 2.2
1 parent 5cf23cb commit 3135ba8

7 files changed

Lines changed: 86 additions & 12 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Compile Include="Interactions\EventTriggerBehavior.cs" />
8484
<Compile Include="Interactions\Interaction.cs" />
8585
<Compile Include="Interactions\InvokeCommandAction.cs" />
86+
<Compile Include="Interactions\PlaySoundAction.cs" />
8687
<Compile Include="NumericTextBox.cs" />
8788
<Compile Include="PasswordBox.cs" />
8889
<Compile Include="Properties\AssemblyInfo.cs">
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
8+
namespace EmptyKeys.UserInterface.Designer.Interactions
9+
{
10+
public class PlaySoundAction : Action
11+
{
12+
/// <summary>
13+
/// The source property
14+
/// </summary>
15+
public static readonly DependencyProperty SourceProperty =
16+
DependencyProperty.Register("Source", typeof(SoundSource), typeof(PlaySoundAction),
17+
new FrameworkPropertyMetadata(null));
18+
19+
/// <summary>
20+
/// Gets or sets the source.
21+
/// </summary>
22+
/// <value>
23+
/// The source.
24+
/// </value>
25+
public SoundSource Source
26+
{
27+
get { return (SoundSource)GetValue(SourceProperty); }
28+
set { SetValue(SourceProperty, value); }
29+
}
30+
}
31+
}

EmptyKeys.UserInterface.Designer/SoundSource.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ public SoundType SoundType
5050
set { SetValue(SoundTypeProperty, value); }
5151
}
5252

53+
/// <summary>
54+
/// The volume property
55+
/// </summary>
56+
public static readonly DependencyProperty VolumeProperty =
57+
DependencyProperty.Register("Volume", typeof(float), typeof(SoundSource),
58+
new FrameworkPropertyMetadata(1f));
59+
60+
/// <summary>
61+
/// Gets or sets the volume.
62+
/// </summary>
63+
/// <value>
64+
/// The volume.
65+
/// </value>
66+
public float Volume
67+
{
68+
get { return (float)GetValue(VolumeProperty); }
69+
set { SetValue(VolumeProperty, value); }
70+
}
71+
5372
/// <summary>
5473
/// Initializes a new instance of the <see cref="SoundSource"/> class.
5574
/// </summary>

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.1.0.0")]
17-
[assembly: AssemblyFileVersion("2.1.0.0")]
16+
[assembly: AssemblyVersion("2.2.0.0")]
17+
[assembly: AssemblyFileVersion("2.2.0.0")]

UIGenerator/CodeComHelper.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -990,19 +990,30 @@ public static void GenerateSoundSources(CodeMemberMethod method, SoundSourceColl
990990
{
991991
foreach (var sound in sounds)
992992
{
993-
CodeMethodInvokeExpression addSound = new CodeMethodInvokeExpression(
994-
new CodeVariableReferenceExpression(collVar), "Add",
995-
new CodeSnippetExpression(
996-
string.Format("new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \"{1}\" }}", sound.SoundType, sound.SoundAsset)));
993+
var soundSource = GenerateSoundSource(method, sound);
994+
CodeMethodInvokeExpression addSound = new CodeMethodInvokeExpression(new CodeVariableReferenceExpression(collVar), "Add", soundSource);
997995
method.Statements.Add(addSound);
998-
999-
method.Statements.Add(new CodeMethodInvokeExpression(
1000-
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("SoundManager"), "Instance"),
1001-
"AddSound",
1002-
new CodePrimitiveExpression(sound.SoundAsset)));
1003996
}
1004997
}
1005998

999+
/// <summary>
1000+
/// Generates the sound source.
1001+
/// </summary>
1002+
/// <param name="method">The method.</param>
1003+
/// <param name="sound">The sound.</param>
1004+
public static CodeSnippetExpression GenerateSoundSource(CodeMemberMethod method, SoundSource sound)
1005+
{
1006+
CodeSnippetExpression expression = new CodeSnippetExpression(
1007+
string.Format("new SoundSource {{ SoundType = SoundType.{0}, SoundAsset = \"{1}\", Volume = {2}f }}", sound.SoundType, sound.SoundAsset, sound.Volume));
1008+
1009+
method.Statements.Add(new CodeMethodInvokeExpression(
1010+
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("SoundManager"), "Instance"),
1011+
"AddSound",
1012+
new CodePrimitiveExpression(sound.SoundAsset)));
1013+
1014+
return expression;
1015+
}
1016+
10061017
private static List<DependencyProperty> GetAttachedProperties(DependencyObject obj)
10071018
{
10081019
List<DependencyProperty> result = new List<DependencyProperty>();

UIGenerator/FontGenerator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ public void GenerateFontAssets(string path, RenderMode renderMode)
122122

123123
string fullPath = Path.Combine(path, assetName) + extension;
124124

125+
if (File.Exists(fullPath))
126+
{
127+
Console.WriteLine(string.Format("Font {0} , size {1}, style {2} file already exists on {3}", fontName, fontSize, fontStyle, fullPath));
128+
continue;
129+
}
130+
125131
using (StreamWriter outfile = new StreamWriter(fullPath, false, Encoding.UTF8))
126132
{
127133
outfile.Write(fileContent);

UIGenerator/Types/ElementGeneratorType.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Windows.Data;
1111
using System.Windows.Input;
1212
using System.Windows.Media.Animation;
13+
using EmptyKeys.UserInterface.Designer;
1314
using EmptyKeys.UserInterface.Designer.Input;
1415
using EmptyKeys.UserInterface.Designer.Interactions;
1516

@@ -229,9 +230,14 @@ private void GenerateBehaviorActions(ActionCollection actionCollection, CodeType
229230
{
230231
PropertyPath path = entry.Value as PropertyPath;
231232
method.Statements.Add(new CodeAssignStatement(
232-
new CodeFieldReferenceExpression(actionVarRef, property.Name),
233+
new CodeFieldReferenceExpression(actionVarRef, property.Name),
233234
new CodeObjectCreateExpression("PropertyPath", new CodePrimitiveExpression(path.Path))));
234235
}
236+
else if (entry.Value is SoundSource)
237+
{
238+
var soundSource = CodeComHelper.GenerateSoundSource(method, entry.Value as SoundSource);
239+
method.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(actionVarRef, property.Name), soundSource));
240+
}
235241
else
236242
{
237243
MethodInfo generic = generateFieldMethod.MakeGenericMethod(property.PropertyType);

0 commit comments

Comments
 (0)