aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
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/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
parent4cd266e13bdb3e27ca77eba3b47278b57a0dcd8d (diff)
downloadTango-a898decf18c4c0ed56d020dc09df55df1ca0263a.tar.gz
Tango-a898decf18c4c0ed56d020dc09df55df1ca0263a.zip
Lots of changes :/
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs66
1 files changed, 35 insertions, 31 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index 7891f96b7..cdfeee54d 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -34,6 +34,7 @@ using Tango.Core.Helpers;
using System.Speech.Synthesis;
using System.Media;
using Tango.MachineStudio.Common.EventLogging;
+using Tango.MachineStudio.Common.Speech;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -55,10 +56,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
private IAuthenticationProvider _authentication;
private ObservablesContext _machineDbContext;
private ObservablesContext _activeJobDbContext;
- private SpeechSynthesizer _speech;
- private SoundPlayer _soundPlayer;
- private SoundPlayer _soundPlayerErr;
private IEventLogger _eventLogger;
+ private ISpeechProvider _speech;
#region Properties
@@ -112,7 +111,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _spoolTypes = value; RaisePropertyChangedAuto(); }
}
-
/// <summary>
/// Gets or sets the application manager.
/// </summary>
@@ -473,6 +471,16 @@ namespace Tango.MachineStudio.Developer.ViewModels
set { _jobFilter = value; RaisePropertyChangedAuto(); OnJobFilterChanged(); }
}
+ private ObservableCollection<MachinesEvent> _jobEvents;
+ /// <summary>
+ /// Gets or sets the running job events.
+ /// </summary>
+ public ObservableCollection<MachinesEvent> JobEvents
+ {
+ get { return _jobEvents; }
+ set { _jobEvents = value; RaisePropertyChangedAuto(); }
+ }
+
#endregion
#region Commands
@@ -600,10 +608,12 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger)
+ public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication, IEventLogger eventLogger, ISpeechProvider speech)
{
SelectedJobs = new ObservableCollection<Job>();
+ JobEvents = new ObservableCollection<MachinesEvent>();
+
LogManager.Log("Initializing machine Db context...");
_machineDbContext = ObservablesContext.CreateDefault();
@@ -624,6 +634,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
_authentication = authentication;
_notification = notificationProvider;
+ _speech = speech;
_navigation = navigation;
ApplicationManager = applicationManager;
VideoCaptureProvider = videoCaptureProvider;
@@ -631,11 +642,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Initializing relay commands...");
- _speech = new SpeechSynthesizer();
- _soundPlayer = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.bip.wav"));
- _soundPlayerErr = new SoundPlayer(EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.Developer.error.wav"));
- _speech.SelectVoice(_speech.GetInstalledVoices().LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female).VoiceInfo.Name);
-
//Initialize Commands...
EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null);
EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null);
@@ -662,12 +668,25 @@ namespace Tango.MachineStudio.Developer.ViewModels
DisplayJobEmbroideryFileCommand = new RelayCommand<Job>(DisplayJobEmbroideryFile);
ApplicationManager.ConnectedMachineChanged += ApplicationManager_ConnectedMachineChanged;
+
+ _eventLogger.NewLog += _eventLogger_NewLog;
}
#endregion
#region Event Handlers
+ private void _eventLogger_NewLog(object sender, MachinesEvent e)
+ {
+ if (IsJobRunning)
+ {
+ InvokeUI(() =>
+ {
+ JobEvents.Add(e);
+ });
+ }
+ }
+
/// <summary>
/// Handles the application manager connected machine changes event.
/// </summary>
@@ -744,7 +763,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
{
if (IsJobRunning)
{
- SpeakError(events.Last().EventType.Name);
+ _speech.SpeakError(events.Last().EventType.Name);
if (events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.AbortRunningJob)))
{
@@ -758,22 +777,6 @@ namespace Tango.MachineStudio.Developer.ViewModels
#endregion
- #region Sound
-
- private void SpeakInfo(String text)
- {
- _soundPlayer.Play();
- _speech.SpeakAsync(text);
- }
-
- private void SpeakError(String text)
- {
- _soundPlayerErr.Play();
- _speech.SpeakAsync(text);
- }
-
- #endregion
-
#region Properties Changes
/// <summary>
@@ -961,7 +964,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
IsJobRunning = false;
IsJobFailed = true;
- SpeakError("Job Failed!");
+ _speech.SpeakError("Job Failed!");
}
}
@@ -973,7 +976,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Setting job completed state...");
IsJobRunning = false;
IsJobCompleted = true;
- SpeakInfo("Job Completed!");
+ _speech.SpeakInfo("Job Completed!");
}
/// <summary>
@@ -994,6 +997,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
return;
}
+ JobEvents.Clear();
RunningJobRemainingTime = TimeSpan.Zero;
RunningJobProgress = 0;
IsJobFailed = false;
@@ -1048,12 +1052,12 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (segment.ID != -1)
{
- SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ _speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
_eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex));
}
else
{
- SpeakInfo(String.Format("Inter Segment Started."));
+ _speech.SpeakInfo(String.Format("Inter Segment Started."));
_eventLogger.Log("Inter Segment Started.");
}
}