From a898decf18c4c0ed56d020dc09df55df1ca0263a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 9 Apr 2018 18:30:58 +0300 Subject: Lots of changes :/ --- .../ViewModels/MainViewVM.cs | 66 +++++----- .../Views/RunningJobView.xaml | 83 ++++++++++++- .../Html/IHtmlPresenter.cs | 14 +++ .../Speech/DefaultSpeechProvider.cs | 71 +++++++++++ .../Speech/ISpeechProvider.cs | 31 +++++ .../Tango.MachineStudio.Common.csproj | 11 +- .../Tango.MachineStudio.Common/bip.wav | Bin 0 -> 161420 bytes .../Tango.MachineStudio.Common/error.wav | Bin 0 -> 146748 bytes .../Html/DefaultHtmlPresenter.cs | 25 ++++ .../Tango.MachineStudio.UI/Html/HtmlWindow.xaml | 37 ++++++ .../Tango.MachineStudio.UI/Html/HtmlWindow.xaml.cs | 48 ++++++++ .../Tango.MachineStudio.UI.csproj | 8 ++ .../Tango.MachineStudio.UI/ViewModelLocator.cs | 7 ++ .../ViewModels/MainViewVM.cs | 40 +++++- .../Tango.MachineStudio.UI/Views/MainView.xaml | 88 ++++++++++---- .../Visual_Studio/Tango.BL/Entities/EventType.cs | 42 +++++++ .../Tango.BL/Entities/HardwareDancer.cs | 20 +++ .../Visual_Studio/Tango.BL/Entities/HtmlPage.cs | 126 +++++++++++++++++++ .../Tango.BL/Enumerations/ActionTypes.cs | 6 + .../Tango.BL/Enumerations/HtmlPages.cs | 19 +++ .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 ++ .../ObservablesEntitiesAdapterExtension.cs | 38 ++++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 1 + .../Tango.DAL.Remote/DB/EVENT_TYPES.cs | 2 + .../Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs | 1 + .../Tango.DAL.Remote/DB/HTML_PAGES.cs | 34 ++++++ .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 79 ++++++++++++ .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 134 +++++++++++---------- .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 3 + 30 files changed, 914 insertions(+), 129 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Html/IHtmlPresenter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/DefaultSpeechProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Speech/ISpeechProvider.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/DefaultHtmlPresenter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/HtmlPage.cs create mode 100644 Software/Visual_Studio/Tango.BL/Enumerations/HtmlPages.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/HTML_PAGES.cs (limited to 'Software/Visual_Studio') 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(); } } - /// /// Gets or sets the application manager. /// @@ -473,6 +471,16 @@ namespace Tango.MachineStudio.Developer.ViewModels set { _jobFilter = value; RaisePropertyChangedAuto(); OnJobFilterChanged(); } } + private ObservableCollection _jobEvents; + /// + /// Gets or sets the running job events. + /// + public ObservableCollection JobEvents + { + get { return _jobEvents; } + set { _jobEvents = value; RaisePropertyChangedAuto(); } + } + #endregion #region Commands @@ -600,10 +608,12 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// The application manager. /// The notification provider. - 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(); + JobEvents = new ObservableCollection(); + 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(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); + }); + } + } + /// /// Handles the application manager connected machine changes event. /// @@ -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 /// @@ -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!"); } /// @@ -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."); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml index 30941f3dd..94570196f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/RunningJobView.xaml @@ -3,12 +3,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" xmlns:global="clr-namespace:Tango.MachineStudio.Developer" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + + + + @@ -29,13 +35,78 @@ - + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + 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 +{ + /// + /// Represents the default speech provider. + /// + /// + /// + public class DefaultSpeechProvider : ExtendedObject, ISpeechProvider + { + private SpeechSynthesizer _speech; + private SoundPlayer _soundPlayer; + private SoundPlayer _soundPlayerErr; + + private bool _mute; + /// + /// Gets or sets a value indicating whether this is mute. + /// + public bool Mute + { + get { return _mute; } + set { _mute = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + 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); + } + + /// + /// Speaks the specified text associated with an information sound. + /// + /// The text. + public void SpeakInfo(string text) + { + if (!Mute) + { + _soundPlayer.Play(); + _speech.SpeakAsync(text); + } + } + + /// + /// Speaks the specified text associated with an error sound. + /// + /// The text. + 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 +{ + /// + /// Represents a text to speech engine. + /// + public interface ISpeechProvider + { + /// + /// Gets or sets a value indicating whether this is mute. + /// + bool Mute { get; set; } + + /// + /// Speaks the specified text associated with an information sound. + /// + /// The text. + void SpeakInfo(String text); + + /// + /// Speaks the specified text associated with an error sound. + /// + /// The text. + 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 @@ + ..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll @@ -104,10 +105,13 @@ + + + @@ -258,6 +262,11 @@ Tango.Video - + + + + + + \ 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 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav 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 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/DefaultHtmlPresenter.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/DefaultHtmlPresenter.cs new file mode 100644 index 000000000..eff8c98a0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/DefaultHtmlPresenter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Tango.BL.Entities; +using Tango.MachineStudio.Common.Html; +using Tango.MachineStudio.UI.Windows; + +namespace Tango.MachineStudio.UI.Html +{ + public class DefaultHtmlPresenter : IHtmlPresenter + { + public bool DisplayHtml(HtmlPage html) + { + HtmlWindow dialog = new HtmlWindow(html); + dialog.Owner = Application.Current.MainWindow; + MainWindow.Instance.shadowGrid.Visibility = Visibility.Visible; + var result = dialog.ShowDialog(); + MainWindow.Instance.shadowGrid.Visibility = Visibility.Hidden; + return result.Value; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml new file mode 100644 index 000000000..654d2d0eb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml.cs new file mode 100644 index 000000000..9f37eba06 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml.cs @@ -0,0 +1,48 @@ +using MahApps.Metro.Controls; +using MaterialDesignThemes.Wpf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using Tango.BL.Entities; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.UI.Html +{ + /// + /// Interaction logic for DialogWindow.xaml + /// + public partial class HtmlWindow : Window + { + public HtmlWindow(HtmlPage html) + { + InitializeComponent(); + + webBrowser.Loaded += (_, __) => + { + webBrowser.NavigateToString(html.Html); + }; + } + + private void OKClicked(object sender, RoutedEventArgs e) + { + DialogResult = true; + Close(); + } + + private void CloseClicked(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 07b1f44fe..4befd2f5c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -143,6 +143,10 @@ MSBuild:Compile Designer + + + HtmlWindow.xaml + TextInputBoxWindow.xaml @@ -199,6 +203,10 @@ ModuleWindow.xaml + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 571122eb5..bbb916d02 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -7,12 +7,15 @@ using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.Html; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.Speech; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Common.Video; using Tango.MachineStudio.UI.Authentication; +using Tango.MachineStudio.UI.Html; using Tango.MachineStudio.UI.Modules; using Tango.MachineStudio.UI.Navigation; using Tango.MachineStudio.UI.Notifications; @@ -59,6 +62,8 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); SimpleIoc.Default.Unregister(); + SimpleIoc.Default.Unregister(); + SimpleIoc.Default.Unregister(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); @@ -69,6 +74,8 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index c9f4b3441..3cb728395 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -20,10 +20,12 @@ using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Diagnostics; using Tango.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.Html; using Tango.MachineStudio.Common.Messages; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.Speech; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Common.Update; using Tango.MachineStudio.UI.StudioApplication; @@ -49,6 +51,7 @@ namespace Tango.MachineStudio.UI.ViewModels private bool _isDisconnecting; private Thread _updateCheckThread; private IEventLogger _eventLogger; + private IHtmlPresenter _htmlPresenter; /// /// Gets or sets the current loaded module. @@ -129,6 +132,16 @@ namespace Tango.MachineStudio.UI.ViewModels /// public RelayCommand UpdateCenterCommand { get; set; } + /// + /// Gets or sets the toggle speech command. + /// + public RelayCommand ToggleSpeechCommand { get; set; } + + /// + /// Gets or sets the display HTML command. + /// + public RelayCommand ResolveMachineEventCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// /// Gets or sets the authentication provider. @@ -169,6 +182,11 @@ namespace Tango.MachineStudio.UI.ViewModels set { _applicationManager = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the speech provider. + /// + public ISpeechProvider SpeechProvider { get; set; } + private bool _isUpdateAvailable; /// /// Gets or sets a value indicating whether a new version update is available. @@ -228,7 +246,9 @@ namespace Tango.MachineStudio.UI.ViewModels IStudioApplicationManager applicationManager, INavigationManager navigationManager, IEventLogger eventLogger, - IDiagnosticsFrameProvider frameProvider) : base(view) + IDiagnosticsFrameProvider frameProvider, + ISpeechProvider speechProvider, + IHtmlPresenter htmlPresenter) : base(view) { _eventLogger = eventLogger; _navigation = navigationManager; @@ -237,6 +257,8 @@ namespace Tango.MachineStudio.UI.ViewModels NotificationProvider = notificationProvider; ApplicationManager = applicationManager; DiagnosticsFrameProvider = frameProvider; + SpeechProvider = speechProvider; + _htmlPresenter = htmlPresenter; StartModuleCommand = new RelayCommand(StartModule); @@ -263,6 +285,10 @@ namespace Tango.MachineStudio.UI.ViewModels machine.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved; } }; + + ToggleSpeechCommand = new RelayCommand(() => { SpeechProvider.Mute = !SpeechProvider.Mute; }); + + ResolveMachineEventCommand = new RelayCommand(ResolveMachineEvent); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable e) @@ -542,5 +568,17 @@ namespace Tango.MachineStudio.UI.ViewModels { _applicationManager.ShutDown(); } + + /// + /// Displays the HTML. + /// + /// The HTML page. + private void ResolveMachineEvent(MachinesEvent machineEvent) + { + if (_htmlPresenter.DisplayHtml(machineEvent.EventType.HtmlPage)) + { + //Send resolved to embedded ! + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index b7a4cc93f..3301fd9f3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -172,6 +172,24 @@ + +