aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-09 18:30:58 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-09 18:30:58 +0300
commita898decf18c4c0ed56d020dc09df55df1ca0263a (patch)
tree66140670047d9ec9d7a0bbeb2851a84868b9515c /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common
parent4cd266e13bdb3e27ca77eba3b47278b57a0dcd8d (diff)
downloadTango-a898decf18c4c0ed56d020dc09df55df1ca0263a.tar.gz
Tango-a898decf18c4c0ed56d020dc09df55df1ca0263a.zip
Lots of changes :/
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs14
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs71
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs31
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj11
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wavbin0 -> 161420 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wavbin0 -> 146748 bytes
6 files changed, 126 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs
new file mode 100644
index 000000000..549022050
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+
+namespace Tango.MachineStudio.Common.Html
+{
+ public interface IHtmlPresenter
+ {
+ bool DisplayHtml(HtmlPage html);
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs
new file mode 100644
index 000000000..fb34c8086
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Media;
+using System.Speech.Synthesis;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+using Tango.Core.Helpers;
+
+namespace Tango.MachineStudio.Common.Speech
+{
+ /// <summary>
+ /// Represents the default speech provider.
+ /// </summary>
+ /// <seealso cref="Tango.Core.ExtendedObject" />
+ /// <seealso cref="Tango.MachineStudio.Common.Speech.ISpeechProvider" />
+ public class DefaultSpeechProvider : ExtendedObject, ISpeechProvider
+ {
+ private SpeechSynthesizer _speech;
+ private SoundPlayer _soundPlayer;
+ private SoundPlayer _soundPlayerErr;
+
+ private bool _mute;
+ /// <summary>
+ /// Gets or sets a value indicating whether this <see cref="ISpeechProvider" /> is mute.
+ /// </summary>
+ public bool Mute
+ {
+ get { return _mute; }
+ set { _mute = value; RaisePropertyChangedAuto(); }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DefaultSpeechProvider"/> class.
+ /// </summary>
+ public DefaultSpeechProvider()
+ {
+ _speech = new SpeechSynthesizer();
+ _soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Common.bip.wav"));
+ _soundPlayerErr = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Common.error.wav"));
+ _speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name);
+ }
+
+ /// <summary>
+ /// Speaks the specified text associated with an information sound.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ public void SpeakInfo(string text)
+ {
+ if (!Mute)
+ {
+ _soundPlayer.Play();
+ _speech.SpeakAsync(text);
+ }
+ }
+
+ /// <summary>
+ /// Speaks the specified text associated with an error sound.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ public void SpeakError(string text)
+ {
+ if (!Mute)
+ {
+ _soundPlayerErr.Play();
+ _speech.SpeakAsync(text);
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs
new file mode 100644
index 000000000..eb31bdc39
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Common.Speech
+{
+ /// <summary>
+ /// Represents a text to speech engine.
+ /// </summary>
+ public interface ISpeechProvider
+ {
+ /// <summary>
+ /// Gets or sets a value indicating whether this <see cref="ISpeechProvider"/> is mute.
+ /// </summary>
+ bool Mute { get; set; }
+
+ /// <summary>
+ /// Speaks the specified text associated with an information sound.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ void SpeakInfo(String text);
+
+ /// <summary>
+ /// Speaks the specified text associated with an error sound.
+ /// </summary>
+ /// <param name="text">The text.</param>
+ void SpeakError(String text);
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
index df553f502..bbbab06ab 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
@@ -66,6 +66,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
+ <Reference Include="System.Speech" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
@@ -104,10 +105,13 @@
<Compile Include="EventLogging\DefaultEventLogger.cs" />
<Compile Include="EventLogging\IEventLogger.cs" />
<Compile Include="ExtensionMethods\CommonDialogExtensions.cs" />
+ <Compile Include="Html\IHtmlPresenter.cs" />
<Compile Include="Helpers\GraphsHelper.cs" />
<Compile Include="Messages\MachineConnectionChangedMessage.cs" />
<Compile Include="Notifications\BarItem.cs" />
<Compile Include="Notifications\DialogViewVM.cs" />
+ <Compile Include="Speech\DefaultSpeechProvider.cs" />
+ <Compile Include="Speech\ISpeechProvider.cs" />
<Compile Include="StudioApplication\IModuleRequestListener.cs" />
<Compile Include="StudioApplication\IShutdownListener.cs" />
<Compile Include="StudioApplication\IStudioApplicationManager.cs" />
@@ -258,6 +262,11 @@
<Name>Tango.Video</Name>
</ProjectReference>
</ItemGroup>
- <ItemGroup />
+ <ItemGroup>
+ <EmbeddedResource Include="bip.wav" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="error.wav" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav
new file mode 100644
index 000000000..5a1d74045
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav
new file mode 100644
index 000000000..4dce7d623
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav
Binary files differ