aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/ProtoEnumFile.cshtml
blob: d659a028e48ef78b4bdac6c9a21f67c23666b01e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Tango PMR Generator
// 
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. Do not modify!
// </auto-generated>
//------------------------------------------------------------------------------

syntax = "proto3";

@foreach (var import in Model.Imports)
{
    <div>
        import "@(import)";
    </div>
}

package @(Model.Package);
option java_package = "com.twine.@(Model.Package.ToLower())";

enum @(Model.Name)
{
    @foreach (var prop in Model.Fields)
    {
    <div>
        @(prop.Description != null ? ("//" + prop.Description) : "")
        @(prop.Name) = @(prop.Value);
    </div>
    }
}
ighlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
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);
            }
        }
    }
}