aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-19 17:56:11 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-19 17:56:11 +0300
commit3fe33a685c3ca7a8730dacffa5357f77d7e76a96 (patch)
treebbdb2e455ab851e6b350ec98d8eacf8eb5f3fafc /Software/Visual_Studio
parent425a679e42f0b61f2f63d92955600cadbc698e1d (diff)
downloadTango-3fe33a685c3ca7a8730dacffa5357f77d7e76a96.tar.gz
Tango-3fe33a685c3ca7a8730dacffa5357f77d7e76a96.zip
Implemented sample dye navigation on PPC.
Fixed some issues with TangoIOC GetWhenAvailable.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/JobNavigationObject.cs21
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs14
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs38
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs20
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs13
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs5
-rw-r--r--Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs12
-rw-r--r--Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs28
10 files changed, 136 insertions, 19 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/JobNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/JobNavigationObject.cs
new file mode 100644
index 000000000..1807f8294
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/JobNavigationObject.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.PPC.Jobs.NavigationObjects
+{
+ public class JobNavigationObject
+ {
+ public Job Job { get; set; }
+ public JobNavigationIntent Intent { get; set; }
+ }
+
+ public enum JobNavigationIntent
+ {
+ Default,
+ SampleDye,
+ }
+}
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 1a4b76cf2..2cb924aa4 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
@@ -166,6 +166,7 @@
<Compile Include="Messages\JobRemovedMessage.cs" />
<Compile Include="Messages\JobSavedMessage.cs" />
<Compile Include="Messages\JobSelectedMessage.cs" />
+ <Compile Include="NavigationObjects\JobNavigationObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@@ -179,6 +180,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
+ <Compile Include="ViewContracts\IJobView.cs" />
<Compile Include="ViewModelLocator.cs" />
<Compile Include="ViewModels\JobProgressViewVM.cs" />
<Compile Include="ViewModels\JobSummeryViewVM.cs" />
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs
new file mode 100644
index 000000000..345dced81
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewContracts/IJobView.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.PPC.Common;
+
+namespace Tango.PPC.Jobs.ViewContracts
+{
+ public interface IJobView : IPPCView
+ {
+ void DisplaySampleDye();
+ }
+}
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 3ebefb00f..7cc76bdcc 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
@@ -23,6 +23,8 @@ using System.Threading;
using Tango.BL.ColorConversion;
using Tango.SharedUI.Helpers;
using Tango.PPC.Common.Navigation;
+using Tango.PPC.Jobs.NavigationObjects;
+using Tango.PPC.Jobs.ViewContracts;
namespace Tango.PPC.Jobs.ViewModels
{
@@ -30,12 +32,13 @@ namespace Tango.PPC.Jobs.ViewModels
/// Represents the selected job view model.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
- public class JobViewVM : PPCViewModel, INavigationObjectReceiver<Job>
+ public class JobViewVM : PPCViewModel<IJobView>, INavigationObjectReceiver<JobNavigationObject>
{
private ObservablesContext _db;
private bool _can_navigate_back;
private Thread _check_gamut_thread;
private Job _job_to_load;
+ private JobNavigationIntent _job_to_load_intent;
#region Properties
@@ -447,6 +450,8 @@ namespace Tango.PPC.Jobs.ViewModels
private void StartSampleDye()
{
Job sampleDyeJob = Job.Clone();
+ sampleDyeJob.Guid = Job.Guid;
+ sampleDyeJob.IsSample = true;
sampleDyeJob.Name = Job.Name + " (sample)";
if (Job.JobType == BL.Enumerations.JobTypes.Embroidery)
@@ -508,7 +513,7 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public override void OnApplicationStarted()
{
-
+ base.OnApplicationStarted();
}
/// <summary>
@@ -516,7 +521,14 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public async override void OnNavigatedTo()
{
- if (_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid)) return;
+ if (_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))
+ {
+ if (_job_to_load_intent == JobNavigationIntent.SampleDye)
+ {
+ View.DisplaySampleDye();
+ }
+ return;
+ }
NotificationProvider.SetGlobalBusyMessage("Loading job details...");
@@ -529,6 +541,7 @@ namespace Tango.PPC.Jobs.ViewModels
}
_db = ObservablesContext.CreateDefault();
+ var a = _db.Jobs.ToList();
Job = await _db.Jobs.SingleOrDefaultAsync(x => x.Guid == _job_to_load.Guid);
Job.ValidateOnPropertyChanged = true;
Rmls = await _db.Rmls.ToListAsync();
@@ -550,6 +563,20 @@ namespace Tango.PPC.Jobs.ViewModels
});
_job_to_load = null;
+
+ if (_job_to_load_intent == JobNavigationIntent.SampleDye)
+ {
+ View.DisplaySampleDye();
+ }
+ }
+
+ /// <summary>
+ /// Called when the navigation system has navigated from this VM view.
+ /// </summary>
+ public override void OnNavigatedFrom()
+ {
+ base.OnNavigatedFrom();
+ _job_to_load_intent = JobNavigationIntent.Default;
}
/// <summary>
@@ -581,9 +608,10 @@ namespace Tango.PPC.Jobs.ViewModels
#region INavigationObjectReceiver
- public void OnNavigatedToWithObject(Job job)
+ public void OnNavigatedToWithObject(JobNavigationObject e)
{
- _job_to_load = job;
+ _job_to_load_intent = e.Intent;
+ _job_to_load = e.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 5b49aedf1..5c66f045b 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
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.PPC.Common;
using Tango.PPC.Common.Notifications.NotificationItems;
+using Tango.PPC.Jobs.NavigationObjects;
using Tango.PPC.Jobs.Views;
namespace Tango.PPC.Jobs.ViewModels
@@ -29,11 +30,22 @@ namespace Tango.PPC.Jobs.ViewModels
private void MachineOperator_PrintingCompleted(object sender, Integration.Operation.PrintingEventArgs e)
{
- NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () =>
+ if (e.Job.IsSample)
{
- NavigationManager.NavigateWithObject<JobsModule, JobView, Job>(e.Job);
- NavigationManager.ClearHistoryExcept<JobsView>();
- }));
+ NotificationProvider.PushNotification(new MessageNotificationItem("Sample completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () =>
+ {
+ NavigationManager.NavigateWithObject<JobsModule, JobView, JobNavigationObject>(new JobNavigationObject() { Job = e.Job, Intent = JobNavigationIntent.SampleDye });
+ NavigationManager.ClearHistoryExcept<JobsView>();
+ }));
+ }
+ else
+ {
+ NotificationProvider.PushNotification(new MessageNotificationItem("Job completed successfully.", MessageNotificationItem.MessageNotificationItemTypes.Success, () =>
+ {
+ NavigationManager.NavigateWithObject<JobsModule, JobView, JobNavigationObject>(new JobNavigationObject() { Job = e.Job });
+ NavigationManager.ClearHistoryExcept<JobsView>();
+ }));
+ }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml
index a9aebb068..d5f77fc5d 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml
@@ -564,7 +564,7 @@
</StackPanel>
</Border>-->
- <touch:TouchExpander Margin="0 0 0 120" Padding="20 15" IsExpanded="True">
+ <touch:TouchExpander x:Name="expander_sample_dye" Margin="0 0 0 120" Padding="20 15">
<touch:TouchExpander.Header>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0 0 20 0">
<Image Source="../Images/JobView/sample-dye.png" Width="39" />
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs
index 05736be7b..77253e286 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml.cs
@@ -13,6 +13,8 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.BL.Entities;
+using Tango.Core.DI;
+using Tango.PPC.Jobs.ViewContracts;
using Tango.PPC.Jobs.ViewModels;
using static Tango.SharedUI.Controls.NavigationControl;
@@ -21,7 +23,7 @@ namespace Tango.PPC.Jobs.Views
/// <summary>
/// Interaction logic for JobView.xaml
/// </summary>
- public partial class JobView : UserControl ,INavigationView
+ public partial class JobView : UserControl ,INavigationView, IJobView
{
private JobViewVM _vm;
@@ -33,6 +35,8 @@ namespace Tango.PPC.Jobs.Views
{
_vm = DataContext as JobViewVM;
};
+
+ TangoIOC.Default.Register<IJobView>(this);
}
public void OnNavigated()
@@ -44,5 +48,12 @@ namespace Tango.PPC.Jobs.Views
{
_vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop);
}
+
+ public async void DisplaySampleDye()
+ {
+ expander_sample_dye.IsExpanded = true;
+ await Task.Delay(500);
+ scrollViewer.ScrollToElement(expander_sample_dye);
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
index 13dc1ac33..1b2f298ce 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs
@@ -192,6 +192,9 @@ namespace Tango.PPC.Common
/// <summary>
/// Called when the instance of IPPCView is available.
/// </summary>
- public abstract void OnViewAttached();
+ public virtual void OnViewAttached()
+ {
+
+ }
}
} \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs
index 8bca1218f..a465c02a4 100644
--- a/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs
+++ b/Software/Visual_Studio/Tango.BL/EntitiesExtensions/Job.cs
@@ -41,6 +41,18 @@ namespace Tango.BL.Entities
#region Properties
+ private bool _isSample;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is a sample dye.
+ /// </summary>
+ [NotMapped]
+ [JsonIgnore]
+ public bool IsSample
+ {
+ get { return _isSample; }
+ set { _isSample = value; RaisePropertyChangedAuto(); }
+ }
+
/// <summary>
/// Gets the total job segments length.
/// </summary>
diff --git a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
index e79a89acd..50b892552 100644
--- a/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
+++ b/Software/Visual_Studio/Tango.Core/DI/TangoIOC.cs
@@ -72,7 +72,7 @@ namespace Tango.Core.DI
/// <param name="instance">The instance.</param>
public void Register<T>(T instance) where T : class
{
- RegisterInternal(typeof(T), typeof(T), instance);
+ RegisterInternal(typeof(T), instance.GetType(), instance);
}
/// <summary>
@@ -154,6 +154,17 @@ namespace Tango.Core.DI
}
/// <summary>
+ /// Notifies the awaiting retrievals of a new instance available.
+ /// </summary>
+ /// <param name="registeredType">Type of the registered.</param>
+ private void NotifyAwaitingRetrievals(RegisteredType registeredType)
+ {
+ var toNotify = _waitingRetrivals.Where(x => x.Item1 == registeredType.InterfaceType).ToList();
+ toNotify.ForEach(x => x.Item2(registeredType.Instance));
+ _waitingRetrivals.RemoveAll(x => toNotify.Contains(x));
+ }
+
+ /// <summary>
/// Gets the instance by the specified type.
/// </summary>
/// <param name="type">The type.</param>
@@ -168,11 +179,7 @@ namespace Tango.Core.DI
if (registeredType.Instance == null)
{
registeredType.Instance = CreateInstance(registeredType.ImplementationType);
-
- //Notify waiting retrievals.
- var toNotify = _waitingRetrivals.Where(x => x.Item1 == registeredType.InterfaceType).ToList();
- toNotify.ForEach(x => x.Item2(registeredType.Instance));
- _waitingRetrivals.RemoveAll(x => toNotify.Contains(x));
+ NotifyAwaitingRetrievals(registeredType);
}
return registeredType.Instance;
@@ -269,7 +276,14 @@ namespace Tango.Core.DI
throw new InvalidOperationException(String.Format("Instance type '{0}' does not match the implementation type '{1}'.", instance.GetType().Name, implementationType.Name));
}
- _registeredTypes.Add(interfaceType, new RegisteredType(interfaceType, implementationType, instance));
+
+ var registeredType = new RegisteredType(interfaceType, implementationType, instance);
+ _registeredTypes.Add(interfaceType, registeredType);
+
+ if (registeredType.Instance != null)
+ {
+ NotifyAwaitingRetrievals(registeredType);
+ }
}
/// <summary>