diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-15 20:04:52 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-15 20:04:52 +0200 |
| commit | 2836f1031bf9c1414a80620e040c1414a45c1648 (patch) | |
| tree | 5b615d1da2023aaab6aa914cabfcbe0f4e897df8 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI | |
| parent | 74438bb2f5d3ad782dec27a8f00838175ae67f8c (diff) | |
| download | Tango-2836f1031bf9c1414a80620e040c1414a45c1648.tar.gz Tango-2836f1031bf9c1414a80620e040c1414a45c1648.zip | |
Working on machine events !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI')
5 files changed, 101 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/error-message.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/error-message.png Binary files differnew file mode 100644 index 000000000..c7c719b8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/error-message.png diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/exception.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/exception.png Binary files differindex 9a4abb703..7b941818c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/exception.png +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/exception.png 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 6a879e965..95c2a9925 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 @@ -421,6 +421,9 @@ <ItemGroup> <Resource Include="Images\new-version.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\error-message.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>if $(ConfigurationName) == Debug $(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Machine Studio.lnk" 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 ba94cd860..b3c6236f8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using Tango.BL.Entities; using Tango.Core.Commands; using Tango.Integration.Services; using Tango.Logging; @@ -75,6 +76,16 @@ namespace Tango.MachineStudio.UI.ViewModels set { _isMenuOpened = value; RaisePropertyChangedAuto(); } } + private bool _isMachineErrorsOpened; + /// <summary> + /// Gets or sets a value indicating whether to display the machine errors. + /// </summary> + public bool IsMachineErrorsOpened + { + get { return _isMachineErrorsOpened; } + set { _isMachineErrorsOpened = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Gets or sets the start module command. /// </summary> @@ -225,6 +236,31 @@ namespace Tango.MachineStudio.UI.ViewModels _updateCheckThread = new Thread(UpdateCheckThreadMethod); _updateCheckThread.IsBackground = true; _updateCheckThread.Start(); + + ApplicationManager.ConnectedMachineChanged += (sender, machine) => + { + if (machine != null) + { + machine.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents; + machine.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents; + + machine.MachineEventsStateProvider.EventsResolved -= MachineEventsStateProvider_EventsResolved; + machine.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved; + } + }; + } + + private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e) + { + if (ApplicationManager.ConnectedMachine.MachineEventsStateProvider.Events.Count == 0) + { + IsMachineErrorsOpened = false; + } + } + + private void MachineEventsStateProvider_NewEvents(object sender, IEnumerable<MachinesEvent> e) + { + IsMachineErrorsOpened = true; } private void UpdateCheckThreadMethod() @@ -323,7 +359,7 @@ namespace Tango.MachineStudio.UI.ViewModels else { ApplicationManager.ConnectedMachine = x.SelectedMachine; - _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP",x.SelectedMachine.SerialNumber)); + _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber)); } } catch (Exception ex) 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 8e6fa36f5..beade3d88 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -9,6 +9,7 @@ xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:entities="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:db="clr-namespace:Tango.MachineStudio.DB.Views;assembly=Tango.MachineStudio.DB" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" @@ -225,6 +226,17 @@ </StackPanel> </Button> + <ToggleButton Visibility="{Binding ApplicationManager.ConnectedMachine.MachineEventsStateProvider.HasEvents,Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed,TargetNullValue=Collapsed,Mode=OneWay}" IsChecked="{Binding IsMachineErrorsOpened}" Style="{StaticResource emptyToggleButton}" Margin="0 0 10 0" Cursor="Hand"> + <ToggleButton.ToolTip> + <TextBlock> + <Run>Press to view</Run> + <Run Text="{Binding ApplicationManager.ConnectedMachine.MachineEventsStateProvider.Events.Count,Mode=OneWay}"></Run> + <Run>hardware messages</Run> + </TextBlock> + </ToggleButton.ToolTip> + <Image Source="/Images/error-message.png" Width="32" /> + </ToggleButton> + <Button Style="{StaticResource emptyButton}" Cursor="Hand" Command="{Binding UpdateCenterCommand}" Visibility="{Binding IsUpdateAvailable,Converter={StaticResource BooleanToVisibilityConverter}}"> <Button.ToolTip> <TextBlock> @@ -383,6 +395,55 @@ <TextBlock Text="{Binding NotificationProvider.CurrentTaskItem.Message,Converter={StaticResource StringEllipsisConverter},ConverterParameter=35}" Foreground="White" VerticalAlignment="Center" Margin="10 0 0 0" TextWrapping="Wrap"></TextBlock> </StackPanel> </Border> + + <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Visibility="{Binding IsMachineErrorsOpened,Converter={StaticResource BooleanToVisibilityConverter}}"> + <Border Width="350" Background="#ECFFFFFF" BorderBrush="White" CornerRadius="5" Padding="5"> + <Border.Effect> + <DropShadowEffect ShadowDepth="0" BlurRadius="10" /> + </Border.Effect> + + <ItemsControl ItemsSource="{Binding ApplicationManager.ConnectedMachine.MachineEventsStateProvider.Events}"> + <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> + <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> + + <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Text="{Binding EventType.Name}"></TextBlock> + </StackPanel> + </StackPanel> + </Border> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + </Border> + + <Canvas HorizontalAlignment="Center"> + <Polygon Points="12,0 0,35 24,35" Fill="#86FFFFFF" Canvas.Top="-35" Canvas.Left="95"></Polygon> + </Canvas> + </Grid> </Grid> </DockPanel> </materialDesign:DrawerHost> |
