diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
15 files changed, 466 insertions, 63 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."); } } 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}"> + + <UserControl.Resources> + <converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" /> + </UserControl.Resources> + <Grid> <Grid Margin="40"> <DockPanel> @@ -29,13 +35,78 @@ </Grid> <Grid> - <DataGrid Background="Transparent" Margin="0 20 0 0" BorderThickness="1" BorderBrush="Gainsboro"> + <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding JobEvents}" SelectedItem="{Binding SelectedJobEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" IsReadOnly="True"> + <DataGrid.RowStyle> + <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> + <Style.Triggers> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> + <Setter Property="Cursor" Value="Hand"></Setter> + </Trigger> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + <Trigger Property="IsFocused" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </DataGrid.RowStyle> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + <Style.Triggers> + <Trigger Property="IsSelected" Value="True"> + <Setter Property="Background" Value="Transparent"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </DataGrid.CellStyle> <DataGrid.Columns> - <DataGridTextColumn Width="Auto" Header="#"/> - <DataGridTextColumn Width="200" Header="TIME STAMP"/> - <DataGridTextColumn Width="100" Header="CODE"/> - <DataGridTextColumn Width="200" Header="NAME"/> - <DataGridTextColumn Width="1*" Header="DESCRIPTION"/> + <DataGridTemplateColumn Header="#"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <materialDesign:PackIcon Width="16" Height="16"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="Alert"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Info"> + <Setter Property="Kind" Value="Information"></Setter> + <Setter Property="Foreground" Value="DimGray"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="Kind" Value="Alert"></Setter> + <Setter Property="Foreground" Value="#FFA300"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="Kind" Value="AlertOctagon"></Setter> + <Setter Property="Foreground" Value="#FF5C5C"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="Kind" Value="BellPlus"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <DataGridTextColumn Header="DATE TIME" Binding="{Binding DateTime,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter='MM/dd/yyyy HH:mm:ss.fff'}" /> + <DataGridTextColumn Header="GROUP" Binding="{Binding EventType.EventTypesGroup.Name}" /> + <DataGridTextColumn Header="EVENT" Binding="{Binding EventType.Name}" /> + <DataGridTemplateColumn Header="MESSAGE" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <TextBlock Text="{Binding Description}" TextTrimming="CharacterEllipsis"></TextBlock> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> </Grid> 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 Binary files differnew file mode 100644 index 000000000..5a1d74045 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/bip.wav diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav Binary files differnew file mode 100644 index 000000000..4dce7d623 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/error.wav 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 @@ +<Window x:Class="Tango.MachineStudio.UI.Html.HtmlWindow" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="clr-namespace:Tango.MachineStudio.UI.Windows" + mc:Ignorable="d" + Title="Machine Studio" Height="500" Width="800" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" Background="Transparent"> + <Grid> + <Grid> + <Border Background="White" Padding="10" BorderThickness="1" BorderBrush="{StaticResource AccentColorBrush}"> + <Border.Effect> + <DropShadowEffect ShadowDepth="0" BlurRadius="10"></DropShadowEffect> + </Border.Effect> + + <Grid> + <DockPanel Margin="10"> + <Grid DockPanel.Dock="Bottom"> + <Button Margin="10 10 0 0" Width="140" HorizontalAlignment="Right" Click="OKClicked">OK</Button> + </Grid> + <WebBrowser x:Name="webBrowser" + OverridesDefaultStyle="False" + ScrollViewer.CanContentScroll="False" + ScrollViewer.HorizontalScrollBarVisibility="Hidden" + ScrollViewer.VerticalScrollBarVisibility="Hidden"></WebBrowser> + </DockPanel> + + <Button Click="CloseClicked" HorizontalAlignment="Right" VerticalAlignment="Top" Width="20" Height="20" Margin="0 -6 -4 0" Padding="0" Style="{StaticResource MaterialDesignFlatButton}" Foreground="Black"> + <materialDesign:PackIcon Kind="Close" Width="16" Height="16"></materialDesign:PackIcon> + </Button> + </Grid> + </Border> + </Grid> + </Grid> +</Window> 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 +{ + /// <summary> + /// Interaction logic for DialogWindow.xaml + /// </summary> + 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 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </ApplicationDefinition> + <Compile Include="Html\DefaultHtmlPresenter.cs" /> + <Compile Include="Html\HtmlWindow.xaml.cs"> + <DependentUpon>HtmlWindow.xaml</DependentUpon> + </Compile> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> <Compile Include="Notifications\TextInputBoxWindow.xaml.cs"> <DependentUpon>TextInputBoxWindow.xaml</DependentUpon> @@ -199,6 +203,10 @@ <Compile Include="Windows\ModuleWindow.xaml.cs"> <DependentUpon>ModuleWindow.xaml</DependentUpon> </Compile> + <Page Include="Html\HtmlWindow.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> 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<IVideoCaptureProvider>(); SimpleIoc.Default.Unregister<IDiagnosticsFrameProvider>(); SimpleIoc.Default.Unregister<IEventLogger>(); + SimpleIoc.Default.Unregister<ISpeechProvider>(); + SimpleIoc.Default.Unregister<IHtmlPresenter>(); SimpleIoc.Default.Register<INotificationProvider, DefaultNotificationProvider>(); SimpleIoc.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>(); @@ -69,6 +74,8 @@ namespace Tango.MachineStudio.UI SimpleIoc.Default.Register<IVideoCaptureProvider, DefaultVideoCaptureProvider>(); SimpleIoc.Default.Register<IDiagnosticsFrameProvider, DefaultDiagnosticsFrameProvider>(); SimpleIoc.Default.Register<IEventLogger, DefaultEventLogger>(); + SimpleIoc.Default.Register<ISpeechProvider, DefaultSpeechProvider>(); + SimpleIoc.Default.Register<IHtmlPresenter, DefaultHtmlPresenter>(); SimpleIoc.Default.Register<MainViewVM>(); SimpleIoc.Default.Register<LoadingViewVM>(); 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; /// <summary> /// Gets or sets the current loaded module. @@ -129,6 +132,16 @@ namespace Tango.MachineStudio.UI.ViewModels /// </summary> public RelayCommand UpdateCenterCommand { get; set; } + /// <summary> + /// Gets or sets the toggle speech command. + /// </summary> + public RelayCommand ToggleSpeechCommand { get; set; } + + /// <summary> + /// Gets or sets the display HTML command. + /// </summary> + public RelayCommand<MachinesEvent> ResolveMachineEventCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// <summary> /// Gets or sets the authentication provider. @@ -169,6 +182,11 @@ namespace Tango.MachineStudio.UI.ViewModels set { _applicationManager = value; RaisePropertyChangedAuto(); } } + /// <summary> + /// Gets or sets the speech provider. + /// </summary> + public ISpeechProvider SpeechProvider { get; set; } + private bool _isUpdateAvailable; /// <summary> /// 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<IStudioModule>(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<MachinesEvent>(ResolveMachineEvent); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e) @@ -542,5 +568,17 @@ namespace Tango.MachineStudio.UI.ViewModels { _applicationManager.ShutDown(); } + + /// <summary> + /// Displays the HTML. + /// </summary> + /// <param name="machineEvent">The HTML page.</param> + 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 @@ </StackPanel> </Button> <Separator/> + <Button Command="{Binding ToggleSpeechCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Width="24" Height="24"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="VolumeHigh"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding SpeechProvider.Mute}" Value="True"> + <Setter Property="Kind" Value="VolumeOff"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Speech</TextBlock> + </StackPanel> + </Button> + <Separator/> <Button Command="{Binding ExitCommand}"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon Kind="CloseCircleOutline" Width="24" Height="24" /> @@ -437,37 +455,59 @@ <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type entities:MachinesEvent}"> <Border BorderThickness="0 0 0 1" BorderBrush="#E1E1E1" Padding="5"> - <StackPanel> - <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Width="24" Height="24"> - <materialDesign:PackIcon.Style> - <Style TargetType="materialDesign:PackIcon"> - <Setter Property="Kind" Value="AlertCircle"></Setter> - <Setter Property="Foreground" Value="#464646"></Setter> + <DockPanel> + <Grid DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center"> + <ContentControl> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Content" Value="{x:Null}"></Setter> <Style.Triggers> - <DataTrigger Binding="{Binding Category}" Value="Warning"> - <Setter Property="Kind" Value="Alert"></Setter> - <Setter Property="Foreground" Value="#FFA300"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Error"> - <Setter Property="Kind" Value="AlertOctagon"></Setter> - <Setter Property="Foreground" Value="#FF5C5C"></Setter> - </DataTrigger> - <DataTrigger Binding="{Binding Category}" Value="Critical"> - <Setter Property="Kind" Value="BellPlus"></Setter> - <Setter Property="Foreground" Value="Red"></Setter> + <DataTrigger Binding="{Binding EventType.HtmlPage,Converter={StaticResource NullObjectToBooleanConverter}}" Value="True"> + <Setter Property="Content"> + <Setter.Value> + <Button Style="{StaticResource emptyButton}" Cursor="Hand" Margin="5" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.ResolveMachineEventCommand}" CommandParameter="{Binding}"> + <materialDesign:PackIcon Kind="TelevisionGuide" Width="24" Height="24" /> + </Button> + </Setter.Value> + </Setter> </DataTrigger> </Style.Triggers> </Style> - </materialDesign:PackIcon.Style> - </materialDesign:PackIcon> + </ContentControl.Style> + </ContentControl> + </Grid> + <StackPanel> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Width="24" Height="24"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Kind" Value="AlertCircle"></Setter> + <Setter Property="Foreground" Value="#464646"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding Category}" Value="Warning"> + <Setter Property="Kind" Value="Alert"></Setter> + <Setter Property="Foreground" Value="#FFA300"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Error"> + <Setter Property="Kind" Value="AlertOctagon"></Setter> + <Setter Property="Foreground" Value="#FF5C5C"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding Category}" Value="Critical"> + <Setter Property="Kind" Value="BellPlus"></Setter> + <Setter Property="Foreground" Value="Red"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> - <StackPanel Margin="10 0 0 0" VerticalAlignment="Top"> - <TextBlock Text="{Binding EventType.Name}"></TextBlock> - <TextBlock Margin="0 5 0 0" Text="{Binding Description}" FontSize="10" Foreground="DimGray" TextWrapping="Wrap"></TextBlock> + <StackPanel Margin="10 0 0 0" VerticalAlignment="Top"> + <TextBlock Text="{Binding EventType.Name}"></TextBlock> + <TextBlock Margin="0 5 0 0" Text="{Binding Description}" FontSize="10" Foreground="DimGray" TextWrapping="Wrap"></TextBlock> + </StackPanel> </StackPanel> </StackPanel> - </StackPanel> + </DockPanel> </Border> </DataTemplate> </ItemsControl.ItemTemplate> |
