From fdfa740288568dba27877a5ef5c817be323cfbb0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 16 Jul 2018 13:47:20 +0300 Subject: Working on PPC. --- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 18 +++--- .../Tango.PPC.Jobs/ViewModels/MainViewVM.cs | 15 ++++- .../Tango.PPC.Jobs/Views/JobProgressView.xaml | 71 +++++++++++++++++++++- .../Navigation/INavigationManager.cs | 18 ++++++ .../Notifications/NotificationItem.cs | 13 ++++ .../MessageNotificationItemView.xaml | 13 +++- .../Navigation/DefaultNavigationManager.cs | 31 ++++++++++ .../PPC/Tango.PPC.UI/Views/MainView.xaml | 9 +-- 8 files changed, 169 insertions(+), 19 deletions(-) (limited to 'Software/Visual_Studio/PPC') 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 c9e48c03f..92c9b4b94 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 @@ -506,7 +506,7 @@ namespace Tango.PPC.Jobs.ViewModels /// public async override void OnNavigatedTo() { - if (_job_to_load == null) return; + if (_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid)) return; NotificationProvider.SetGlobalBusyMessage("Loading job details..."); @@ -552,13 +552,15 @@ namespace Tango.PPC.Jobs.ViewModels if (!_can_navigate_back) { - result = await NotificationProvider.ShowQuestion("Are you sure you want to exit this job?"); - } - - if (result) - { - Job = null; - SegmentsCollectionView = null; + if (await NotificationProvider.ShowQuestion("Are you sure you want to exit this job?")) + { + Job = null; + SegmentsCollectionView = null; + } + else + { + result = false; + } } return result; 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 53fe73bd5..5b49aedf1 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 @@ -15,15 +15,24 @@ namespace Tango.PPC.Jobs.ViewModels public override void OnApplicationStarted() { MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; } - private void MachineOperator_PrintingCompleted(object sender, Integration.Operation.PrintingEventArgs e) + private void MachineOperator_PrintingFailed(object sender, Integration.Operation.PrintingFailedEventArgs e) { - NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("Job failed. ({0})", e.Exception.Message), MessageNotificationItem.MessageNotificationItemTypes.Error, () => { - NavigationManager.NavigateWithObject(e.Job); + NavigationManager.ClearHistoryExcept(); + })); + } + private void MachineOperator_PrintingCompleted(object sender, Integration.Operation.PrintingEventArgs e) + { + NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + { + NavigationManager.NavigateWithObject(e.Job); + NavigationManager.ClearHistoryExcept(); })); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml index e707b3550..56fbcd9a7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobProgressView.xaml @@ -21,7 +21,24 @@ - + + + + + @@ -60,8 +77,52 @@ - now dying - + + + + + @@ -75,6 +136,10 @@ + + + Go to 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 249a917de..94a2e8d35 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Navigation/INavigationManager.cs @@ -12,8 +12,16 @@ namespace Tango.PPC.Common.Navigation /// public interface INavigationManager { + /// + /// Gets the current module. + /// IPPCModule CurrentModule { get; } + /// + /// Gets the current view model. + /// + PPCViewModel CurrentVM { get; } + /// /// Gets a value indicating whether the navigation system is able to navigate to the previous view. /// @@ -86,5 +94,15 @@ namespace Tango.PPC.Common.Navigation /// Task NavigateWithObject(TPass obj, bool pushToHistory = true) where TModule : IPPCModule; + + /// + /// Clears the navigation back history. + /// + void ClearHistory(); + + /// + /// Clears the navigation back history except the specified view type. + /// + void ClearHistoryExcept(); } } 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 2f74024f3..1fdf0c729 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,19 @@ namespace Tango.PPC.Common.Notifications /// public abstract class NotificationItem : ItemBase { + private bool _isExpanded; + /// + /// Gets or sets a value indicating whether the notification panel is expanded. + /// + public bool IsExpanded + { + get { return _isExpanded; } + set { _isExpanded = value; RaisePropertyChangedAuto(); } + } + + /// + /// Called when the item has been pressed. + /// protected override void OnPreesed() { base.OnPreesed(); 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 index b049dc108..fa26bce83 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml @@ -49,7 +49,18 @@ - + + + + + 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 47450a68e..f06bd88de 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs @@ -34,6 +34,14 @@ namespace Tango.PPC.UI.Navigation private Stack _navigationHistory; + /// + /// Gets the current view model. + /// + public PPCViewModel CurrentVM + { + get { return _currentVM as PPCViewModel; } + } + private IPPCModule _currentModule; /// /// Gets or sets the current module. @@ -339,5 +347,28 @@ namespace Tango.PPC.UI.Navigation return false; } } + + /// + /// Clears the navigation back history. + /// + public void ClearHistory() + { + _navigationHistory.Clear(); + RaisePropertyChanged(nameof(CanNavigateBack)); + } + + public void ClearHistoryExcept() + { + var history_list = _navigationHistory.ToList(); + history_list = history_list.Where(x => x.Contains(typeof(T).Name)).Distinct().ToList(); + _navigationHistory.Clear(); + + foreach (var item in history_list) + { + _navigationHistory.Push(item); + } + + RaisePropertyChanged(nameof(CanNavigateBack)); + } } } 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 f333ea2e8..1ce18bff1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -23,15 +23,16 @@ CurrentMessageBox="{Binding NotificationProvider.CurrentMessageBox}" HasNotifications="{Binding NotificationProvider.HasNotificationItems}" Notifications="{Binding NotificationProvider.NotificationItems}" + ItemExpandedPropertyPath="IsExpanded" HasDialog="{Binding NotificationProvider.HasDialog}" CurrentDialog="{Binding NotificationProvider.CurrentDialog}"> - - - - + + + + -- cgit v1.3.1