From 33a68a0e46e55e86a4c1f100ea3d7e9180a801a3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 12 Jul 2018 19:07:24 +0300 Subject: Working on PPC & Tango.Integration. --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 405c19eb7..b3a0c5b1a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.DI; +using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; @@ -20,6 +21,8 @@ namespace Tango.PPC.UI.ViewModels /// public class LayoutViewVM : PPCViewModel { + private JobHandler _jobHandler; + /// /// Gets or sets the module loader. /// @@ -66,6 +69,11 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand NotificationsAreaPressedCommand { get; set; } + /// + /// Gets or sets the stop printing command. + /// + public RelayCommand StopPrintingCommand { get; set; } + /// /// Initializes a new instance of the class. /// @@ -75,6 +83,21 @@ namespace Tango.PPC.UI.ViewModels HomeCommand = new RelayCommand(NavigateHome); MenuOrBackCommand = new RelayCommand(OpenMenuOrNavigateBack); NotificationsAreaPressedCommand = new RelayCommand(OpenFirstNotificationOrDisplayAll); + + StopPrintingCommand = new RelayCommand(StopPrinting); + } + + private void StopPrinting() + { + if (_jobHandler != null) + { + _jobHandler.Cancel(); + } + } + + private void MachineOperator_PrintingStarted(object sender, Integration.Operation.JobHandler jobHandler) + { + _jobHandler = jobHandler; } /// @@ -118,6 +141,7 @@ namespace Tango.PPC.UI.ViewModels { base.OnApplicationStarted(); ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; } /// -- cgit v1.3.1 From 64bcf92608faae31b7cd31ac3da5c7d1d7ebcd0b Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 14 Jul 2018 21:27:57 +0300 Subject: Implemented job completed notification item. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../JobCompletedNotificationItem.cs | 20 ++++++ .../JobCompletedNotificationItemView.xaml | 16 +++++ .../JobCompletedNotificationItemView.xaml.cs | 28 ++++++++ .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 11 +++ .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 15 +++- .../Tango.PPC.Common/Notifications/AppBarItem.cs | 65 +---------------- .../Notifications/INotificationProvider.cs | 26 ++----- .../PPC/Tango.PPC.Common/Notifications/ItemBase.cs | 77 +++++++++++++++++++++ .../Notifications/NotificationItem.cs | 52 +------------- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 1 + .../Notifications/DefaultNotificationProvider.cs | 61 +++------------- .../EmptyCartridgesNotification.cs | 34 --------- .../EmptyCartridgesNotificationView.xaml | 15 ---- .../EmptyCartridgesNotificationView.xaml.cs | 28 -------- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 8 --- .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 1 - .../PPC/Tango.PPC.UI/Views/MainView.xaml | 10 +-- 19 files changed, 190 insertions(+), 278 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index f41a7a03a..670011fef 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index e5a22310a..1bcea900a 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs new file mode 100644 index 000000000..5c48dc606 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.Jobs.NotificationItems +{ + public class JobCompletedNotificationItem : NotificationItem + { + public override Type ViewType + { + get + { + return typeof(JobCompletedNotificationItemView); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml new file mode 100644 index 000000000..b96337eff --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml @@ -0,0 +1,16 @@ + + + + + The job has been completed + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs new file mode 100644 index 000000000..b6d9797e5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.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.Jobs.NotificationItems +{ + /// + /// Interaction logic for JobCompletedNotificationItemView.xaml + /// + public partial class JobCompletedNotificationItemView : UserControl + { + public JobCompletedNotificationItemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index aafa028c7..9ff90ca42 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -92,6 +92,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -159,6 +163,10 @@ + + + JobCompletedNotificationItemView.xaml + Code @@ -322,5 +330,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index 9a0d0f8ab..f3d16e899 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -8,6 +8,7 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.AppBarItems; +using Tango.PPC.Jobs.NotificationItems; using Tango.PPC.Jobs.Views; namespace Tango.PPC.Jobs.ViewModels @@ -45,6 +46,18 @@ namespace Tango.PPC.Jobs.ViewModels Job = jobHandler.Job; jobHandler.StatusChanged += JobHandler_StatusChanged; jobHandler.Stopped += JobHandler_Stopped; + jobHandler.Completed += JobHandler_Completed; + } + + private void JobHandler_Completed(object sender, EventArgs e) + { + InvokeUI(() => + { + NotificationProvider.PushNotification().Pressed += (_, __) => + { + NavigationManager.NavigateTo(nameof(JobView)); + }; + }); } public override void OnNavigatedFrom() @@ -53,7 +66,7 @@ namespace Tango.PPC.Jobs.ViewModels if (MachineProvider.MachineOperator.IsPrinting) { - NotificationProvider.PushAppBarItem().Preesed += (_, __) => + NotificationProvider.PushAppBarItem().Pressed += (_, __) => { NotificationProvider.CurrentAppBarItem.Close(); NavigationManager.NavigateTo(nameof(JobProgressView)); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs index e35164cf7..1c47d2a97 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppBarItem.cs @@ -11,71 +11,8 @@ namespace Tango.PPC.Common.Notifications /// /// Represents an AppBar item that can be inserted into the application header. /// - /// - public abstract class AppBarItem : IDisposable + public abstract class AppBarItem : ItemBase { - /// - /// Occurs when the AppBar item has been closed. - /// - public event EventHandler Closed; - /// - /// Occurs when the AppBar item has been pressed. - /// - public event EventHandler Preesed; - - /// - /// Gets or sets the remove action. - /// - internal Action RemoveAction { get; set; } - - /// - /// Gets or sets the AppBar view type. - /// - public abstract Type ViewType { get; } - - /// - /// Gets or sets the close command. - /// - public RelayCommand CloseCommand { get; set; } - - /// - /// Gets or sets the pressed command. - /// - /// Initializes a new instance of the class. - /// - public AppBarItem() - { - CloseCommand = new RelayCommand(Close); - PressedCommand = new RelayCommand(OnPreesed); - } - - /// - /// Called when the AppBar item has been pressed. - /// - protected virtual void OnPreesed() - { - Preesed?.Invoke(this, new EventArgs()); - } - - /// - /// Called after the close command has been raised. - /// - public virtual void Close() - { - RemoveAction?.Invoke(); - Closed?.Invoke(this, new EventArgs()); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - Close(); - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs index 9063cef36..39cf2879f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -87,6 +87,13 @@ namespace Tango.PPC.Common.Notifications /// The item. NotificationItem PushNotification(NotificationItem item); + /// + /// Pushes the notification. + /// + /// + /// + NotificationItem PushNotification() where T : NotificationItem; + /// /// Displays the specified dialog in a modal design. /// @@ -114,31 +121,12 @@ namespace Tango.PPC.Common.Notifications /// Task ShowDialog() where VM : DialogViewVM; - /// - /// Inserts the notification item to the bottom of the notifications collection. - /// - /// The item. - /// A condition which determines if this item is still relevant. - /// Determines whether to perform automatic checking of the condition. - /// Determines how frequently the condition function will be invoked. (Default 1 second) - NotificationItem PushNotification(NotificationItem item, Func condition, bool autoCheck = true, TimeSpan? checkInterval = null); - /// /// Removed the specified notification item. /// /// The item. void PopNotification(NotificationItem item); - /// - /// Invokes the notification items conditions. - /// - void InvokeNotificationItemsConditions(); - - /// - /// Gets the pop notification command. - /// - RelayCommand PopNotificationCommand { get; } - /// /// Gets a value indicating whether this instance is in global busy state. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs new file mode 100644 index 000000000..12369948b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/ItemBase.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; + +namespace Tango.PPC.Common.Notifications +{ + public abstract class ItemBase : ExtendedObject, IDisposable + { + /// + /// Occurs when the item has been closed. + /// + public event EventHandler Closed; + + /// + /// Occurs when the item has been pressed. + /// + public event EventHandler Pressed; + + /// + /// Gets or sets the remove action. + /// + internal Action RemoveAction { get; set; } + + /// + /// Gets or sets the view type. + /// + public abstract Type ViewType { get; } + + /// + /// Gets or sets the close command. + /// + public RelayCommand CloseCommand { get; set; } + + /// + /// Gets or sets the pressed command. + /// + /// Initializes a new instance of the class. + /// + public ItemBase() + { + CloseCommand = new RelayCommand(Close); + PressedCommand = new RelayCommand(OnPreesed); + } + + /// + /// Called when the item has been pressed. + /// + protected virtual void OnPreesed() + { + Pressed?.Invoke(this, new EventArgs()); + } + + /// + /// Called after the close command has been raised. + /// + public virtual void Close() + { + RemoveAction?.Invoke(); + Closed?.Invoke(this, new EventArgs()); + } + + /// + /// Disposes the item. + /// + public void Dispose() + { + Close(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs index f5e319fa0..e1832090e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs @@ -12,58 +12,8 @@ namespace Tango.PPC.Common.Notifications /// /// Represents a base notification item. /// - /// - public abstract class NotificationItem : ExtendedObject, IDisposable + public abstract class NotificationItem : ItemBase { - /// - /// Gets or sets the condition. - /// - internal Func Condition { get; set; } - /// - /// Gets or sets a value indicating whether [automatic check]. - /// - internal bool AutoCheck { get; set; } - - /// - /// Gets or sets the automatic check interval. - /// - internal TimeSpan AutoCheckInterval { get; set; } - - /// - /// Gets or sets the remove action. - /// - internal Action RemoveAction { get; set; } - - /// - /// Gets or sets the check timer. - /// - internal Timer Timer { get; set; } - - private String _message; - /// - /// Gets or sets the notification message. - /// - public String Message - { - get { return _message; } - set { _message = value; RaisePropertyChangedAuto(); } - } - - /// - /// Gets or sets the type of the view associated with this notification item. - /// - public abstract Type ViewType { get; } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - if (RemoveAction != null) - { - RemoveAction(); - } - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index e48da8140..15f5d98c5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -108,6 +108,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index 647fc1ef1..0ff9982ee 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -212,43 +212,20 @@ namespace Tango.PPC.UI.Notifications /// public NotificationItem PushNotification(NotificationItem item) { - return PushNotification(item, null, false, null); + item.RemoveAction = () => { PopNotification(item); }; + NotificationItems.Insert(0, item); + RaisePropertyChanged(nameof(HasNotificationItems)); + return item; } /// - /// Inserts the notification item to the bottom of the notifications collection. + /// Pushes the notification. /// - /// The item. - /// A condition which determines if this item is still relevant. - /// Determines whether to perform automatic checking of the condition. - /// Determines how frequently the condition function will be invoked. (Default 1 second) + /// /// - public NotificationItem PushNotification(NotificationItem item, Func condition, bool autoCheck = true, TimeSpan? checkInterval = default(TimeSpan?)) + public NotificationItem PushNotification() where T : NotificationItem { - item.Condition = condition; - item.AutoCheck = autoCheck; - item.AutoCheckInterval = checkInterval != null ? checkInterval.Value : TimeSpan.FromSeconds(1); - item.RemoveAction = () => { PopNotification(item); }; - NotificationItems.Insert(0, item); - - if (autoCheck && condition != null) - { - Timer timer = new Timer(); - item.Timer = timer; - timer.Interval = item.AutoCheckInterval.TotalMilliseconds; - timer.Elapsed += (x, y) => - { - if (!item.Condition()) - { - PopNotification(item); - } - }; - timer.Start(); - } - - RaisePropertyChanged(nameof(HasNotificationItems)); - - return item; + return PushNotification(Activator.CreateInstance()); } /// @@ -257,32 +234,10 @@ namespace Tango.PPC.UI.Notifications /// The item. public void PopNotification(NotificationItem item) { - if (item.Timer != null) - { - item.Timer.Stop(); - } - NotificationItems.Remove(item); - RaisePropertyChanged(nameof(HasNotificationItems)); } - /// - /// Invokes the notification items conditions. - /// - public void InvokeNotificationItemsConditions() - { - var list = NotificationItems.ToList(); - - foreach (var item in list.Where(x => x.Condition != null)) - { - if (!item.Condition()) - { - PopNotification(item); - } - } - } - /// /// Gets a value indicating whether this instance has notification items. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs deleted file mode 100644 index 49a0c03eb..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotification.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using Tango.BL.Enumerations; -using Tango.PPC.Common.Notifications; - -namespace Tango.PPC.UI.Notifications.NotificationItems -{ - public class EmptyCartridgesNotification : NotificationItem - { - public List LiquidTypes { get; set; } - - public EmptyCartridgesNotification() - { - Message = "Cartridges are empty, please replace cartridges"; - } - - public EmptyCartridgesNotification(IEnumerable liquidTypes) : this() - { - LiquidTypes = liquidTypes.ToList(); - } - - public override Type ViewType - { - get - { - return typeof(EmptyCartridgesNotificationView); - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml deleted file mode 100644 index ccb6618e7..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs deleted file mode 100644 index 5fab4ab44..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.UI.Notifications.NotificationItems -{ - /// - /// Interaction logic for EmptyCartridgesNotification.xaml - /// - public partial class EmptyCartridgesNotificationView : UserControl - { - public EmptyCartridgesNotificationView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 2e344bdc9..dc3745bef 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -121,10 +121,6 @@ - - - EmptyCartridgesNotificationView.xaml - @@ -161,10 +157,6 @@ MainWindow.xaml Code - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index b3a0c5b1a..11bef4827 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -9,7 +9,6 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; -using Tango.PPC.UI.Notifications.NotificationItems; using Tango.PPC.UI.ViewsContracts; using Tango.SharedUI; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index dcb19dbee..f333ea2e8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -27,10 +27,12 @@ CurrentDialog="{Binding NotificationProvider.CurrentDialog}"> - - - - + + + + + + -- cgit v1.3.1 From cc425e019d3a7d3494ac15ffe213b6b47b1c64ed Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 15 Jul 2018 01:04:34 +0300 Subject: Working on PPC. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../JobCompletedNotificationItem.cs | 20 ------ .../JobCompletedNotificationItemView.xaml | 16 ----- .../JobCompletedNotificationItemView.xaml.cs | 28 -------- .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 8 --- .../Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs | 23 ++----- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 23 ++++--- .../Tango.PPC.Jobs/ViewModels/MainViewVM.cs | 15 ++++- .../Navigation/INavigationManager.cs | 14 +++- .../Navigation/INavigationObjectReceiver.cs | 13 ++++ .../Notifications/NotificationItem.cs | 6 +- .../NotificationItems/MessageNotificationItem.cs | 61 +++++++++++++++++ .../MessageNotificationItemView.xaml | 55 ++++++++++++++++ .../MessageNotificationItemView.xaml.cs | 28 ++++++++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 10 +++ .../Threading/IDispatcherProvider.cs | 14 ++++ .../Navigation/DefaultNavigationManager.cs | 72 +++++++++++++++++---- .../Notifications/DefaultNotificationProvider.cs | 2 + .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 1 + .../Threading/DefaultDispetcherProvider.cs | 30 +++++++++ .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 4 ++ .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 10 +-- .../Operation/IMachineOperator.cs | 8 +-- .../Tango.Integration/Operation/MachineOperator.cs | 18 +++--- .../Operation/PrintingEventArgs.cs | 21 ++++++ .../Operation/PrintingFailedEventArgs.cs | 19 ++++++ .../Tango.Integration/Tango.Integration.csproj | 2 + .../Tango.Touch/Resources/Colors.xaml | 5 ++ 29 files changed, 390 insertions(+), 136 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationObjectReceiver.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItem.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Threading/IDispatcherProvider.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Threading/DefaultDispetcherProvider.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/PrintingFailedEventArgs.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 670011fef..ed4d61e76 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 1bcea900a..90c771cf6 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs deleted file mode 100644 index 5c48dc606..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItem.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PPC.Common.Notifications; - -namespace Tango.PPC.Jobs.NotificationItems -{ - public class JobCompletedNotificationItem : NotificationItem - { - public override Type ViewType - { - get - { - return typeof(JobCompletedNotificationItemView); - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml deleted file mode 100644 index b96337eff..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - The job has been completed - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs deleted file mode 100644 index b6d9797e5..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.Jobs.NotificationItems -{ - /// - /// Interaction logic for JobCompletedNotificationItemView.xaml - /// - public partial class JobCompletedNotificationItemView : UserControl - { - public JobCompletedNotificationItemView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 9ff90ca42..f457600be 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -92,10 +92,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -163,10 +159,6 @@ - - - JobCompletedNotificationItemView.xaml - Code diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs index f3d16e899..fa5f26c70 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs @@ -8,7 +8,6 @@ using Tango.Integration.Operation; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; using Tango.PPC.Jobs.AppBarItems; -using Tango.PPC.Jobs.NotificationItems; using Tango.PPC.Jobs.Views; namespace Tango.PPC.Jobs.ViewModels @@ -38,26 +37,14 @@ namespace Tango.PPC.Jobs.ViewModels public override void OnApplicationStarted() { - MachineProvider.MachineOperator.PrintingStarted += PrintingStarted; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; } - private void PrintingStarted(object sender, JobHandler jobHandler) + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) { - Job = jobHandler.Job; - jobHandler.StatusChanged += JobHandler_StatusChanged; - jobHandler.Stopped += JobHandler_Stopped; - jobHandler.Completed += JobHandler_Completed; - } - - private void JobHandler_Completed(object sender, EventArgs e) - { - InvokeUI(() => - { - NotificationProvider.PushNotification().Pressed += (_, __) => - { - NavigationManager.NavigateTo(nameof(JobView)); - }; - }); + Job = e.Job; + e.JobHandler.StatusChanged += JobHandler_StatusChanged; + e.JobHandler.Stopped += JobHandler_Stopped; } public override void OnNavigatedFrom() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 211f5e205..c9e48c03f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -22,6 +22,7 @@ using System.Runtime.InteropServices; using System.Threading; using Tango.BL.ColorConversion; using Tango.SharedUI.Helpers; +using Tango.PPC.Common.Navigation; namespace Tango.PPC.Jobs.ViewModels { @@ -29,7 +30,7 @@ namespace Tango.PPC.Jobs.ViewModels /// Represents the selected job view model. /// /// - public class JobViewVM : PPCViewModel + public class JobViewVM : PPCViewModel, INavigationObjectReceiver { private ObservablesContext _db; private bool _can_navigate_back; @@ -529,16 +530,6 @@ namespace Tango.PPC.Jobs.ViewModels _check_gamut_thread.Start(); } - //Job.Segments.ReloadAsyncIdle((current, total) => - //{ - - // NotificationProvider.SetGlobalBusyMessage(String.Format("Loading job segment {0}/{1}...", current, total)); - - //}, () => - //{ - - //}); - SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); @@ -550,7 +541,6 @@ namespace Tango.PPC.Jobs.ViewModels _job_to_load = null; } - /// /// Called before the navigation system navigates back from this object. /// Return false to abort the navigation. @@ -575,5 +565,14 @@ namespace Tango.PPC.Jobs.ViewModels } #endregion + + #region INavigationObjectReceiver + + public void OnNavigatedToWithObject(Job job) + { + _job_to_load = job; + } + + #endregion } } 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 9750652f7..53fe73bd5 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 @@ -3,7 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.PPC.Common; +using Tango.PPC.Common.Notifications.NotificationItems; +using Tango.PPC.Jobs.Views; namespace Tango.PPC.Jobs.ViewModels { @@ -11,7 +14,17 @@ namespace Tango.PPC.Jobs.ViewModels { public override void OnApplicationStarted() { - + MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + } + + private void MachineOperator_PrintingCompleted(object sender, Integration.Operation.PrintingEventArgs e) + { + NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + { + + NavigationManager.NavigateWithObject(e.Job); + + })); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs index 2dba3a60b..249a917de 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs @@ -68,11 +68,23 @@ namespace Tango.PPC.Common.Navigation Task NavigateTo(String fullPath, bool pushToHistory = true); /// - /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). + /// Navigates to the specified module and view with the specified object and expecting a return parameter. /// The view must be of type INavigationResultProvider. /// /// The full path. Task NavigateForResult(TPass obj, bool pushToHistory = true) where TModule : IPPCModule; + + /// + /// Navigates to the specified module and view with the specified object. + /// + /// The type of the module. + /// The type of the view. + /// The type of the pass. + /// The object. + /// if set to true [push to history]. + /// + Task NavigateWithObject(TPass obj, bool pushToHistory = true) + where TModule : IPPCModule; } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationObjectReceiver.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationObjectReceiver.cs new file mode 100644 index 000000000..8c906b106 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationObjectReceiver.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Navigation +{ + public interface INavigationObjectReceiver + { + void OnNavigatedToWithObject(T obj); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs index e1832090e..2f74024f3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs @@ -14,6 +14,10 @@ namespace Tango.PPC.Common.Notifications /// public abstract class NotificationItem : ItemBase { - + protected override void OnPreesed() + { + base.OnPreesed(); + Close(); + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItem.cs new file mode 100644 index 000000000..5e120ab8c --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItem.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Notifications.NotificationItems +{ + public class MessageNotificationItem : NotificationItem + { + public enum MessageNotificationItemTypes + { + Info, + Success, + Warning, + Error, + } + + private String _message; + public String Message + { + get { return _message; } + set { _message = value; RaisePropertyChangedAuto(); } + } + + private MessageNotificationItemTypes _messageType; + + public MessageNotificationItemTypes MessageType + { + get { return _messageType; } + set { _messageType = value; RaisePropertyChangedAuto(); } + } + + public override Type ViewType + { + get { return typeof(MessageNotificationItemView); } + } + + public MessageNotificationItem() : base() + { + + } + + public MessageNotificationItem(String message, MessageNotificationItemTypes type, Action pressed) : this() + { + Message = message; + MessageType = type; + Pressed += (_, __) => pressed?.Invoke(); + } + + public MessageNotificationItem(String message, MessageNotificationItemTypes type) : this(message, type, null) + { + + } + + public MessageNotificationItem(String message) : this(message, MessageNotificationItemTypes.Info) + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml new file mode 100644 index 000000000..b049dc108 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml.cs new file mode 100644 index 000000000..559d81347 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.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.Common.Notifications.NotificationItems +{ + /// + /// Interaction logic for MessageNotificationItemView.xaml + /// + public partial class MessageNotificationItemView : UserControl + { + public MessageNotificationItemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 15f5d98c5..32aef8ae8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -106,12 +106,18 @@ + + + + MessageNotificationItemView.xaml + + MSBuild:Compile Designer @@ -120,6 +126,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Threading/IDispatcherProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Threading/IDispatcherProvider.cs new file mode 100644 index 000000000..4152d0cb9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Threading/IDispatcherProvider.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Threading +{ + public interface IDispatcherProvider + { + void Invoke(Action action); + void InvokeSync(Action action); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs index 0ede1306f..47450a68e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -11,6 +11,7 @@ using Tango.Core.Commands; using Tango.PPC.Common; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Threading; using Tango.PPC.UI.Views; using Tango.SharedUI.Controls; @@ -24,6 +25,7 @@ namespace Tango.PPC.UI.Navigation { private event Action NavigationCycleCompleted; + private IDispatcherProvider _dispatcherProvider; private IPPCModuleLoader _moduleLoader; private Object _currentVM; private String _lastFullPath; @@ -56,13 +58,15 @@ namespace Tango.PPC.UI.Navigation /// Initializes a new instance of the class. /// /// The module loader. - public DefaultNavigationManager(IPPCModuleLoader moduleLoader) + public DefaultNavigationManager(IPPCModuleLoader moduleLoader, IDispatcherProvider dispatcherProvider) { _navigationHistory = new Stack(); _moduleLoader = moduleLoader; NavigateToCommand = new RelayCommand(async (x) => await NavigateTo(x)); NavigateBackCommand = new RelayCommand(async () => await NavigateBack()); + + _dispatcherProvider = dispatcherProvider; } /// @@ -204,18 +208,16 @@ namespace Tango.PPC.UI.Navigation return true; } - private Task NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath) - { - if (viewPath != null && viewPath.Length > 0) - { - return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory); - } - else - { - return NavigateTo(moduleType.Name, pushToHistory); - } - } - + /// + /// Navigates for result. + /// + /// The type of the module. + /// The type of the view. + /// The type of the result. + /// The type of the object. + /// The object. + /// if set to true [push to history]. + /// public Task NavigateForResult(TObject obj, bool pushToHistory = true) where TModule : IPPCModule { @@ -258,6 +260,50 @@ namespace Tango.PPC.UI.Navigation return source.Task; } + /// + /// Navigates to the specified module and view with the specified object. + /// + /// The type of the module. + /// The type of the view. + /// The type of the pass. + /// The object. + /// if set to true [push to history]. + /// + public Task NavigateWithObject(TPass obj, bool pushToHistory = true) where TModule : IPPCModule + { + TaskCompletionSource source = new TaskCompletionSource(); + + Action handler = null; + + handler = (from, to) => + { + if (to is INavigationObjectReceiver) + { + (to as INavigationObjectReceiver).OnNavigatedToWithObject(obj); + } + + NavigationCycleCompleted -= handler; + }; + + NavigationCycleCompleted += handler; + + NavigateTo(typeof(TView).Name, pushToHistory); + + return source.Task; + } + + private Task NavigateTo(Type moduleType, bool pushToHistory = true, params String[] viewPath) + { + if (viewPath != null && viewPath.Length > 0) + { + return NavigateTo(moduleType.Name + "." + String.Join(".", viewPath), pushToHistory); + } + else + { + return NavigateTo(moduleType.Name, pushToHistory); + } + } + /// /// Gets a value indicating whether the navigation system is able to navigate to the previous view. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs index 0ff9982ee..ba869957d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/DefaultNotificationProvider.cs @@ -45,6 +45,8 @@ namespace Tango.PPC.UI.Notifications _pendingDialogs = new ConcurrentQueue>(); PopNotificationCommand = new RelayCommand((x) => PopNotification(x)); + + NotificationItems.EnableCrossThreadOperations(); } private MessageBoxVM _currentMessageBox; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index dc3745bef..a8c80c3f7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -123,6 +123,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Threading/DefaultDispetcherProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Threading/DefaultDispetcherProvider.cs new file mode 100644 index 000000000..c33233573 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Threading/DefaultDispetcherProvider.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Threading; +using Tango.PPC.Common.Threading; + +namespace Tango.PPC.UI.Threading +{ + public class DefaultDispetcherProvider : IDispatcherProvider + { + private Dispatcher _dispatcher; + + public DefaultDispetcherProvider(Dispatcher dispacther) + { + _dispatcher = dispacther; + } + + public void Invoke(Action action) + { + _dispatcher.BeginInvoke(action); + } + + public void InvokeSync(Action action) + { + _dispatcher.Invoke(action); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index e36fd4c51..d396920ab 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -11,11 +11,13 @@ using Tango.PPC.Common.EventLogging; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.Threading; using Tango.PPC.UI.Authentication; using Tango.PPC.UI.Modules; using Tango.PPC.UI.Navigation; using Tango.PPC.UI.Notifications; using Tango.PPC.UI.PPCApplication; +using Tango.PPC.UI.Threading; using Tango.PPC.UI.ViewModels; using Tango.PPC.UI.Views; using Tango.PPC.UI.ViewsContracts; @@ -34,6 +36,7 @@ namespace Tango.PPC.UI /// static ViewModelLocator() { + TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); @@ -45,6 +48,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Register(new DefaultDispetcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 11bef4827..062ade9cf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -94,11 +94,6 @@ namespace Tango.PPC.UI.ViewModels } } - private void MachineOperator_PrintingStarted(object sender, Integration.Operation.JobHandler jobHandler) - { - _jobHandler = jobHandler; - } - /// /// Opens the menu or navigate back. /// @@ -143,6 +138,11 @@ namespace Tango.PPC.UI.ViewModels MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; } + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) + { + _jobHandler = e.JobHandler; + } + /// /// Handles the ModulesLoaded event of the ModuleLoader. /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index da6abe031..099641bd4 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -61,22 +61,22 @@ namespace Tango.Integration.Operation /// /// Occurs when a printing process has started. /// - event EventHandler PrintingStarted; + event EventHandler PrintingStarted; /// /// Occurs when a printing process has failed. /// - event EventHandler PrintingFailed; + event EventHandler PrintingFailed; /// /// Occurs when a printing process has been aborted. /// - event EventHandler PrintingAborted; + event EventHandler PrintingAborted; /// /// Occurs when a printing process has completed. /// - event EventHandler PrintingCompleted; + event EventHandler PrintingCompleted; /// /// Occurs when a request has been sent. diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 20968385d..167a69b78 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -120,22 +120,22 @@ namespace Tango.Integration.Operation /// /// Occurs when a printing process has started. /// - public event EventHandler PrintingStarted; + public event EventHandler PrintingStarted; /// /// Occurs when a printing process has completed. /// - public event EventHandler PrintingCompleted; + public event EventHandler PrintingCompleted; /// /// Occurs when a printing process has failed. /// - public event EventHandler PrintingFailed; + public event EventHandler PrintingFailed; /// /// Occurs when a printing process has been aborted. /// - public event EventHandler PrintingAborted; + public event EventHandler PrintingAborted; #endregion @@ -753,7 +753,7 @@ namespace Tango.Integration.Operation try { var result = await SendRequest(new AbortJobRequest()); - PrintingAborted?.Invoke(this, new EventArgs()); + PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); handler.RaiseCanceled(); } catch (Exception ex) @@ -762,7 +762,7 @@ namespace Tango.Integration.Operation } }, originalJob, processParameters); - handler.StatusChanged += (x, s) => + handler.StatusChanged += (x, s) => { RunningJobStatus = s; }; @@ -778,7 +778,7 @@ namespace Tango.Integration.Operation { Status = MachineStatuses.Printing; RunningJob = originalJob; - PrintingStarted?.Invoke(this, handler); + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); responseLogged = true; LogResponseReceived(response.Message); } @@ -789,7 +789,7 @@ namespace Tango.Integration.Operation if (!handler.IsCanceled) { Status = MachineStatuses.Error; - PrintingFailed?.Invoke(this, ex); + PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); handler.RaiseFailed(ex); LogRequestFailed(request, ex); } @@ -801,7 +801,7 @@ namespace Tango.Integration.Operation }, () => { Status = MachineStatuses.ReadyToDye; - PrintingCompleted?.Invoke(this, new EventArgs()); + PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); handler.RaiseCompleted(); }); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs new file mode 100644 index 000000000..fe8a573a5 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/PrintingEventArgs.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + public class PrintingEventArgs : EventArgs + { + public JobHandler JobHandler { get; private set; } + public Job Job { get; private set; } + + public PrintingEventArgs(JobHandler jobHandler, Job job) + { + JobHandler = jobHandler; + Job = job; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PrintingFailedEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PrintingFailedEventArgs.cs new file mode 100644 index 000000000..0898a7c72 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/PrintingFailedEventArgs.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + public class PrintingFailedEventArgs : PrintingEventArgs + { + public Exception Exception { get; private set; } + + public PrintingFailedEventArgs(JobHandler jobHandler, Job job, Exception ex) : base(jobHandler, job) + { + Exception = ex; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 36ab0de06..7482db8c0 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -87,9 +87,11 @@ + + diff --git a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml index 782fefdea..fd1d77d82 100644 --- a/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml +++ b/Software/Visual_Studio/Tango.Touch/Resources/Colors.xaml @@ -42,6 +42,9 @@ #c1c5cb #FF6767 + + #56da6c + #FF7505 #fa1555 @@ -84,5 +87,7 @@ + + \ No newline at end of file -- cgit v1.3.1 From de5700549a5fe01862f71d452f2abe4a74996605 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Jul 2018 14:16:26 +0300 Subject: Implemented PPC twine animated gif. Sign out. Implemented TangoInject attribute 'When Available' mode! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Authentication/IAuthenticationProvider.cs | 2 +- .../Connection/DefaultMachineProvider.cs | 14 +++++--- .../DefaultAuthenticationProvider.cs | 13 ++++++- .../PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif | Bin 0 -> 377756 bytes .../PPCApplication/DefaultPPCApplicationManager.cs | 39 ++++++++++++++------- .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 1 + .../PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs | 15 ++++++++ .../PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs | 8 +++++ .../PPC/Tango.PPC.UI/Views/LayoutView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/LoadingView.xaml | 30 ++++++++++++++-- .../PPC/Tango.PPC.UI/Views/LoginView.xaml | 6 ++-- Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs | 28 +++++++++++++-- .../Tango.Core/DI/TangoInjectAttribute.cs | 10 ++++++ .../Visual_Studio/Tango.Core/DI/TangoInjectMode.cs | 14 ++++++++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 1 + 17 files changed, 156 insertions(+), 27 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif create mode 100644 Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 67bfef2e9..171258f71 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index ef2543dd1..9349d3c16 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs index 0892932a8..75c2b1d61 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs @@ -33,6 +33,6 @@ namespace Tango.PPC.Common.Authentication /// /// Logs-out the current logged-in user. /// - void Logout(); + void LogOut(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs index 1fd5fdd0a..d0f8f4c6c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connection/DefaultMachineProvider.cs @@ -71,12 +71,16 @@ namespace Tango.PPC.Common.Connection private async void ConnectToMachine() { - Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); - var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); + try + { + Transport.Discovery.UsbCommunicationScanner scanner = new Transport.Discovery.UsbCommunicationScanner(UsbSerialBaudRates.BR_9600); + var response = await scanner.Scan(new ConnectRequest() { Password = "1234" }, TimeSpan.FromSeconds(10)); - await MachineOperator.Disconnect(); - MachineOperator.Adapter = response.Adapter; - await MachineOperator.Connect(); + await MachineOperator.Disconnect(); + MachineOperator.Adapter = response.Adapter; + await MachineOperator.Connect(); + } + catch { } } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs index a259e303a..7196c9743 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs @@ -6,7 +6,9 @@ using System.Threading.Tasks; using Tango.BL; using Tango.BL.Entities; using Tango.Core; +using Tango.Core.DI; using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Navigation; namespace Tango.PPC.UI.Authentication { @@ -17,6 +19,9 @@ namespace Tango.PPC.UI.Authentication /// public class DefaultAuthenticationProvider : ExtendedObject, IAuthenticationProvider { + [TangoInject(TangoInjectMode.WhenAvailable)] + private INavigationManager _navigation; + /// /// Occurs when the current logged-in user has changed. /// @@ -36,6 +41,11 @@ namespace Tango.PPC.UI.Authentication } } + public DefaultAuthenticationProvider() + { + + } + /// /// Performs a user login by the specified email and password. /// @@ -53,10 +63,11 @@ namespace Tango.PPC.UI.Authentication /// /// Logs-out the current logged-in user. /// - public void Logout() + public void LogOut() { CurrentUser = null; CurrentUserChanged?.Invoke(this, CurrentUser); + _navigation.NavigateTo(NavigationView.LoginView); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif new file mode 100644 index 000000000..3aac6d473 Binary files /dev/null and b/Software/Visual_Studio/PPC/Tango.PPC.UI/Images/Twine_Loading_GIF.gif differ diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 5f5fb4f7e..0fbef92a7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -30,6 +30,7 @@ namespace Tango.PPC.UI.PPCApplication public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager { private List _notifiedViewModels; + private IMachineProvider _machineProvider; /// /// Occurs when the application has started. @@ -63,6 +64,8 @@ namespace Tango.PPC.UI.PPCApplication /// public DefaultPPCApplicationManager(IMachineProvider machineProvider) { + _machineProvider = machineProvider; + if (!DesignMode) { _notifiedViewModels = new List(); @@ -115,20 +118,17 @@ namespace Tango.PPC.UI.PPCApplication { if (loader.UserModules.Count > 0) { - loader.UserModules.LastOrDefault().Initialized += (e, f) => + if (loader.UserModules.ToList().Exists(m => !m.IsInitialized)) { - foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) + loader.UserModules.LastOrDefault().Initialized += (e, f) => { - if (!_notifiedViewModels.Contains(vm)) - { - vm.OnApplicationStarted(); - _notifiedViewModels.Add(vm); - } - } - - ModulesInitialized?.Invoke(this, new EventArgs()); - machineProvider.Init(); - }; + FinalizeModuleInitialization(); + }; + } + else + { + FinalizeModuleInitialization(); + } } }; }); @@ -136,6 +136,21 @@ namespace Tango.PPC.UI.PPCApplication } } + private void FinalizeModuleInitialization() + { + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase()) + { + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } + } + + ModulesInitialized?.Invoke(this, new EventArgs()); + _machineProvider.Init(); + } + /// /// Shutdown the application. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index a8c80c3f7..cc5eed54f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -323,6 +323,7 @@ Tango.ColorLib.dll PreserveNewest + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs index 062ade9cf..268f42ce9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs @@ -73,6 +73,11 @@ namespace Tango.PPC.UI.ViewModels /// public RelayCommand StopPrintingCommand { get; set; } + /// + /// Gets or sets the sign-out command. + /// + public RelayCommand SignOutCommand { get; set; } + /// /// Initializes a new instance of the class. /// @@ -84,6 +89,7 @@ namespace Tango.PPC.UI.ViewModels NotificationsAreaPressedCommand = new RelayCommand(OpenFirstNotificationOrDisplayAll); StopPrintingCommand = new RelayCommand(StopPrinting); + SignOutCommand = new RelayCommand(SignOut); } private void StopPrinting() @@ -161,6 +167,15 @@ namespace Tango.PPC.UI.ViewModels } + /// + /// Represents an event that is raised when the sign-out operation is complete. + /// + private void SignOut() + { + AuthenticationProvider.LogOut(); + IsMenuOpened = false; + } + /// /// Opens the first notification or display all. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index dd54873ce..022efd9b8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -54,7 +54,15 @@ namespace Tango.PPC.UI.ViewModels public override void OnApplicationStarted() { + AuthenticationProvider.CurrentUserChanged += AuthenticationProvider_CurrentUserChanged; + } + private void AuthenticationProvider_CurrentUserChanged(object sender, BL.Entities.User user) + { + if (user == null) + { + Password = String.Empty; + } } private void Login() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 89e199ed1..3aa6e0118 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -85,7 +85,7 @@ - + Sign Out diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml index ca7d7fb53..9e7861595 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" xmlns:fx="clr-namespace:Tango.SharedUI.Effects;assembly=Tango.SharedUI" + xmlns:gif="clr-namespace:Tango.AnimatedGif;assembly=Tango.AnimatedGif" xmlns:global="clr-namespace:Tango.PPC.UI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.UI.Views" @@ -12,7 +13,7 @@ d:DesignHeight="1280" d:DesignWidth="720" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}"> - + - Loading... + + + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml index 027e61d08..179d1dde3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoginView.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d" d:DesignHeight="1280" d:DesignWidth="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:LoginViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoginViewVM}"> - + Login to your account @@ -21,9 +21,9 @@ - Keep me logged in. + Keep me signed in - LOGIN + LOGIN Forgot password? diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs index 20827bca7..e79a89acd 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs @@ -341,12 +341,36 @@ namespace Tango.Core.DI foreach (var prop in type.GetPropertiesWithAttribute(BindingFlags.Public | BindingFlags.Instance)) { - prop.SetValue(target, GetInstance(prop.PropertyType)); + var att = prop.GetCustomAttribute(); + + if (att.Mode == TangoInjectMode.Immediate) + { + prop.SetValue(target, GetInstance(prop.PropertyType)); + } + else + { + GetInstanceWhenAvailable(prop.PropertyType, (x) => + { + prop.SetValue(target, GetInstance(prop.PropertyType)); + }); + } } foreach (var field in type.GetFieldsWithAttribute(BindingFlags.NonPublic | BindingFlags.Instance)) { - field.SetValue(target, GetInstance(field.FieldType)); + var att = field.GetCustomAttribute(); + + if (att.Mode == TangoInjectMode.Immediate) + { + field.SetValue(target, GetInstance(field.FieldType)); + } + else + { + GetInstanceWhenAvailable(field.FieldType, (x) => + { + field.SetValue(target, GetInstance(field.FieldType)); + }); + } } } } diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs b/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs index f316347fb..b05a83769 100644 --- a/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs +++ b/Software/Visual_Studio/Tango.Core/DI/TangoInjectAttribute.cs @@ -9,6 +9,16 @@ namespace Tango.Core.DI [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Constructor)] public class TangoInjectAttribute : Attribute { + public TangoInjectMode Mode { get; set; } + public TangoInjectAttribute() + { + + } + + public TangoInjectAttribute(TangoInjectMode mode) + { + Mode = mode; + } } } diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs b/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs new file mode 100644 index 000000000..7ee70b3ec --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/DI/TangoInjectMode.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Core.DI +{ + public enum TangoInjectMode + { + Immediate, + WhenAvailable, + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 1e70bc587..d5e03d03c 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -75,6 +75,7 @@ + -- cgit v1.3.1