diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-07-15 01:04:34 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-07-15 01:04:34 +0300 |
| commit | cc425e019d3a7d3494ac15ffe213b6b47b1c64ed (patch) | |
| tree | 6db5ec969f92f91c2d05af55216bc4a267cc2370 | |
| parent | 64bcf92608faae31b7cd31ac3da5c7d1d7ebcd0b (diff) | |
| download | Tango-cc425e019d3a7d3494ac15ffe213b6b47b1c64ed.tar.gz Tango-cc425e019d3a7d3494ac15ffe213b6b47b1c64ed.zip | |
Working on PPC.
28 files changed, 366 insertions, 112 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 670011fef..ed4d61e76 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 1bcea900a..90c771cf6 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf 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 @@ -<UserControl x:Class="Tango.PPC.Jobs.NotificationItems.JobCompletedNotificationItemView" - 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" - xmlns:local="clr-namespace:Tango.PPC.Jobs.NotificationItems" - mc:Ignorable="d" - d:DesignHeight="60" d:DesignWidth="800"> - <Grid> - <DockPanel> - <touch:TouchIcon Margin="10" DockPanel.Dock="Left" Icon="Check" Foreground="{StaticResource TangoGreenBrush}" /> - <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="{StaticResource TangoGreenBrush}">The job has been completed</TextBlock> - </DockPanel> - </Grid> -</UserControl> 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 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> - <Page Include="NotificationItems\JobCompletedNotificationItemView.xaml"> - <SubType>Designer</SubType> - <Generator>MSBuild:Compile</Generator> - </Page> <Page Include="Resources\Styles.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -163,10 +159,6 @@ <Compile Include="Messages\JobRemovedMessage.cs" /> <Compile Include="Messages\JobSavedMessage.cs" /> <Compile Include="Messages\JobSelectedMessage.cs" /> - <Compile Include="NotificationItems\JobCompletedNotificationItem.cs" /> - <Compile Include="NotificationItems\JobCompletedNotificationItemView.xaml.cs"> - <DependentUpon>JobCompletedNotificationItemView.xaml</DependentUpon> - </Compile> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> </Compile> 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<JobCompletedNotificationItem>().Pressed += (_, __) => - { - NavigationManager.NavigateTo<JobsModule>(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. /// </summary> /// <seealso cref="Tango.PPC.Common.PPCViewModel" /> - public class JobViewVM : PPCViewModel + public class JobViewVM : PPCViewModel, INavigationObjectReceiver<Job> { 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; } - /// <summary> /// 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<JobsModule, JobView, Job>(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<bool> NavigateTo(String fullPath, bool pushToHistory = true); /// <summary> - /// 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<TResult>. /// </summary> /// <param name="fullPath">The full path.</param> Task<TResult> NavigateForResult<TModule, TView, TResult, TPass>(TPass obj, bool pushToHistory = true) where TModule : IPPCModule; + + /// <summary> + /// Navigates to the specified module and view with the specified object. + /// </summary> + /// <typeparam name="TModule">The type of the module.</typeparam> + /// <typeparam name="TView">The type of the view.</typeparam> + /// <typeparam name="TPass">The type of the pass.</typeparam> + /// <param name="obj">The object.</param> + /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param> + /// <returns></returns> + Task<bool> NavigateWithObject<TModule, TView, TPass>(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<T> + { + 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 /// </summary> 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 @@ +<UserControl x:Class="Tango.PPC.Common.Notifications.NotificationItems.MessageNotificationItemView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.Common.Notifications.NotificationItems" + mc:Ignorable="d" + d:DesignHeight="60" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=local:MessageNotificationItem, IsDesignTimeCreatable=False}"> + <ContentControl> + <ContentControl.Style> + <Style TargetType="ContentControl"> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding MessageType}" Value="Info"> + <Setter Property="Foreground" Value="{StaticResource TangoLightForegroundBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Success"> + <Setter Property="Foreground" Value="{StaticResource TangoSuccessBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Warning"> + <Setter Property="Foreground" Value="{StaticResource TangoWarningBrush}"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Error"> + <Setter Property="Foreground" Value="{StaticResource TangoErrorBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </ContentControl.Style> + <DockPanel> + <touch:TouchIcon Margin="15" DockPanel.Dock="Left" MaxHeight="50"> + <touch:TouchIcon.Style> + <Style TargetType="touch:TouchIcon"> + <Setter Property="Icon" Value="Information"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding MessageType}" Value="Info"> + <Setter Property="Icon" Value="Information"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Success"> + <Setter Property="Icon" Value="Check"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Warning"> + <Setter Property="Icon" Value="Alert"></Setter> + </DataTrigger> + <DataTrigger Binding="{Binding MessageType}" Value="Error"> + <Setter Property="Icon" Value="AlertOctagon"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </touch:TouchIcon.Style> + </touch:TouchIcon> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Text="{Binding Message}"></TextBlock> + </DockPanel> + </ContentControl> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml.cs index b6d9797e5..559d81347 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NotificationItems/JobCompletedNotificationItemView.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml.cs @@ -13,14 +13,14 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -namespace Tango.PPC.Jobs.NotificationItems +namespace Tango.PPC.Common.Notifications.NotificationItems { /// <summary> - /// Interaction logic for JobCompletedNotificationItemView.xaml + /// Interaction logic for MessageNotificationItemView.xaml /// </summary> - public partial class JobCompletedNotificationItemView : UserControl + public partial class MessageNotificationItemView : UserControl { - public JobCompletedNotificationItemView() + 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 @@ <Compile Include="IPPCView.cs" /> <Compile Include="Modules\IPPCModuleLoader.cs" /> <Compile Include="Navigation\INavigationBlocker.cs" /> + <Compile Include="Navigation\INavigationObjectReceiver.cs" /> <Compile Include="Navigation\INavigationResultProvider.cs" /> <Compile Include="Notifications\AppBarItem.cs" /> <Compile Include="Notifications\ItemBase.cs" /> <Compile Include="Notifications\NotificationItem.cs" /> + <Compile Include="Notifications\NotificationItems\MessageNotificationItem.cs" /> + <Compile Include="Notifications\NotificationItems\MessageNotificationItemView.xaml.cs"> + <DependentUpon>MessageNotificationItemView.xaml</DependentUpon> + </Compile> <Compile Include="PPCModuleAttribute.cs" /> <Compile Include="PPCModuleBase.cs" /> + <Compile Include="Threading\IDispatcherProvider.cs" /> <Page Include="Controls\MultiPieChart.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -120,6 +126,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Notifications\NotificationItems\MessageNotificationItemView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Resources\Colors.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> 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<Object, Object> 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 <see cref="DefaultNavigationManager"/> class. /// </summary> /// <param name="moduleLoader">The module loader.</param> - public DefaultNavigationManager(IPPCModuleLoader moduleLoader) + public DefaultNavigationManager(IPPCModuleLoader moduleLoader, IDispatcherProvider dispatcherProvider) { _navigationHistory = new Stack<String>(); _moduleLoader = moduleLoader; NavigateToCommand = new RelayCommand<string>(async (x) => await NavigateTo(x)); NavigateBackCommand = new RelayCommand(async () => await NavigateBack()); + + _dispatcherProvider = dispatcherProvider; } /// <summary> @@ -204,18 +208,16 @@ namespace Tango.PPC.UI.Navigation return true; } - private Task<bool> 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); - } - } - + /// <summary> + /// Navigates for result. + /// </summary> + /// <typeparam name="TModule">The type of the module.</typeparam> + /// <typeparam name="TView">The type of the view.</typeparam> + /// <typeparam name="TResult">The type of the result.</typeparam> + /// <typeparam name="TObject">The type of the object.</typeparam> + /// <param name="obj">The object.</param> + /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param> + /// <returns></returns> public Task<TResult> NavigateForResult<TModule, TView, TResult, TObject>(TObject obj, bool pushToHistory = true) where TModule : IPPCModule { @@ -259,6 +261,50 @@ namespace Tango.PPC.UI.Navigation } /// <summary> + /// Navigates to the specified module and view with the specified object. + /// </summary> + /// <typeparam name="TModule">The type of the module.</typeparam> + /// <typeparam name="TView">The type of the view.</typeparam> + /// <typeparam name="TPass">The type of the pass.</typeparam> + /// <param name="obj">The object.</param> + /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param> + /// <returns></returns> + public Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true) where TModule : IPPCModule + { + TaskCompletionSource<bool> source = new TaskCompletionSource<bool>(); + + Action<Object, Object> handler = null; + + handler = (from, to) => + { + if (to is INavigationObjectReceiver<TPass>) + { + (to as INavigationObjectReceiver<TPass>).OnNavigatedToWithObject(obj); + } + + NavigationCycleCompleted -= handler; + }; + + NavigationCycleCompleted += handler; + + NavigateTo<TModule>(typeof(TView).Name, pushToHistory); + + return source.Task; + } + + private Task<bool> 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); + } + } + + /// <summary> /// Gets a value indicating whether the navigation system is able to navigate to the previous view. /// </summary> public bool CanNavigateBack 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<PendingNotification<DialogAndView, DialogViewVM>>(); PopNotificationCommand = new RelayCommand<NotificationItem>((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 @@ <Compile Include="Notifications\DialogAndView.cs" /> <Compile Include="Notifications\PendingNotification.cs" /> <Compile Include="PPCApplication\DefaultPPCApplicationManager.cs" /> + <Compile Include="Threading\DefaultDispetcherProvider.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\LayoutViewVM.cs" /> <Compile Include="ViewModels\LoadingViewVM.cs" /> 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 /// </summary> static ViewModelLocator() { + TangoIOC.Default.Unregister<IDispatcherProvider>(); TangoIOC.Default.Unregister<INotificationProvider>(); TangoIOC.Default.Unregister<IAuthenticationProvider>(); TangoIOC.Default.Unregister<IPPCModuleLoader>(); @@ -45,6 +48,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IEventLogger>(); TangoIOC.Default.Unregister<ITeamFoundationServiceClient>(); + TangoIOC.Default.Register<IDispatcherProvider, DefaultDispetcherProvider>(new DefaultDispetcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>(); TangoIOC.Default.Register<IAuthenticationProvider, DefaultAuthenticationProvider>(); TangoIOC.Default.Register<IPPCModuleLoader, DefaultPPCModuleLoader>(); 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; - } - /// <summary> /// Opens the menu or navigate back. /// </summary> @@ -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; + } + /// <summary> /// Handles the ModulesLoaded event of the ModuleLoader. /// </summary> 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 /// <summary> /// Occurs when a printing process has started. /// </summary> - event EventHandler<JobHandler> PrintingStarted; + event EventHandler<PrintingEventArgs> PrintingStarted; /// <summary> /// Occurs when a printing process has failed. /// </summary> - event EventHandler<Exception> PrintingFailed; + event EventHandler<PrintingFailedEventArgs> PrintingFailed; /// <summary> /// Occurs when a printing process has been aborted. /// </summary> - event EventHandler PrintingAborted; + event EventHandler<PrintingEventArgs> PrintingAborted; /// <summary> /// Occurs when a printing process has completed. /// </summary> - event EventHandler PrintingCompleted; + event EventHandler<PrintingEventArgs> PrintingCompleted; /// <summary> /// 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 /// <summary> /// Occurs when a printing process has started. /// </summary> - public event EventHandler<JobHandler> PrintingStarted; + public event EventHandler<PrintingEventArgs> PrintingStarted; /// <summary> /// Occurs when a printing process has completed. /// </summary> - public event EventHandler PrintingCompleted; + public event EventHandler<PrintingEventArgs> PrintingCompleted; /// <summary> /// Occurs when a printing process has failed. /// </summary> - public event EventHandler<Exception> PrintingFailed; + public event EventHandler<PrintingFailedEventArgs> PrintingFailed; /// <summary> /// Occurs when a printing process has been aborted. /// </summary> - public event EventHandler PrintingAborted; + public event EventHandler<PrintingEventArgs> PrintingAborted; #endregion @@ -753,7 +753,7 @@ namespace Tango.Integration.Operation try { var result = await SendRequest<AbortJobRequest, AbortJobResponse>(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 @@ <Compile Include="Operation\EmbeddedLogItem.cs" /> <Compile Include="Operation\IMachineEventsStateProvider.cs" /> <Compile Include="Operation\IMachineOperator.cs" /> + <Compile Include="Operation\PrintingFailedEventArgs.cs" /> <Compile Include="Operation\MachineOperator.cs" /> <Compile Include="Operation\JobHandler.cs" /> <Compile Include="Operation\MachineStatuses.cs" /> + <Compile Include="Operation\PrintingEventArgs.cs" /> <Compile Include="Operation\RequestFailedEventArgs.cs" /> <Compile Include="Operation\RunningJobStatus.cs" /> <Compile Include="Services\ExternalBridgeScanner.cs" /> 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 @@ <Color x:Key="TangoGrayColor">#c1c5cb</Color> <Color x:Key="TangoRedColor">#FF6767</Color> + + <Color x:Key="TangoSuccessColor">#56da6c</Color> + <Color x:Key="TangoWarningColor">#FF7505</Color> <Color x:Key="TangoErrorColor">#fa1555</Color> <!--Brushes--> @@ -84,5 +87,7 @@ <SolidColorBrush x:Key="TangoGrayBrush" Color="{StaticResource TangoGrayColor}"></SolidColorBrush> <SolidColorBrush x:Key="TangoRedBrush" Color="{StaticResource TangoRedColor}"></SolidColorBrush> + <SolidColorBrush x:Key="TangoSuccessBrush" Color="{StaticResource TangoSuccessColor}"></SolidColorBrush> + <SolidColorBrush x:Key="TangoWarningBrush" Color="{StaticResource TangoWarningColor}"></SolidColorBrush> <SolidColorBrush x:Key="TangoErrorBrush" Color="{StaticResource TangoErrorColor}"></SolidColorBrush> </ResourceDictionary>
\ No newline at end of file |
