diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-27 15:31:21 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-11-27 15:31:21 +0200 |
| commit | e0167674d812f90896b982fa236dc2634eb79bcb (patch) | |
| tree | 99be93e441c7fe09a199a7390f1b24c41eb95860 /Software/Visual_Studio/PPC/Modules | |
| parent | e2f911073fbf4ca14a2cd9e1c04592888ad9de1a (diff) | |
| download | Tango-e0167674d812f90896b982fa236dc2634eb79bcb.tar.gz Tango-e0167674d812f90896b982fa236dc2634eb79bcb.zip | |
Working on PPC Events module.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
7 files changed, 284 insertions, 62 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml new file mode 100644 index 000000000..d0f24c5bb --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml @@ -0,0 +1,76 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.Events.Resources"> + + <!--Jobs Grid--> + <Style x:Key="TangoEventsGrid" TargetType="{x:Type touch:LightTouchDataGrid}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGrid}}"> + <Style.Resources> + + <Style TargetType="{x:Type touch:LightTouchDataGridHeaderRow}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGridHeaderRow}}"> + <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Setter Property="BorderThickness" Value="1"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoLowAccentBrush}"></Setter> + <Setter Property="Height" Value="68"></Setter> + <Setter Property="Margin" Value="5 0 5 5"></Setter> + <Setter Property="CornerRadius" Value="5"></Setter> + <Setter Property="Effect"> + <Setter.Value> + <DropShadowEffect BlurRadius="5" ShadowDepth="1" Color="Silver" /> + </Setter.Value> + </Setter> + </Style> + + <Style TargetType="{x:Type touch:LightTouchDataGridRow}"> + <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoDarkForegroundBrush}"></Setter> + <Setter Property="BorderThickness" Value="1"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource TangoLightBorderBrush}"></Setter> + <Setter Property="Padding" Value="5"></Setter> + <Setter Property="CornerRadius" Value="5"></Setter> + <Setter Property="Margin" Value="5 4"></Setter> + <Setter Property="Height" Value="Auto"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type touch:LightTouchDataGridRow}"> + <Border DockPanel.Dock="Top" Background="{TemplateBinding Background}" + BorderBrush="{TemplateBinding BorderBrush}" + BorderThickness="{TemplateBinding BorderThickness}" + CornerRadius="{TemplateBinding CornerRadius}" + Padding="{TemplateBinding Padding}"> + + <DockPanel> + <ContentPresenter Height="78" DockPanel.Dock="Top" Content="{TemplateBinding Content}" /> + + <Grid Height="300" Margin="10" Visibility="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridRow},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}"> + + </Grid> + </DockPanel> + </Border> + </ControlTemplate> + </Setter.Value> + </Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True"> + <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter> + <DataTrigger.EnterActions> + <BeginStoryboard> + <Storyboard> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:00" /> + <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="00:00:00" /> + </Storyboard> + </BeginStoryboard> + </DataTrigger.EnterActions> + </DataTrigger> + </Style.Triggers> + </Style> + + <Style TargetType="{x:Type touch:LightTouchDataGridCell}" BasedOn="{StaticResource {x:Type touch:LightTouchDataGridCell}}"> + + </Style> + </Style.Resources> + </Style> + <!--Jobs Grid--> + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj index 02929e18e..09347c02e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj @@ -69,6 +69,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Resources\Styles.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\MainView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -144,7 +148,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs index 38784b790..326c78787 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs @@ -1,24 +1,114 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.PPC.Common; +using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.Notifications.NotificationItems; namespace Tango.PPC.Events.ViewModels { /// <summary> - /// Represents the main view VM and entry point for <see cref="Synchronization.MyModule"/>. + /// Represents the main view VM and entry point for <see cref="Events.EventsModule"/>. /// </summary> /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class MainViewVM : PPCViewModel { + private Dictionary<EventTypes, NotificationItem> _notifications; + + private ObservableCollection<MachinesEvent> _currentEvents; + /// <summary> + /// Gets or sets the current events. + /// </summary> + public ObservableCollection<MachinesEvent> CurrentEvents + { + get { return _currentEvents; } + set { _currentEvents = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="MainViewVM"/> class. + /// </summary> + public MainViewVM() + { + CurrentEvents = new ObservableCollection<MachinesEvent>(); + _notifications = new Dictionary<EventTypes, NotificationItem>(); + } + /// <summary> /// Called when the application has been started /// </summary> public override void OnApplicationStarted() { - //Start initializing here rather then in the constructor. + EventLogger.EventReceived += EventLogger_EventReceived; + EventLogger.EventResolved += EventLogger_EventResolved; + } + + private void EventLogger_EventReceived(object sender, MachinesEvent ev) + { + InvokeUI(() => + { + if (ev.Group != EventTypesGroups.Transport) + { + CurrentEvents.Insert(0, ev); + + if (ev.Group != EventTypesGroups.Application && ev.Group != EventTypesGroups.Transport) + { + var notificationItem = new MessageNotificationItem(); + notificationItem.CanClose = false; + notificationItem.Message = ev.EventType.Description; + notificationItem.ExpandedMessage = ev.Description; + notificationItem.Pressed += (_, __) => + { + NotificationProvider.ShowInfo($"{ev.EventType.Description} Selected !"); + }; + + switch (ev.Category) + { + case EventTypesCategories.Info: + notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Info; + break; + case EventTypesCategories.Warning: + notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Warning; + break; + case EventTypesCategories.Error: + notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error; + break; + case EventTypesCategories.Critical: + notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error; + break; + } + + NotificationProvider.PushNotification(notificationItem); + _notifications.Add(ev.EventType.Type, notificationItem); + } + } + }); + } + + private void EventLogger_EventResolved(object sender, MachinesEvent ev) + { + InvokeUI(() => + { + if (ev.Group != EventTypesGroups.Transport) + { + CurrentEvents.Remove(ev); + + if (ev.Group != EventTypesGroups.Application && ev.Group != EventTypesGroups.Transport) + { + if (_notifications.ContainsKey(ev.EventType.Type)) + { + var notification = _notifications[ev.EventType.Type]; + _notifications.Remove(ev.EventType.Type); + NotificationProvider.PopNotification(notification); + } + } + } + }); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml index b5666d367..7351be38b 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml @@ -5,10 +5,107 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.Events.ViewModels" xmlns:global="clr-namespace:Tango.PPC.Events" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.Events.Views" mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - <Grid Background="{StaticResource TangoPrimaryBackgroundBrush}"> - <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">EVENTS</TextBlock> + + <UserControl.Resources> + + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Styles.xaml" /> + </ResourceDictionary.MergedDictionaries> + </ResourceDictionary> + </UserControl.Resources> + + <Grid Background="{StaticResource TangoMidBackgroundBrush}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <Border Padding="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}"> + <Border.Effect> + <DropShadowEffect Color="Silver" ShadowDepth="0" BlurRadius="20" Opacity="1" /> + </Border.Effect> + <TextBlock VerticalAlignment="Center" FontSize="{StaticResource TangoHeaderFontSize}" FontWeight="SemiBold">Events</TextBlock> + </Border> + + <Grid Grid.Row="1"> + <touch:LightTouchDataGrid SelectionChanged="dataGridEvent_SelectionChanged" RenderOptions.EdgeMode="Unspecified" SelectionMode="Single" EnableDragAndDrop="False" Style="{StaticResource TangoEventsGrid}" x:Name="dataGridEvent" SelectedItems="{Binding SelectedEvents}" ItemsSource="{Binding CurrentEvents}" ItemSelectedCommand="{Binding EventSelectedCommand}" Margin="10"> + <touch:LightTouchDataGrid.Columns> + <touch:LightTouchDataGridColumn Width="120" Header="Severity" HorizontalContentAlignment="Center" SortMember="Category"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <touch:TouchIcon Width="32" Height="32" IsHitTestVisible="False"> + <touch:TouchIcon.Style> + <Style TargetType="touch:TouchIcon"> + <Setter Property="Icon" Value="CheckCircleOutline"/> + <Setter Property="Foreground" Value="{StaticResource TangoSuccessBrush}"/> + <Style.Triggers> + <DataTrigger Binding="{Binding Category,Mode=OneWay}" Value="Warning"> + <Setter Property="Icon" Value="AlertCircleOutline"/> + <Setter Property="Foreground" Value="{StaticResource TangoWarningBrush}"/> + </DataTrigger> + <DataTrigger Binding="{Binding Category,Mode=OneWay}" Value="Error"> + <Setter Property="Icon" Value="AlertCircleOutline"/> + <Setter Property="Foreground" Value="{StaticResource TangoErrorBrush}"/> + </DataTrigger> + <DataTrigger Binding="{Binding Category,Mode=OneWay}" Value="Critical"> + <Setter Property="Icon" Value="Alert"/> + <Setter Property="Foreground" Value="{StaticResource TangoErrorBrush}"/> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchIcon.Style> + </touch:TouchIcon> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="1*" Header="Title" SortMember="Name" HorizontalContentAlignment="Left"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding Name,Mode=OneWay}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="100" Header="# Error Code." SortMember="Code" HorizontalContentAlignment="Center"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False"> + <Run>#</Run><Run Text="{Binding Code,Mode=OneWay}"></Run> + </TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="200" Header="Date & Time" SortMember="DateTime"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <TextBlock IsHitTestVisible="False" Text="{Binding DateTime,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter=g}"></TextBlock> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + <touch:LightTouchDataGridColumn Width="50" HorizontalContentAlignment="Center"> + <touch:LightTouchDataGridColumn.CellTemplate> + <DataTemplate> + <touch:TouchIcon Width="24" Height="24"> + <touch:TouchIcon.Style> + <Style TargetType="touch:TouchIcon"> + <Setter Property="Icon" Value="ChevronRight"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridRow},Path=IsSelected}" Value="True"> + <Setter Property="Icon" Value="ChevronDown"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchIcon.Style> + </touch:TouchIcon> + </DataTemplate> + </touch:LightTouchDataGridColumn.CellTemplate> + </touch:LightTouchDataGridColumn> + </touch:LightTouchDataGrid.Columns> + </touch:LightTouchDataGrid> + </Grid> </Grid> </UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml.cs index 6a8fe6b5a..26caab36e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml.cs @@ -24,5 +24,16 @@ namespace Tango.PPC.Events.Views { InitializeComponent(); } + + private void dataGridEvent_SelectionChanged(object sender, EventArgs e) + { + Task.Delay(100).ContinueWith((x) => + { + this.BeginInvoke(() => + { + dataGridEvent.LayoutRows(false); + }); + }); + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs index af2e44615..5b4a3e403 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs @@ -20,13 +20,6 @@ namespace Tango.PPC.Jobs.ViewModels /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> public class MainViewVM : PPCViewModel { - private Dictionary<EventTypes, NotificationItem> _notifications; - - public MainViewVM() : base() - { - _notifications = new Dictionary<EventTypes, NotificationItem>(); - } - /// <summary> /// Called when the application has been started. /// </summary> @@ -34,8 +27,6 @@ namespace Tango.PPC.Jobs.ViewModels { MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; - MachineProvider.MachineOperator.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents; - MachineProvider.MachineOperator.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved; } /// <summary> @@ -88,52 +79,5 @@ namespace Tango.PPC.Jobs.ViewModels })); } } - - private void MachineEventsStateProvider_NewEvents(object sender, IEnumerable<MachinesEvent> events) - { - foreach (var item in events) - { - var notificationItem = new MessageNotificationItem(); - notificationItem.CanClose = false; - notificationItem.Message = item.EventType.Description; - notificationItem.ExpandedMessage = item.Description; - notificationItem.Pressed += (_, __) => - { - NotificationProvider.ShowInfo($"{item.EventType.Description} Selected !"); - }; - - switch (item.Category) - { - case EventTypesCategories.Info: - notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Info; - break; - case EventTypesCategories.Warning: - notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Warning; - break; - case EventTypesCategories.Error: - notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error; - break; - case EventTypesCategories.Critical: - notificationItem.MessageType = MessageNotificationItem.MessageNotificationItemTypes.Error; - break; - } - - NotificationProvider.PushNotification(notificationItem); - _notifications.Add(item.EventType.Type, notificationItem); - } - } - - private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> events) - { - foreach (var item in events) - { - if (_notifications.ContainsKey(item.EventType.Type)) - { - var notification = _notifications[item.EventType.Type]; - _notifications.Remove(item.EventType.Type); - NotificationProvider.PopNotification(notification); - } - } - } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml index 840149c98..3b098f557 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Storage/Views/MainView.xaml @@ -15,7 +15,7 @@ <Grid Margin="10"> <DockPanel> - <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile,TargetNullValue=Visibility.Collapsed,FallbackValue=Visibility.Collapsed}"> + <Grid DockPanel.Dock="Top" Visibility="{Binding Request.Intent,Converter={StaticResource EnumToVisibilityConverter},ConverterParameter=SaveFile}"> <Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" Padding="20"> <StackPanel> <TextBlock Text="{Binding Request.Title}" FontSize="{StaticResource TangoHeaderFontSize}"></TextBlock> |
