aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-07-08 09:45:46 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-07-08 09:45:46 +0300
commita2cf6c8d62083a63ee193a1cd206ab345368b242 (patch)
tree4f653018e4fb5b4ad806e9d410800489afe411e5 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs
parentc8807df7010acb129997cb7ca130e6b7928ce809 (diff)
parentf4688d6113dc33deac114bd6999967fec246b8c0 (diff)
downloadTango-a2cf6c8d62083a63ee193a1cd206ab345368b242.tar.gz
Tango-a2cf6c8d62083a63ee193a1cd206ab345368b242.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs79
1 files changed, 56 insertions, 23 deletions
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 50ea04272..260670e08 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
@@ -21,6 +21,7 @@ using Tango.BL.Catalogs;
using System.Runtime.InteropServices;
using System.Threading;
using Tango.BL.ColorConversion;
+using Tango.SharedUI.Helpers;
namespace Tango.PPC.Jobs.ViewModels
{
@@ -33,6 +34,7 @@ namespace Tango.PPC.Jobs.ViewModels
private ObservablesContext _db;
private bool _can_navigate_back;
private Thread _check_gamut_thread;
+ private Job _job_to_load;
#region Properties
@@ -406,25 +408,7 @@ namespace Tango.PPC.Jobs.ViewModels
/// <param name="message">The message.</param>
private void HandleJobSelectedMessage(JobSelectedMessage message)
{
- if (_db != null)
- {
- _db.Dispose();
- }
-
- _db = ObservablesContext.CreateDefault();
- Job = _db.Jobs.SingleOrDefault(x => x.Guid == message.Job.Guid);
- Rmls = _db.Rmls.ToList();
- ColorSpaces = _db.ColorSpaces.ToList();
- SpoolTypes = _db.SpoolTypes.ToList();
- Customers = _db.Customers.Where(x => x.OrganizationGuid == Job.Machine.Organization.Guid).ToList();
-
- SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments);
- SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending));
-
- if (!_check_gamut_thread.IsAlive)
- {
- _check_gamut_thread.Start();
- }
+ _job_to_load = message.Job;
}
#endregion
@@ -442,10 +426,47 @@ namespace Tango.PPC.Jobs.ViewModels
/// <summary>
/// Called when the navigation system has navigated to this VM view.
/// </summary>
- public override void OnNavigatedTo()
+ public async override void OnNavigatedTo()
{
+ NotificationProvider.SetGlobalBusyMessage("Loading job details...");
+
_can_navigate_back = false;
base.OnNavigatedTo();
+
+ if (_db != null)
+ {
+ _db.Dispose();
+ }
+
+ _db = ObservablesContext.CreateDefault();
+ Job = await _db.Jobs.SingleOrDefaultAsync(x => x.Guid == _job_to_load.Guid);
+ Rmls = await _db.Rmls.ToListAsync();
+ ColorSpaces = await _db.ColorSpaces.ToListAsync();
+ SpoolTypes = await _db.SpoolTypes.ToListAsync();
+ Customers = await _db.Customers.Where(x => x.OrganizationGuid == ApplicationManager.Machine.OrganizationGuid).ToListAsync();
+
+ //if (!_check_gamut_thread.IsAlive)
+ //{
+ // _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));
+
+ InvokeUIOnIdle(() =>
+ {
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ });
}
/// <summary>
@@ -453,10 +474,22 @@ namespace Tango.PPC.Jobs.ViewModels
/// Return false to abort the navigation.
/// </summary>
/// <returns></returns>
- public override Task<bool> OnNavigateOutRequest()
+ public async override Task<bool> OnNavigateOutRequest()
{
- if (_can_navigate_back) return Task.FromResult(true);
- return NotificationProvider.ShowQuestion("Are you sure you want to exit this job?");
+ bool result = true;
+
+ if (!_can_navigate_back)
+ {
+ result = await NotificationProvider.ShowQuestion("Are you sure you want to exit this job?");
+ }
+
+ if (result)
+ {
+ Job = null;
+ SegmentsCollectionView = null;
+ }
+
+ return result;
}
#endregion