aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-11-25 18:41:28 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-11-25 18:41:28 +0200
commitab4d7232c388a10224a642fe210b30670f91e574 (patch)
tree75b7349a23f5db0c682dcce2ba87a85a18409b42 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels
parent80ed2914882d82dce0f60c09185da6a500f78d8b (diff)
parent03180d26af65c24822cf5ffd44a347db7394d3b2 (diff)
downloadTango-ab4d7232c388a10224a642fe210b30670f91e574.tar.gz
Tango-ab4d7232c388a10224a642fe210b30670f91e574.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs61
2 files changed, 62 insertions, 1 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 874beba75..6b2a610b3 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
@@ -967,7 +967,7 @@ namespace Tango.PPC.Jobs.ViewModels
{
Thread.Sleep(500);
- if (Job != null && IsVisible && (Job.ColorSpace != null && Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32()))
+ if (Job != null && IsVisible && (Job.ColorSpace != null && (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() || Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.LAB.ToInt32())))
{
var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.Corrected && !x.OutOfGamutChecked).ToList();
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
index c4bd1f5b8..2f22e2f2d 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs
@@ -22,6 +22,11 @@ using Tango.PPC.Jobs.Views;
using System.Data.Entity;
using Tango.BL.Builders;
using Tango.PPC.Jobs.NavigationObjects;
+using Tango.PPC.Storage;
+using Tango.Explorer;
+using System.IO;
+using Google.Protobuf;
+using Tango.PMR.Exports;
namespace Tango.PPC.Jobs.ViewModels
{
@@ -137,6 +142,11 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public RelayCommand CloneJobsCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the export job command.
+ /// </summary>
+ public RelayCommand ExportJobCommand { get; set; }
+
#endregion
#region Constructors
@@ -162,6 +172,7 @@ namespace Tango.PPC.Jobs.ViewModels
AddJobCommand = new RelayCommand(AddNewJob);
DeleteJobsCommand = new RelayCommand(() => DeleteJobs(SelectedJobs));
CloneJobsCommand = new RelayCommand(() => CloneJobs(SelectedJobs));
+ ExportJobCommand = new RelayCommand(ExportJob);
RegisterForMessage<JobRemovedMessage>(HandleJobRemovedMessage);
RegisterForMessage<JobSavedMessage>(HandleJobSavedMessage);
@@ -451,6 +462,56 @@ namespace Tango.PPC.Jobs.ViewModels
public override void OnApplicationReady()
{
base.OnApplicationReady();
+ StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Job.Extension, HandleJobFileLoaded);
+ }
+
+ #endregion
+
+ #region Job Export
+
+ private async void ExportJob()
+ {
+ var selected_job = SelectedJobs.First();
+ ClearSelection();
+
+ var result = await NavigationManager.
+ NavigateForResult<StorageModule,
+ Storage.Views.MainView, ExplorerFileItem,
+ Storage.Models.StorageNavigationRequest>(
+ new Storage.Models.StorageNavigationRequest()
+ {
+ Intent = Storage.Models.StorageNavigationIntent.SaveFile,
+ DefaultFileName = selected_job.Name + ExplorerFileDefinition.Job.Extension,
+ Filter = ExplorerFileDefinition.Job.Extension
+ });
+
+ if (result != null)
+ {
+ var jobFile = await selected_job.ToJobFile();
+
+ using (FileStream fs = new FileStream(result.Path, FileMode.Create))
+ {
+ jobFile.WriteTo(fs);
+ }
+
+ await NotificationProvider.ShowInfo("Job saved.");
+ }
+ }
+
+ #endregion
+
+ #region Handle Job File Loading From Storage
+
+ private async void HandleJobFileLoaded(ExplorerFileItem jobFile)
+ {
+ using (ObservablesContext jobContext = ObservablesContext.CreateDefault())
+ {
+ JobFile jFile = JobFile.Parser.ParseFrom(File.ReadAllBytes(jobFile.Path));
+ var job = await Job.FromJobFile(jFile, MachineProvider.Machine.Guid, AuthenticationProvider.CurrentUser.Guid);
+ jobContext.Jobs.Add(job);
+ await jobContext.SaveChangesAsync();
+ LoadJobs();
+ }
}
#endregion