aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-27 16:34:43 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-27 16:34:43 +0200
commita90c38d0e29cc3332affbfb3c0500b008f451334 (patch)
treef084c21cc069504cacd9a134f0c3c8b4b1727416 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Events
parente0167674d812f90896b982fa236dc2634eb79bcb (diff)
downloadTango-a90c38d0e29cc3332affbfb3c0500b008f451334.tar.gz
Tango-a90c38d0e29cc3332affbfb3c0500b008f451334.zip
Added event content and routing.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Events')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs46
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml12
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml.cs28
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/event_demo.pngbin0 -> 54581 bytes
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml18
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj11
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs25
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml.cs7
9 files changed, 144 insertions, 5 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs
new file mode 100644
index 000000000..b0d00bf9f
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+using Tango.BL.Entities;
+
+namespace Tango.PPC.Events.Converters
+{
+ public class MachineEventToViewConverter : IValueConverter
+ {
+ private static List<FrameworkElement> _views = new List<FrameworkElement>();
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ MachinesEvent ev = value as MachinesEvent;
+
+ if (ev != null)
+ {
+ FrameworkElement view = _views.SingleOrDefault(x => x.GetType() == typeof(EventsViews.GeneralView));
+
+ if (view != null)
+ {
+ return view;
+ }
+ else
+ {
+ view = Activator.CreateInstance<EventsViews.GeneralView>();
+ return view;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml
new file mode 100644
index 000000000..edec8cb55
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml
@@ -0,0 +1,12 @@
+<UserControl x:Class="Tango.PPC.Events.EventsViews.GeneralView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ 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:local="clr-namespace:Tango.PPC.Events.EventsViews"
+ mc:Ignorable="d"
+ d:DesignHeight="450" d:DesignWidth="800">
+ <Grid>
+ <Image Source="../Images/event_demo.png" RenderOptions.BitmapScalingMode="Fant" />
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml.cs
new file mode 100644
index 000000000..50a28f21c
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/GeneralView.xaml.cs
@@ -0,0 +1,28 @@
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.PPC.Events.EventsViews
+{
+ /// <summary>
+ /// Interaction logic for GeneralView.xaml
+ /// </summary>
+ public partial class GeneralView : UserControl
+ {
+ public GeneralView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/event_demo.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/event_demo.png
new file mode 100644
index 000000000..c30fb3ec9
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Images/event_demo.png
Binary files differ
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
index d0f24c5bb..468ba228d 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Resources/Styles.xaml
@@ -1,12 +1,15 @@
<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:converters="clr-namespace:Tango.PPC.Events.Converters"
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>
+ <converters:MachineEventToViewConverter x:Key="MachineEventToViewConverter" />
+
<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>
@@ -43,8 +46,19 @@
<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 Margin="10" Visibility="{Binding RelativeSource={RelativeSource AncestorType=touch:LightTouchDataGridRow},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <ContentControl>
+ <ContentControl.Style>
+ <Style TargetType="ContentControl">
+ <Setter Property="Content" Value="{x:Null}"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=Visibility}" Value="Visible">
+ <Setter Property="Content" Value="{Binding Converter={StaticResource MachineEventToViewConverter}}"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ContentControl.Style>
+ </ContentControl>
</Grid>
</DockPanel>
</Border>
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 09347c02e..6ef477f5d 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="EventsViews\GeneralView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Resources\Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -82,7 +86,11 @@
<Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs">
<Link>GlobalVersionInfo.cs</Link>
</Compile>
+ <Compile Include="Converters\MachineEventToViewConverter.cs" />
<Compile Include="EventsModule.cs" />
+ <Compile Include="EventsViews\GeneralView.xaml.cs">
+ <DependentUpon>GeneralView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@@ -145,6 +153,9 @@
<ItemGroup>
<Resource Include="Images\events-module.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\event_demo.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
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 326c78787..2b4a5a75b 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
@@ -30,6 +30,14 @@ namespace Tango.PPC.Events.ViewModels
set { _currentEvents = value; RaisePropertyChangedAuto(); }
}
+ private MachinesEvent _selectedEvent;
+ public MachinesEvent SelectedEvent
+ {
+ get { return _selectedEvent; }
+ set { _selectedEvent = value; RaisePropertyChangedAuto(); }
+ }
+
+
/// <summary>
/// Initializes a new instance of the <see cref="MainViewVM"/> class.
/// </summary>
@@ -62,9 +70,10 @@ namespace Tango.PPC.Events.ViewModels
notificationItem.CanClose = false;
notificationItem.Message = ev.EventType.Description;
notificationItem.ExpandedMessage = ev.Description;
- notificationItem.Pressed += (_, __) =>
+ notificationItem.Pressed += async (_, __) =>
{
- NotificationProvider.ShowInfo($"{ev.EventType.Description} Selected !");
+ SelectedEvent = ev;
+ await NavigationManager.NavigateTo<EventsModule>();
};
switch (ev.Category)
@@ -110,5 +119,17 @@ namespace Tango.PPC.Events.ViewModels
}
});
}
+
+ public override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+ NotificationProvider.NotificationsVisible = false;
+ }
+
+ public override void OnNavigatedFrom()
+ {
+ base.OnNavigatedFrom();
+ NotificationProvider.NotificationsVisible = true;
+ }
}
}
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 7351be38b..2a48d71d6 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
@@ -33,7 +33,7 @@
</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 SelectionChanged="dataGridEvent_SelectionChanged" RenderOptions.EdgeMode="Unspecified" SelectionMode="Single" EnableDragAndDrop="False" Style="{StaticResource TangoEventsGrid}" x:Name="dataGridEvent" ItemsSource="{Binding CurrentEvents}" SelectedItem="{Binding SelectedEvent,Mode=TwoWay}" ItemSelectedCommand="{Binding EventSelectedCommand}" Margin="10">
<touch:LightTouchDataGrid.Columns>
<touch:LightTouchDataGridColumn Width="120" Header="Severity" HorizontalContentAlignment="Center" SortMember="Category">
<touch:LightTouchDataGridColumn.CellTemplate>
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 26caab36e..248b1eecb 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
@@ -32,6 +32,13 @@ namespace Tango.PPC.Events.Views
this.BeginInvoke(() =>
{
dataGridEvent.LayoutRows(false);
+
+ var selected_row = dataGridEvent.GetRows().FirstOrDefault(y => y.IsSelected);
+
+ if (selected_row != null)
+ {
+ dataGridEvent.ScrollViewer.ScrollToElement(selected_row);
+ }
});
});
}