From 33b515e9151243281506cba38bff963dcd43d41d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 22 Aug 2021 12:43:58 +0300 Subject: Jobs module v2 creation and conditional loading. --- .../PPC/Modules/Tango.PPC.JobsV2/App.xaml | 11 + .../AppBarItems/JobProgressAppBarItem.cs | 43 + .../AppBarItems/JobProgressAppBarItemView.xaml | 29 + .../AppBarItems/JobProgressAppBarItemView.xaml.cs | 30 + .../AppButtons/StartPrintingButton.cs | 26 + .../AppButtons/StopPrintingButton.cs | 17 + .../Tango.PPC.JobsV2/Controls/JobOutlineControl.cs | 326 ++++ .../Controls/JobSummeryViewer.xaml | 120 ++ .../Controls/JobSummeryViewer.xaml.cs | 68 + .../Controls/RunningJobViewer.xaml | 122 ++ .../Controls/RunningJobViewer.xaml.cs | 79 + .../Controls/TwineCatalogViewer.xaml | 27 + .../Controls/TwineCatalogViewer.xaml.cs | 98 ++ .../Converters/ColorSpaceToImageConverter.cs | 43 + .../Converters/ColorSpaceToVisibilityConverter.cs | 43 + .../Converters/JobProgressToPositionConverter.cs | 36 + .../Converters/JobToEmbroideryImageConverter.cs | 38 + .../Converters/JobToPieImageConverter.cs | 40 + .../Converters/JobTypeToImageConverter.cs | 37 + .../Converters/JobsCategoryToOpacityConverter.cs | 27 + .../JobsCategoryToVisibilityConverter.cs | 28 + .../Dialogs/AdvancedColorCorrectionView.xaml | 178 +++ .../Dialogs/AdvancedColorCorrectionView.xaml.cs | 30 + .../Dialogs/AdvancedColorCorrectionViewVM.cs | 19 + .../Dialogs/BasicColorCorrectionView.xaml | 162 ++ .../Dialogs/BasicColorCorrectionView.xaml.cs | 33 + .../Dialogs/BasicColorCorrectionViewVM.cs | 101 ++ .../Dialogs/CatalogSelectionView.xaml | 71 + .../Dialogs/CatalogSelectionView.xaml.cs | 34 + .../Dialogs/CatalogSelectionViewVM.cs | 51 + .../Dialogs/ColorProfileReceivedView.xaml | 41 + .../Dialogs/ColorProfileReceivedView.xaml.cs | 28 + .../Dialogs/ColorProfileReceivedViewVM.cs | 71 + .../Dialogs/FineTuningPaletteView.xaml | 113 ++ .../Dialogs/FineTuningPaletteView.xaml.cs | 33 + .../Dialogs/FineTuningPaletteViewVM.cs | 102 ++ .../Dialogs/ImportColorProfileView.xaml | 35 + .../Dialogs/ImportColorProfileView.xaml.cs | 28 + .../Dialogs/ImportColorProfileViewVM.cs | 16 + .../Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml | 38 + .../Dialogs/ImportCsvJobView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Dialogs/ImportCsvJobViewVM.cs | 76 + .../Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml | 25 + .../Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Dialogs/ImportJobViewVM.cs | 20 + .../Dialogs/ImportTwnFileView.xaml | 28 + .../Dialogs/ImportTwnFileView.xaml.cs | 28 + .../Dialogs/ImportTwnFileViewVM.cs | 17 + .../Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml | 109 ++ .../Dialogs/JobCreationView.xaml.cs | 34 + .../Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs | 66 + .../Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml | 32 + .../Dialogs/SpoolChangeView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Dialogs/SpoolChangeViewVM.cs | 20 + .../Images/Coats/coats-sylko-logo.png | Bin 0 -> 8189 bytes .../Tango.PPC.JobsV2/Images/Coats/coats.png | Bin 0 -> 971 bytes .../Tango.PPC.JobsV2/Images/Coats/thread.png | Bin 0 -> 5682 bytes .../Modules/Tango.PPC.JobsV2/Images/Embroider.png | Bin 0 -> 90271 bytes .../Modules/Tango.PPC.JobsV2/Images/Embroidery.png | Bin 0 -> 38479 bytes .../Tango.PPC.JobsV2/Images/Job Issues/cyan.png | Bin 0 -> 1905 bytes .../Images/JobProgressView/clock.png | Bin 0 -> 536 bytes .../Images/JobProgressView/drop.png | Bin 0 -> 516 bytes .../Images/JobView/additional-tools.png | Bin 0 -> 1159 bytes .../Images/JobView/color-fine-tuning.png | Bin 0 -> 1890 bytes .../Images/JobView/color-length.png | Bin 0 -> 2619 bytes .../Images/JobView/color-picker.png | Bin 0 -> 1376 bytes .../Tango.PPC.JobsV2/Images/JobView/delete.png | Bin 0 -> 420 bytes .../Tango.PPC.JobsV2/Images/JobView/error.png | Bin 0 -> 428 bytes .../Images/JobView/job-details.png | Bin 0 -> 1164 bytes .../Images/JobView/job-summary.png | Bin 0 -> 1836 bytes .../Tango.PPC.JobsV2/Images/JobView/output.png | Bin 0 -> 2255 bytes .../Tango.PPC.JobsV2/Images/JobView/remove.png | Bin 0 -> 313 bytes .../Images/JobView/replace-color.png | Bin 0 -> 1148 bytes .../Tango.PPC.JobsV2/Images/JobView/sample-dye.png | Bin 0 -> 2120 bytes .../Tango.PPC.JobsV2/Images/JobView/settings.png | Bin 0 -> 857 bytes .../Images/JobView/transparent.jpg | Bin 0 -> 27097 bytes .../Images/JobView/transparent_small.jpg | Bin 0 -> 10743 bytes .../Images/JobView/twine-catalog.png | Bin 0 -> 1408 bytes .../Modules/Tango.PPC.JobsV2/Images/Knitting.png | Bin 0 -> 42273 bytes .../Tango.PPC.JobsV2/Images/NewJob/coats.png | Bin 0 -> 1019 bytes .../Modules/Tango.PPC.JobsV2/Images/NewJob/lab.png | Bin 0 -> 1011 bytes .../Modules/Tango.PPC.JobsV2/Images/NewJob/rgb.png | Bin 0 -> 1468 bytes .../Tango.PPC.JobsV2/Images/NewJob/twine.png | Bin 0 -> 798 bytes .../Tango.PPC.JobsV2/Images/NewJob/volume.png | Bin 0 -> 1857 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/Sewing.png | Bin 0 -> 30800 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/arrows.png | Bin 0 -> 472 bytes .../Tango.PPC.JobsV2/Images/color-picker.png | Bin 0 -> 1171 bytes .../Images/color_approved_small.png | Bin 0 -> 1560 bytes .../Images/color_approved_small_gray.png | Bin 0 -> 1371 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/csv.png | Bin 0 -> 2613 bytes .../Modules/Tango.PPC.JobsV2/Images/emb-file.png | Bin 0 -> 2588 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/job.png | Bin 0 -> 6419 bytes .../Tango.PPC.JobsV2/Images/jobs-module.png | Bin 0 -> 1664 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/jobs.png | Bin 0 -> 767 bytes .../Images/large-cards-view - blue.png | Bin 0 -> 891 bytes .../Tango.PPC.JobsV2/Images/large-cards-view.png | Bin 0 -> 306 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/length.png | Bin 0 -> 504 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/liquid.png | Bin 0 -> 1043 bytes .../Modules/Tango.PPC.JobsV2/Images/pantone.png | Bin 0 -> 5717 bytes .../Tango.PPC.JobsV2/Images/pencil-blue.png | Bin 0 -> 434 bytes .../Tango.PPC.JobsV2/Images/pencil-gray.png | Bin 0 -> 422 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/plus.png | Bin 0 -> 133 bytes .../Images/sample_approved_small.png | Bin 0 -> 1559 bytes .../Images/sample_approved_small_gray.png | Bin 0 -> 1414 bytes .../Images/small-cards-view - blue.png | Bin 0 -> 860 bytes .../Tango.PPC.JobsV2/Images/small-cards-view.png | Bin 0 -> 370 bytes .../Modules/Tango.PPC.JobsV2/Images/snapmatch.png | Bin 0 -> 181461 bytes .../Tango.PPC.JobsV2/Images/spool_change.png | Bin 0 -> 8111 bytes .../Tango.PPC.JobsV2/Images/spool_replace.png | Bin 0 -> 46011 bytes .../PPC/Modules/Tango.PPC.JobsV2/Images/sync.png | Bin 0 -> 4127 bytes .../Modules/Tango.PPC.JobsV2/Images/sync_job.png | Bin 0 -> 6743 bytes .../Modules/Tango.PPC.JobsV2/Images/warning.png | Bin 0 -> 603 bytes .../Modules/Tango.PPC.JobsV2/JobsModuleSettings.cs | 86 + .../PPC/Modules/Tango.PPC.JobsV2/JobsV2Module.cs | 84 + .../Messages/JobSelectedMessage.cs | 26 + .../Messages/NavigatedToJobsModuleMessage.cs | 12 + .../NavigationObjects/JobNavigationObject.cs | 36 + .../JobSummeryNavigationObject.cs | 16 + .../TwineCatalogNavigationObject.cs | 15 + .../NewSynchronizardJobsNotificationItem.cs | 32 + .../NewSynchronizardJobsNotificationItemView.xaml | 30 + ...ewSynchronizardJobsNotificationItemView.xaml.cs | 30 + .../Tango.PPC.JobsV2/Properties/AssemblyInfo.cs | 20 + .../Properties/Resources.Designer.cs | 62 + .../Tango.PPC.JobsV2/Properties/Resources.resx | 117 ++ .../Properties/Settings.Designer.cs | 30 + .../Tango.PPC.JobsV2/Properties/Settings.settings | 7 + .../Modules/Tango.PPC.JobsV2/Resources/Styles.xaml | 48 + .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 526 +++++++ .../Tango.PPC.JobsV2/ViewContracts/IJobView.cs | 31 + .../Tango.PPC.JobsV2/ViewContracts/IJobsView.cs | 14 + .../Modules/Tango.PPC.JobsV2/ViewModelLocator.cs | 92 ++ .../ViewModels/JobProgressViewVM.cs | 259 +++ .../ViewModels/JobSummeryViewVM.cs | 192 +++ .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 1650 ++++++++++++++++++++ .../Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs | 1073 +++++++++++++ .../Tango.PPC.JobsV2/ViewModels/MainViewVM.cs | 168 ++ .../ViewModels/TwineCatalogViewVM.cs | 185 +++ .../Tango.PPC.JobsV2/Views/JobProgressView.xaml | 232 +++ .../Tango.PPC.JobsV2/Views/JobProgressView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Views/JobSummeryView.xaml | 111 ++ .../Tango.PPC.JobsV2/Views/JobSummeryView.xaml.cs | 28 + .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml | 1242 +++++++++++++++ .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs | 135 ++ .../Modules/Tango.PPC.JobsV2/Views/JobsView.xaml | 355 +++++ .../Tango.PPC.JobsV2/Views/JobsView.xaml.cs | 63 + .../Modules/Tango.PPC.JobsV2/Views/MainView.xaml | 22 + .../Tango.PPC.JobsV2/Views/MainView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Views/TwineCatalogView.xaml | 42 + .../Views/TwineCatalogView.xaml.cs | 28 + .../PPC/Modules/Tango.PPC.JobsV2/app.config | 97 ++ .../PPC/Modules/Tango.PPC.JobsV2/packages.config | 7 + .../Tango.PPC.MachineSettings/Views/MainView.xaml | 5 + 153 files changed, 10275 insertions(+) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/App.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItem.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StartPrintingButton.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StopPrintingButton.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobOutlineControl.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToImageConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobProgressToPositionConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToEmbroideryImageConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToPieImageConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobTypeToImageConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToOpacityConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats-sylko-logo.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/thread.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroider.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroidery.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Job Issues/cyan.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/clock.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/drop.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/additional-tools.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-fine-tuning.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-length.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-picker.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/delete.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/error.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-details.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-summary.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/output.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/remove.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/replace-color.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/sample-dye.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/settings.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent.jpg create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent_small.jpg create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/twine-catalog.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Knitting.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/coats.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/lab.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/rgb.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/twine.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/volume.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Sewing.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/arrows.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color-picker.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small_gray.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/csv.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/emb-file.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/job.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs-module.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view - blue.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/length.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/liquid.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pantone.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-blue.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-gray.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/plus.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small_gray.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view - blue.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/snapmatch.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_change.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_replace.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync_job.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/warning.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsModuleSettings.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsV2Module.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/JobSelectedMessage.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/NavigatedToJobsModuleMessage.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobNavigationObject.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobSummeryNavigationObject.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/TwineCatalogNavigationObject.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItem.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.resx create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.settings create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resources/Styles.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobView.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobsView.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobProgressViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobSummeryViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/TwineCatalogViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/app.config create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/App.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/App.xaml new file mode 100644 index 000000000..c8281a6e6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/App.xaml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItem.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItem.cs new file mode 100644 index 000000000..c43448a82 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItem.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.Jobs.AppBarItems +{ + /// + /// Represents a job progress . + /// + /// + public class JobProgressAppBarItem : AppBarItem + { + /// + /// Gets or sets the machine provider. + /// + [TangoInject] + public IMachineProvider MachineProvider { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public JobProgressAppBarItem() + { + TangoIOC.Default.Inject(this); + } + + /// + /// Gets or sets the view type. + /// + public override Type ViewType + { + get + { + return typeof(JobProgressAppBarItemView); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml new file mode 100644 index 000000000..16c6a42be --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml @@ -0,0 +1,29 @@ + + + + + + + + + Completed + /m + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml.cs new file mode 100644 index 000000000..f0ba3b77d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppBarItems/JobProgressAppBarItemView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.AppBarItems +{ + /// + /// Represents the view. + /// + /// + /// + public partial class JobProgressAppBarItemView : UserControl + { + public JobProgressAppBarItemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StartPrintingButton.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StartPrintingButton.cs new file mode 100644 index 000000000..4d6050639 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StartPrintingButton.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.PPC.Common.Notifications; + +namespace Tango.PPC.Jobs.AppButtons +{ + public class StartPrintingButton : AppButton + { + public StartPrintingButton(RelayCommand command, IMachineOperator op) : base("DYE", command) + { + op.StatusChanged += Op_StatusChanged; + + Op_StatusChanged(op, op.Status); + } + + private void Op_StatusChanged(object sender, MachineStatuses status) + { + IsEnabled = (sender as IMachineOperator).CanPrint; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StopPrintingButton.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StopPrintingButton.cs new file mode 100644 index 000000000..d9ef86861 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/AppButtons/StopPrintingButton.cs @@ -0,0 +1,17 @@ +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.AppButtons +{ + public class StopPrintingButton : AppButton + { + public StopPrintingButton() : base("STOP", true) + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobOutlineControl.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobOutlineControl.cs new file mode 100644 index 000000000..385f488ba --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobOutlineControl.cs @@ -0,0 +1,326 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Shapes; +using Tango.PMR.Printing; +using Tango.Touch.Controls; + +namespace Tango.PPC.Jobs +{ + public class JobOutlineControl : Control + { + #region Members + + private Size _sizeControl = new Size(0, 0); + ScrollViewer _parentScrollViewer = null; + public struct LevelOffset + { + public const double level_0 = 0.0; + public const double level_1 = 10.0; + public const double level_2 = 20.0; + public const double level_3 = 37.0; + public const double level_4 = 50.0; + public const double level_5 = 60.0; + public const double level_6 = 77.0; + public const double level_7 = 90.0; + public const double level_8 = 100.0; + } + private double _verticalOffset = 0; + private double _viewportHeight = 0; + private const double HEADER_FONT_HEIGHT = 35; + private const double TITLE_FONT_HEIGHT = 22; + private const double SUB_TITLE_FONT_HEIGHT = 19; + private const double NORMAL_FONT_HEIGHT = 17; + private const double WIDTH = 330; + + #endregion members + + public JobOutlineControl() : base() + { + DataContextChanged += JobOutlineControl_DataContextChanged; + Width = WIDTH; + } + + private void JobOutlineControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (DataContext == null) + { + return; + } + + if (_parentScrollViewer != null) + { + _parentScrollViewer.ScrollToTop(); + } + + InvalidateVisual(); + } + + #region events + + private void ScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) + { + if (e.VerticalChange == 0.0) + return; + + _verticalOffset = _parentScrollViewer.VerticalOffset; + _viewportHeight = _parentScrollViewer.ViewportHeight; + InvalidateVisual(); + } + #endregion events + + #region render + protected override void OnRender(DrawingContext drawingContext) + { + base.OnRender(drawingContext); + + if (!(DataContext is JobTicket job)) return; + if (_parentScrollViewer == null) + { + _parentScrollViewer = this.FindAncestor(); + _parentScrollViewer.ScrollChanged -= ScrollViewer_ScrollChanged; + _parentScrollViewer.ScrollChanged += ScrollViewer_ScrollChanged; + } + else if (_viewportHeight == 0) + { + _viewportHeight = _parentScrollViewer.ActualHeight; + } + _sizeControl = new Size(); + _sizeControl.Height += 10; + DrawHeaderText(drawingContext, "JOB OUTLINE", 30, LevelOffset.level_0); + _sizeControl.Height += HEADER_FONT_HEIGHT; + + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "BASIC", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + var basicProps = GetNameValueList(job); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + //JobTicket.Spool + if (job.Spool != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "SPOOL", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.Spool); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + //JobTicket.ProcessParameters + if (job.ProcessParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "PROCESS PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.ProcessParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + //JobTicket.ThreadParameters + if (job.ThreadParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "THREAD PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.ThreadParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + //JobTicket.HeadCleaningParameters + if (job.HeadCleaningParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "HEAD CLEANING PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.HeadCleaningParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + //JobTicket.BtsrParameters + if (job.BtsrParameters != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "BTSR PARAMETERS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 5.0; + basicProps = GetNameValueList(job.BtsrParameters); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_1, TouchIconKind.Settings); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + //JobTicket.Segments + if (job.Segments != null) + { + _sizeControl.Height += 20; + DrawHeaderText(drawingContext, "SEGMENTS", 17, LevelOffset.level_0); + _sizeControl.Height += TITLE_FONT_HEIGHT; + _sizeControl.Height += 10.0; + int index = 0; + foreach (JobSegment seg in job.Segments) + { + DrawHeaderText(drawingContext, string.Format("#{0} SEGMENT", ++index), 14, LevelOffset.level_1); + _sizeControl.Height += SUB_TITLE_FONT_HEIGHT; + basicProps = GetNameValueList(seg); + foreach (var prop in basicProps) + { + DrawNameValueText(drawingContext, prop, LevelOffset.level_2, TouchIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + //BrushStops + DrawHeaderText(drawingContext, "BRUSH STOPS", 12, LevelOffset.level_3); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + int indexBrush = 0; + foreach (JobBrushStop brushstop in seg.BrushStops) + { + _sizeControl.Height += 5.0; + DrawHeaderText(drawingContext, string.Format("#{0} STOP", ++indexBrush), 11, LevelOffset.level_4); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + var brushStops = GetNameValueList(brushstop); + foreach (var brushstopprop in brushStops) + { + DrawNameValueText(drawingContext, brushstopprop, LevelOffset.level_5, TouchIconKind.Pencil); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + DrawHeaderText(drawingContext, "DISPENSERS", 12, LevelOffset.level_6); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + _sizeControl.Height += 5.0; + int indexDispenser = 0; + foreach (JobDispenser disp in brushstop.Dispensers) + { + DrawHeaderText(drawingContext, string.Format("#{0} DISPENSER", ++indexDispenser), 11, LevelOffset.level_6); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + var dispProperties = GetNameValueList(disp); + foreach (var dispprop in dispProperties) + { + DrawNameValueText(drawingContext, dispprop, LevelOffset.level_7, TouchIconKind.ArrowRightBoldCircle); + _sizeControl.Height += NORMAL_FONT_HEIGHT; + } + } + } + } + } + + if (Height != _sizeControl.Height) + { + Height = _sizeControl.Height; + } + } + public IEnumerable> GetNameValueList(object value) + { + if (value != null) + { + var properties = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => (!x.PropertyType.IsClass && !typeof(IEnumerable).IsAssignableFrom(x.PropertyType)) || x.PropertyType == typeof(String)).ToList(); + return properties.Select(x => new Tuple(x.Name, x.GetValue(value).ToString())); + } + else + { + return null; + } + } + #endregion render + + #region drawing + protected void DrawNameValueText(DrawingContext drawingContext, Tuple text, double levelOfOffset, TouchIconKind? icon) + { + if (IsInViewPort()) + { + FormattedText formattedName = new FormattedText(text.Item1 + ": ", System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), + 12, Foreground); + DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedName, icon); + double widthOfNameText = formattedName.WidthIncludingTrailingWhitespace + 17 + levelOfOffset;//17 pix for draw icon before text + + FormattedText formattedValue = new FormattedText(text.Item2, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), + 12, Foreground); + DrawIconTextIfVisible(drawingContext, widthOfNameText, formattedValue); + _sizeControl.Width = Math.Max(_sizeControl.Width, (widthOfNameText + formattedValue.WidthIncludingTrailingWhitespace)); + } + } + + private bool IsInViewPort() + { + return (_sizeControl.Height >= _verticalOffset && _sizeControl.Height <= (_verticalOffset + _viewportHeight + 5)); + } + + protected void DrawHeaderText(DrawingContext drawingContext, string text, int fontSize, double levelOfOffset) + { + if (IsInViewPort()) + { + FormattedText formattedtext = new FormattedText(text, System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(this.FontFamily, FontStyles.Normal, FontWeights.SemiBold, FontStretches.Normal), + fontSize, Foreground); + DrawIconTextIfVisible(drawingContext, levelOfOffset, formattedtext); + _sizeControl.Width = Math.Max(_sizeControl.Width, (formattedtext.Width + levelOfOffset)); + } + } + + private void DrawIconTextIfVisible(DrawingContext drawingContext, double levelOfOffset, FormattedText formattedText, TouchIconKind? icon = null) + { + if (icon is TouchIconKind) + { + DrawIcon(drawingContext, (TouchIconKind)icon, new Point(levelOfOffset, _sizeControl.Height)); + levelOfOffset += 17; + } + drawingContext.DrawText(formattedText, new Point(levelOfOffset, _sizeControl.Height)); + } + private void DrawIcon(DrawingContext drawingContext, TouchIconKind kind, Point point) + { + GeometryGroup group = GetGeometryByIcon(kind); + SetGeometryPosition(group, point); + drawingContext.DrawGeometry(Foreground, new Pen(Brushes.White, 1), group); + + } + private GeometryGroup GetGeometryByIcon(TouchIconKind kind) + { + Geometry geometry = Geometry.Parse(TouchIcon.Icons[kind]); + GeometryGroup group = new GeometryGroup(); + group.Children.Add(geometry); + + TransformGroup tg = new TransformGroup(); + tg.Children.Add(new ScaleTransform() + { + ScaleX = 10d / geometry.Bounds.Width, + ScaleY = 10d / geometry.Bounds.Height, + }); + tg.Children.Add(new TranslateTransform() { }); + + group.Transform = tg; + return group; + } + private void SetGeometryPosition(GeometryGroup group, Point point) + { + TransformGroup tg = group.Transform as TransformGroup; + (tg.Children[1] as TranslateTransform).X = point.X; + (tg.Children[1] as TranslateTransform).Y = point.Y + 1; + } + #endregion drawing + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml new file mode 100644 index 000000000..bd0bbfd11 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml.cs new file mode 100644 index 000000000..c977e71d0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/JobSummeryViewer.xaml.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Controls +{ + /// + /// Represents a summary viewer control. + /// + /// + /// + public partial class JobSummeryViewer : UserControl + { + + /// + /// Gets or sets the job. + /// + public Job Job + { + get { return (Job)GetValue(JobProperty); } + set { SetValue(JobProperty, value); } + } + public static readonly DependencyProperty JobProperty = + DependencyProperty.Register("Job", typeof(Job), typeof(JobSummeryViewer), new PropertyMetadata(null)); + + /// + /// Maybe not necessary! + /// + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + public static readonly DependencyProperty IsActiveProperty = + DependencyProperty.Register("IsActive", typeof(bool), typeof(JobSummeryViewer), new PropertyMetadata(false)); + + /// + /// Gets or sets a value indicating whether to display summery markers. + /// + public bool DisplayMarkers + { + get { return (bool)GetValue(DisplayMarkersProperty); } + set { SetValue(DisplayMarkersProperty, value); } + } + public static readonly DependencyProperty DisplayMarkersProperty = + DependencyProperty.Register("DisplayMarkers", typeof(bool), typeof(JobSummeryViewer), new PropertyMetadata(true)); + + /// + /// Initializes a new instance of the class. + /// + public JobSummeryViewer() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml new file mode 100644 index 000000000..5d3f3f1fc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml.cs new file mode 100644 index 000000000..133a60bbd --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/RunningJobViewer.xaml.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Entities; +using Tango.Integration.Operation; + +namespace Tango.PPC.Jobs.Controls +{ + /// + /// Represents a running viewer control. + /// + /// + /// + public partial class RunningJobViewer : UserControl + { + /// + /// Maybe not necessary! + /// + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + public static readonly DependencyProperty IsActiveProperty = + DependencyProperty.Register("IsActive", typeof(bool), typeof(RunningJobViewer), new PropertyMetadata(false)); + + /// + /// Gets or sets a value indicating whether summary markers. + /// + public bool DisplayMarkers + { + get { return (bool)GetValue(DisplayMarkersProperty); } + set { SetValue(DisplayMarkersProperty, value); } + } + public static readonly DependencyProperty DisplayMarkersProperty = + DependencyProperty.Register("DisplayMarkers", typeof(bool), typeof(RunningJobViewer), new PropertyMetadata(true)); + + /// + /// Gets or sets the job. + /// + public Job Job + { + get { return (Job)GetValue(JobProperty); } + set { SetValue(JobProperty, value); } + } + public static readonly DependencyProperty JobProperty = + DependencyProperty.Register("Job", typeof(Job), typeof(RunningJobViewer), new PropertyMetadata(null)); + + /// + /// Gets or sets the running job status. + /// + public RunningJobStatus RunningJobStatus + { + get { return (RunningJobStatus)GetValue(RunningJobStatusProperty); } + set { SetValue(RunningJobStatusProperty, value); } + } + public static readonly DependencyProperty RunningJobStatusProperty = + DependencyProperty.Register("RunningJobStatus", typeof(RunningJobStatus), typeof(RunningJobViewer), new PropertyMetadata(null)); + + /// + /// Initializes a new instance of the class. + /// + public RunningJobViewer() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml new file mode 100644 index 000000000..dff1202d8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + CATALOG + RECENT + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs new file mode 100644 index 000000000..929e9cd76 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Controls/TwineCatalogViewer.xaml.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Controls +{ + /// + /// Represents a twine viewer control. + /// + /// + /// + public partial class TwineCatalogViewer : UserControl + { + private ColorCatalog _originalCatalog; + + /// + /// Gets or sets the recent catalog items as a catalog. + /// + public ColorCatalog Recent + { + get { return (ColorCatalog)GetValue(RecentProperty); } + set { SetValue(RecentProperty, value); } + } + public static readonly DependencyProperty RecentProperty = + DependencyProperty.Register("Recent", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + + /// + /// Gets or sets the catalog. + /// + public ColorCatalog Catalog + { + get { return (ColorCatalog)GetValue(CatalogProperty); } + set { SetValue(CatalogProperty, value); } + } + public static readonly DependencyProperty CatalogProperty = + DependencyProperty.Register("Catalog", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + + /// + /// Gets or sets the selected catalog item. + /// + public ColorCatalogsItem SelectedItem + { + get { return (ColorCatalogsItem)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + + /// + /// Gets or sets the current catalog filter. + /// + public String Filter + { + get { return (String)GetValue(FilterProperty); } + set { SetValue(FilterProperty, value); } + } + public static readonly DependencyProperty FilterProperty = + DependencyProperty.Register("Filter", typeof(String), typeof(TwineCatalogViewer), new PropertyMetadata(null,(d,e) => (d as TwineCatalogViewer).OnFilterChanged())); + + /// + /// Called when the filter has been changed + /// + private void OnFilterChanged() + { + if (Filter == "CATALOG" && _originalCatalog != null) + { + Catalog = _originalCatalog; + _originalCatalog = null; + } + else if (Filter == "RECENT") + { + _originalCatalog = Catalog; + Catalog = Recent; + } + } + + /// + /// Initializes a new instance of the class. + /// + public TwineCatalogViewer() + { + InitializeComponent(); + Filter = "CATALOG"; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToImageConverter.cs new file mode 100644 index 000000000..f10bf0064 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToImageConverter.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Enumerations; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Jobs.Converters +{ + public class ColorSpaceToImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + ColorSpaces colorSpace = (ColorSpaces)value; + + switch (colorSpace) + { + case ColorSpaces.RGB: + return ResourceHelper.GetImageFromResources("Images/NewJob/rgb.png"); + case ColorSpaces.LAB: + return ResourceHelper.GetImageFromResources("Images/NewJob/lab.png"); + case ColorSpaces.Catalog: + return ResourceHelper.GetImageFromResources("Images/NewJob/twine.png"); + case ColorSpaces.Volume: + return ResourceHelper.GetImageFromResources("Images/NewJob/volume.png"); + default: + return ResourceHelper.GetImageFromResources("Images/NewJob/coats.png"); + } + } + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToVisibilityConverter.cs new file mode 100644 index 000000000..b1be93793 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorSpaceToVisibilityConverter.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Converters +{ + public class ColorSpaceToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ColorSpace colorSpace = value as ColorSpace; + + if (colorSpace != null) + { + if (String.IsNullOrWhiteSpace(parameter.ToStringSafe())) + { + if (colorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) + { + return Visibility.Collapsed; + } + } + else + { + String[] spaces = parameter.ToString().Split(','); + return spaces.Contains(colorSpace.Space.ToString()) ? Visibility.Visible : Visibility.Collapsed; + } + } + + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobProgressToPositionConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobProgressToPositionConverter.cs new file mode 100644 index 000000000..3ecc3276a --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobProgressToPositionConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Tango.PPC.Jobs.Converters +{ + /// + /// Converts a job progress to X position using the specified UI element width. + /// + /// + public class JobProgressToPositionConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length == 3 && values[1] != DependencyProperty.UnsetValue) + { + double progress = (double)values[0]; + double total = (double)values[1]; + double ui_width = (double)values[2]; + return (progress / total) * ui_width; + } + + return 0d; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToEmbroideryImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToEmbroideryImageConverter.cs new file mode 100644 index 000000000..fce5bedf6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToEmbroideryImageConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobToEmbroideryImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Job job = value as Job; + + if (job != null && job.EmbroideryFileData != null) + { + try + { + return job.EmbroideryJpeg.ToBitmapSource(); + } + catch + { + return null; + } + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToPieImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToPieImageConverter.cs new file mode 100644 index 000000000..4c1a27822 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobToPieImageConverter.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using Tango.BL.Entities; +using System.Media; + +namespace Tango.PPC.Jobs.Converters +{ + /// + /// Converts a job to representing the job segments as a pie chart. + /// + /// + public class JobToPieImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Job job = value as Job; + + if (job != null) + { + String[] param = parameter.ToString().Split(','); + double width = double.Parse(param[0]); + double height = double.Parse(param[1]); + return job.CreateSegmentsPie(width, height); + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobTypeToImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobTypeToImageConverter.cs new file mode 100644 index 000000000..aaa6a5bf2 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobTypeToImageConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Enumerations; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobTypeToImageConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + JobTypes jobType = (JobTypes)value; + + switch (jobType) + { + case JobTypes.Embroidery: + return ResourceHelper.GetImageFromResources("Images/Embroidery.png"); + case JobTypes.Sewing: + return ResourceHelper.GetImageFromResources("Images/Sewing.png"); + case JobTypes.Knitting: + return ResourceHelper.GetImageFromResources("Images/Knitting.png"); + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToOpacityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToOpacityConverter.cs new file mode 100644 index 000000000..0eaad280a --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToOpacityConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using static Tango.PPC.Jobs.ViewModels.JobsViewVM; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobsCategoryToOpacityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + JobsCategory selected = (JobsCategory)Enum.Parse(typeof(JobsCategory), parameter.ToString()); + JobsCategory category = (JobsCategory)value; + + return category.Equals(selected) ? 1 : 0; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToVisibilityConverter.cs new file mode 100644 index 000000000..e602a99fc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/JobsCategoryToVisibilityConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using static Tango.PPC.Jobs.ViewModels.JobsViewVM; + +namespace Tango.PPC.Jobs.Converters +{ + public class JobsCategoryToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + JobsCategory selected = (JobsCategory)Enum.Parse(typeof(JobsCategory), parameter.ToString()); + JobsCategory category = (JobsCategory)value; + + return category.Equals(selected) ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml new file mode 100644 index 000000000..da6989ff6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + , + , + + + + + + + , + , + + + + + + + + + + + + + + + + + + + + + + + , + + + + + + + + + + + + + + + + Twine Catalog + + + + + OK + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml.cs new file mode 100644 index 000000000..68e53d7af --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the Hive color correction dialog. + /// + /// + /// + public partial class AdvancedColorCorrectionView : UserControl + { + public AdvancedColorCorrectionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionViewVM.cs new file mode 100644 index 000000000..db8573322 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/AdvancedColorCorrectionViewVM.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.ColorLab; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the Hive color correction ViewModel. + /// + /// + public class AdvancedColorCorrectionViewVM : BasicColorCorrectionViewVM + { + public bool IsOutOfGamut { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml new file mode 100644 index 000000000..bd31b88ce --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + Color is out of range + + + + + + + + + + + + , + , + + + + + + + , + , + + + + + + Please use the closest alternative + + + + + + + + + + + + + + + + + + , + , + + + + + + + , + , + + + + + + + + + + + + + More Options + + + + + OK + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml.cs new file mode 100644 index 000000000..96744ccb3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionView.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the Triplet color conversion dialog. + /// + /// + /// + public partial class BasicColorCorrectionView : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public BasicColorCorrectionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionViewVM.cs new file mode 100644 index 000000000..a6ffb57c3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/BasicColorCorrectionViewVM.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.ColorConversion; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the triplet color conversion dialog ViewModel. + /// + /// + public class BasicColorCorrectionViewVM : DialogViewVM + { + private bool _moreOptions; + + /// + /// Represents a color conversion dialog result. + /// + public enum ColorCorrectionDialogResult + { + None, + Confirmed, + MoreOptions, + } + + /// + /// Gets or sets the invalid brush stop (out of gamut). + /// + public BrushStop InvalidBrushStop { get; set; } + + /// + /// Gets the dialog result. + /// + public ColorCorrectionDialogResult Result { get; private set; } + + /// + /// Gets or sets the suggestions. + /// + public List Suggestions { get; set; } + + + private ColorConversionSuggestion _selectedSuggestion; + /// + /// Gets or sets the selected suggestion. + /// + public ColorConversionSuggestion SelectedSuggestion + { + get { return _selectedSuggestion; } + set { _selectedSuggestion = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the more options command. + /// + public RelayCommand MoreOptionsCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public BasicColorCorrectionViewVM() + { + MoreOptionsCommand = new RelayCommand(() => + { + _moreOptions = true; + Accept(); + }); + } + + /// + /// Invokes the event. + /// + protected override void Accept() + { + Result = _moreOptions ? ColorCorrectionDialogResult.MoreOptions : ColorCorrectionDialogResult.Confirmed; + base.Accept(); + } + + /// + /// Invokes the event. + /// + protected override void Cancel() + { + Result = ColorCorrectionDialogResult.None; + base.Cancel(); + } + + /// + /// Called when the dialog has been shown. + /// + public override void OnShow() + { + base.OnShow(); + SelectedSuggestion = Suggestions.GetCenterSuggestion(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml new file mode 100644 index 000000000..586325515 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + CANCEL + CREATE + + + + Select Catalog + Please select the desired color catalog and press 'create'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml.cs new file mode 100644 index 000000000..65d03e531 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionView.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Enumerations; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the new job creation dialog. + /// + /// + /// + public partial class CatalogSelectionView : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public CatalogSelectionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionViewVM.cs new file mode 100644 index 000000000..0c4cd72f6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/CatalogSelectionViewVM.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents a catalog picker. + /// + /// + public class CatalogSelectionViewVM : DialogViewVM + { + + private ObservableCollection _catalogs; + /// + /// Gets or sets the catalogs. + /// + public ObservableCollection Catalogs + { + get { return _catalogs; } + set { _catalogs = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalog _selectedCatalog; + /// + /// Gets or sets the selected catalog. + /// + public ColorCatalog SelectedCatalog + { + get { return _selectedCatalog; } + set { _selectedCatalog = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + /// The catalogs. + /// The selected catalog. + public CatalogSelectionViewVM(List catalogs, ColorCatalog selectedCatalog) : base() + { + Catalogs = catalogs.ToObservableCollection(); + SelectedCatalog = selectedCatalog; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml new file mode 100644 index 000000000..bc6534596 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml @@ -0,0 +1,41 @@ + + + + + DECLINE + + + + + + + APPROVE + + + + New SnapMatch Color + + A SnapMatch user is trying to send you a color detection result. Press 'Approve' to create a new job from this color. + + + + + Detected Color + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml.cs new file mode 100644 index 000000000..66ed6e334 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ImportJobView.xaml + /// + public partial class ColorProfileReceivedView : UserControl + { + public ColorProfileReceivedView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedViewVM.cs new file mode 100644 index 000000000..1386acb93 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorProfileReceivedViewVM.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Threading; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ColorProfileReceivedViewVM : DialogViewVM + { + private DispatcherTimer _timer; + + public Color Color { get; set; } + + private int _maxSeconds; + public int MaxSeconds + { + get { return _maxSeconds; } + set { _maxSeconds = value; RaisePropertyChangedAuto(); } + } + + private int _secondsRemaining; + public int SecondsRemaining + { + get { return _secondsRemaining; } + set { _secondsRemaining = value; RaisePropertyChangedAuto(); } + } + + public ColorProfileReceivedViewVM() + { + MaxSeconds = 10; + SecondsRemaining = 10; + + _timer = new DispatcherTimer(); + _timer.Interval = TimeSpan.FromMilliseconds(800); + _timer.Tick += _timer_Tick; + } + + public override void OnShow() + { + base.OnShow(); + _timer.Start(); + } + + protected override void Accept() + { + _timer.Stop(); + base.Accept(); + } + + protected override void Cancel() + { + _timer.Stop(); + base.Cancel(); + } + + private void _timer_Tick(object sender, EventArgs e) + { + SecondsRemaining--; + + if (SecondsRemaining == 0) + { + Cancel(); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml new file mode 100644 index 000000000..0d6faa092 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml @@ -0,0 +1,113 @@ + + + + + Fine Tuning Palette + Choose fine tuning palette: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CANCEL + + + OK + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml.cs new file mode 100644 index 000000000..b86584ad8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteView.xaml.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the fine tuning pallet dialog. + /// + /// + /// + public partial class FineTuningPaletteView : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public FineTuningPaletteView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteViewVM.cs new file mode 100644 index 000000000..2e16ac747 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/FineTuningPaletteViewVM.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.ColorConversion; +using Tango.PPC.Common.Models; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the fine tuning pallet dialog ViewModel. + /// + /// + public class FineTuningPaletteViewVM : DialogViewVM + { + private Job _job; + private bool _prevent_change; + private IColorConverter _converter; + + private List _suggestions; + /// + /// Gets or sets the triplet suggestions. + /// + public List Suggestions + { + get { return _suggestions; } + set { _suggestions = value; RaisePropertyChangedAuto(); } + } + + private List _hiveSuggestions; + /// + /// Gets or sets the hive suggestions. + /// + public List HiveSuggestions + { + get { return _hiveSuggestions; } + set { _hiveSuggestions = value; RaisePropertyChangedAuto(); } + } + + private ColorConversionSuggestion _selectedHiveSuggestion; + /// + /// Gets or sets the selected hive suggestion. + /// + public ColorConversionSuggestion SelectedHiveSuggestion + { + get { return _selectedHiveSuggestion; } + set { _selectedHiveSuggestion = value; RaisePropertyChangedAuto(); OnSelectedHiveSuggestionChanged(); } + } + + private ColorConversionSuggestion _selectedSuggestion; + /// + /// Gets or sets the selected triplet suggestion. + /// + public ColorConversionSuggestion SelectedSuggestion + { + get { return _selectedSuggestion; } + set { _selectedSuggestion = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public FineTuningPaletteViewVM() + { + Suggestions = new List(); + HiveSuggestions = new List(); + + _converter = new DefaultColorConverter(); + } + + /// + /// Called when the selected hive suggestion has been changed + /// + private void OnSelectedHiveSuggestionChanged() + { + if (!_prevent_change) + { + Suggestions = _converter.Convert(_job, SelectedHiveSuggestion.Color, true).CreateTrippletSuggestions(); + SelectedSuggestion = Suggestions.GetCenterSuggestion(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The fine tune item. + /// The job. + public FineTuningPaletteViewVM(FineTuneItem fineTuneItem, Job job) : this() + { + _prevent_change = true; + _job = job; + Suggestions = fineTuneItem.Suggestions; + HiveSuggestions = fineTuneItem.HiveSuggestions; + SelectedHiveSuggestion = HiveSuggestions.GetCenterSuggestion(); + SelectedSuggestion = Suggestions[Suggestions.Count / 2]; + _prevent_change = false; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml new file mode 100644 index 000000000..41010261e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml @@ -0,0 +1,35 @@ + + + + + CANCEL + IMPORT + + + + Import SnapMatch Color + + A SnapMatch color detection result file has been selected from the storage device. press 'IMPORT' to create a new job from this color. + + + + + Detected Color + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml.cs new file mode 100644 index 000000000..f919b9df8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ImportJobView.xaml + /// + public partial class ImportColorProfileView : UserControl + { + public ImportColorProfileView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileViewVM.cs new file mode 100644 index 000000000..100236d8e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportColorProfileViewVM.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ImportColorProfileViewVM : DialogViewVM + { + public Color Color { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml new file mode 100644 index 000000000..e1caea66d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml @@ -0,0 +1,38 @@ + + + + + CANCEL + IMPORT + + + + + + + IMPORT CSV JOB + A csv job file has been selected from the storage device. press 'IMPORT' to add the job to your job list. + + + + Job Name + + + + + Thread Type + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml.cs new file mode 100644 index 000000000..67fc5ec82 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ImportJobView.xaml + /// + public partial class ImportCsvJobView : UserControl + { + public ImportCsvJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobViewVM.cs new file mode 100644 index 000000000..ffa406795 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportCsvJobViewVM.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.PPC.Common; +using Tango.PPC.Common.Connection; +using Tango.Settings; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ImportCsvJobViewVM : DialogViewVM + { + [TangoInject] + private IMachineProvider MachineProvider { get; set; } + + private String _name; + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChangedAuto(); } + } + + private List _rmls; + public List Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + private Rml _selectedRml; + public Rml SelectedRml + { + get { return _selectedRml; } + set { _selectedRml = value; RaisePropertyChangedAuto(); } + } + + private bool _importAndEdit; + public bool ImportAndEdit + { + get { return _importAndEdit; } + set { _importAndEdit = value; RaisePropertyChangedAuto(); } + } + + public ImportCsvJobViewVM() + { + TangoIOC.Default.Inject(this); + } + + public async Task Init() + { + var settings = SettingsManager.Default.GetOrCreate(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + Rmls = await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); + + if (settings.DefaultRmlGuid != null) + { + SelectedRml = Rmls.SingleOrDefault(x => x.Guid == settings.DefaultRmlGuid); + } + + if (SelectedRml == null) + { + SelectedRml = Rmls.FirstOrDefault(); + } + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml new file mode 100644 index 000000000..da51bba27 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml @@ -0,0 +1,25 @@ + + + + + CANCEL + IMPORT + + + + IMPORT JOB + A job file has been selected from the storage device. press 'IMPORT' to add the job to your job list. + + Edit this job after import + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml.cs new file mode 100644 index 000000000..2d17483f5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ImportJobView.xaml + /// + public partial class ImportJobView : UserControl + { + public ImportJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobViewVM.cs new file mode 100644 index 000000000..0440d6a54 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportJobViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ImportJobViewVM : DialogViewVM + { + private bool _importAndEdit; + public bool ImportAndEdit + { + get { return _importAndEdit; } + set { _importAndEdit = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml new file mode 100644 index 000000000..0cd9540ec --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml @@ -0,0 +1,28 @@ + + + + + CANCEL + IMPORT + + + + Import Embroidery File + + An embroidery design file has been selected from the storage device. press 'IMPORT' to create a new job from this design. + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml.cs new file mode 100644 index 000000000..a04406374 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ImportJobView.xaml + /// + public partial class ImportTwnFileView : UserControl + { + public ImportTwnFileView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileViewVM.cs new file mode 100644 index 000000000..5792413b8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ImportTwnFileViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ImportTwnFileViewVM : DialogViewVM + { + public BitmapSource Thumbnail { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml new file mode 100644 index 000000000..cecdf813c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + CANCEL + CREATE + + + + New Job + Please select the job application and color space/catalog and press 'create'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml.cs new file mode 100644 index 000000000..4d57794d7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Enumerations; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the new job creation dialog. + /// + /// + /// + public partial class JobCreationView : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public JobCreationView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs new file mode 100644 index 000000000..e2176c6af --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Represents the a job type picker view model + /// + /// + public class JobCreationViewVM : DialogViewVM + { + /// + /// Gets or sets the supported job types. + /// + public List SupportedJobTypes { get; set; } + + private JobTypes _selectedJobType; + /// + /// Gets or sets the type of the selected job. + /// + public JobTypes SelectedJobType + { + get { return _selectedJobType; } + set + { + _selectedJobType = value; + RaisePropertyChangedAuto(); + } + } + + /// + /// Gets or sets the supported color spaces. + /// + public List SupportedColorSpaces { get; set; } + + private ColorSpaces _selectedColorSpace; + /// + /// Gets or sets the selected color space. + /// + public ColorSpaces SelectedColorSpace + { + get { return _selectedColorSpace; } + set + { + _selectedColorSpace = value; + RaisePropertyChangedAuto(); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The supported job types. + /// The supported color spaces + public JobCreationViewVM(List supportedJobTypes,List supportedColorSpaces) : base() + { + SupportedJobTypes = supportedJobTypes; + SupportedColorSpaces = supportedColorSpaces; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml new file mode 100644 index 000000000..c0874363f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml @@ -0,0 +1,32 @@ + + + + + + ABORT + CONTINUE + + + + SPOOL CHANGE + + The current job was set to dye each color segment on a single spool. + + Please replace the spool and press 'continue'. + + + + / + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml.cs new file mode 100644 index 000000000..f79e1f4b7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for SpoolChangeView.xaml + /// + public partial class SpoolChangeView : UserControl + { + public SpoolChangeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeViewVM.cs new file mode 100644 index 000000000..8942cb284 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/SpoolChangeViewVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Integration.Operation; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class SpoolChangeViewVM : DialogViewVM + { + public SpoolChangeRequiredEventArgs SpoolChangeRequiredEventArgs { get; set; } + + public SpoolChangeViewVM(SpoolChangeRequiredEventArgs spoolChangeRequiredEventArgs) + { + SpoolChangeRequiredEventArgs = spoolChangeRequiredEventArgs; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats-sylko-logo.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats-sylko-logo.png new file mode 100644 index 000000000..5fc4c13d1 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats-sylko-logo.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats.png new file mode 100644 index 000000000..1b2d01f51 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/coats.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/thread.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/thread.png new file mode 100644 index 000000000..443897335 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Coats/thread.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroider.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroider.png new file mode 100644 index 000000000..f71bc2a70 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroider.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroidery.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroidery.png new file mode 100644 index 000000000..d71717835 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Embroidery.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Job Issues/cyan.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Job Issues/cyan.png new file mode 100644 index 000000000..d53382f28 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Job Issues/cyan.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/clock.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/clock.png new file mode 100644 index 000000000..80cde5b8b Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/clock.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/drop.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/drop.png new file mode 100644 index 000000000..75b215a63 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobProgressView/drop.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/additional-tools.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/additional-tools.png new file mode 100644 index 000000000..421446e8d Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/additional-tools.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-fine-tuning.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-fine-tuning.png new file mode 100644 index 000000000..5b8201eef Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-fine-tuning.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-length.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-length.png new file mode 100644 index 000000000..6495c83ff Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-length.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-picker.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-picker.png new file mode 100644 index 000000000..e09d23190 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/color-picker.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/delete.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/delete.png new file mode 100644 index 000000000..1e4cf9945 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/delete.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/error.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/error.png new file mode 100644 index 000000000..02a0a91a9 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/error.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-details.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-details.png new file mode 100644 index 000000000..e0ebc547e Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-details.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-summary.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-summary.png new file mode 100644 index 000000000..d85cbd5e0 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job-summary.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/output.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/output.png new file mode 100644 index 000000000..7e58fa67a Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/output.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/remove.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/remove.png new file mode 100644 index 000000000..68ee07788 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/remove.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/replace-color.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/replace-color.png new file mode 100644 index 000000000..af5655416 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/replace-color.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/sample-dye.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/sample-dye.png new file mode 100644 index 000000000..f8989e19a Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/sample-dye.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/settings.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/settings.png new file mode 100644 index 000000000..d7b224819 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/settings.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent.jpg b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent.jpg new file mode 100644 index 000000000..cf1d94d12 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent.jpg differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent_small.jpg b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent_small.jpg new file mode 100644 index 000000000..c682a4c7e Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/transparent_small.jpg differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/twine-catalog.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/twine-catalog.png new file mode 100644 index 000000000..35d9b69cd Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/twine-catalog.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Knitting.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Knitting.png new file mode 100644 index 000000000..06c345965 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Knitting.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/coats.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/coats.png new file mode 100644 index 000000000..d6cd3ecf2 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/coats.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/lab.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/lab.png new file mode 100644 index 000000000..607afd980 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/lab.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/rgb.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/rgb.png new file mode 100644 index 000000000..dfdf32c8d Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/rgb.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/twine.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/twine.png new file mode 100644 index 000000000..b1d3da8c5 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/twine.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/volume.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/volume.png new file mode 100644 index 000000000..434e704ca Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/NewJob/volume.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Sewing.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Sewing.png new file mode 100644 index 000000000..51c468eea Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/Sewing.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/arrows.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/arrows.png new file mode 100644 index 000000000..ae3482ee5 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/arrows.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color-picker.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color-picker.png new file mode 100644 index 000000000..d8d6f8470 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color-picker.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small.png new file mode 100644 index 000000000..e29b5fb67 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small_gray.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small_gray.png new file mode 100644 index 000000000..828379648 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/color_approved_small_gray.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/csv.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/csv.png new file mode 100644 index 000000000..5ff44818b Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/csv.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/emb-file.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/emb-file.png new file mode 100644 index 000000000..a369eb899 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/emb-file.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/job.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/job.png new file mode 100644 index 000000000..a41bcf8f0 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/job.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs-module.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs-module.png new file mode 100644 index 000000000..85e82c491 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs-module.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs.png new file mode 100644 index 000000000..eb668ad03 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/jobs.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view - blue.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view - blue.png new file mode 100644 index 000000000..a37e0b555 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view - blue.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view.png new file mode 100644 index 000000000..697ce228c Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/large-cards-view.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/length.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/length.png new file mode 100644 index 000000000..bad870dcb Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/length.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/liquid.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/liquid.png new file mode 100644 index 000000000..7c5a4bceb Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/liquid.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pantone.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pantone.png new file mode 100644 index 000000000..477af3c2c Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pantone.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-blue.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-blue.png new file mode 100644 index 000000000..cab937cef Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-blue.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-gray.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-gray.png new file mode 100644 index 000000000..0ca2eed8c Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/pencil-gray.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/plus.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/plus.png new file mode 100644 index 000000000..de965130e Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/plus.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small.png new file mode 100644 index 000000000..6e4e56fe0 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small_gray.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small_gray.png new file mode 100644 index 000000000..edf3bf0dd Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sample_approved_small_gray.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view - blue.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view - blue.png new file mode 100644 index 000000000..d0a97503e Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view - blue.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view.png new file mode 100644 index 000000000..873b7513f Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/small-cards-view.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/snapmatch.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/snapmatch.png new file mode 100644 index 000000000..05656ffdc Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/snapmatch.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_change.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_change.png new file mode 100644 index 000000000..17737eed0 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_change.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_replace.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_replace.png new file mode 100644 index 000000000..0adf7e7d4 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/spool_replace.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync.png new file mode 100644 index 000000000..46059c5c0 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync_job.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync_job.png new file mode 100644 index 000000000..4e46ee447 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/sync_job.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/warning.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/warning.png new file mode 100644 index 000000000..5c7672421 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/warning.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsModuleSettings.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsModuleSettings.cs new file mode 100644 index 000000000..85278d692 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsModuleSettings.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Settings; + +namespace Tango.PPC.Jobs +{ + /// + /// Represents the jobs module settings. + /// + /// + public class JobsModuleSettings : SettingsBase + { + public class RecentCatalog + { + public String Guid { get; set; } + public List RecentItems { get; set; } + + public RecentCatalog() + { + RecentItems = new List(); + } + } + + /// + /// Gets or sets the recent catalogs items. + /// + public List RecentCatalogsItems { get; set; } + + /// + /// Gets or sets the last job color space. + /// + public ColorSpaces? LastJobColorSpace { get; set; } + + /// + /// Gets or sets the new job last type. + /// + public JobTypes? LastJobType { get; set; } + + /// + /// Gets or sets the last selected catalog unique identifier. + /// + public String LastSelectedCatalogGuid { get; set; } + + /// + /// Adds a catalog item to the recent list. + /// + /// The catalog. + /// The catalog item. + public void AddRecentCatalogItem(ColorCatalog catalog, ColorCatalogsItem item) + { + var recentCatalog = RecentCatalogsItems.FirstOrDefault(x => x.Guid == catalog.Guid); + + if (recentCatalog == null) + { + recentCatalog = new RecentCatalog(); + recentCatalog.Guid = catalog.Guid; + RecentCatalogsItems.Add(recentCatalog); + } + + if (recentCatalog.RecentItems.Exists(x => x == item.Guid)) + { + recentCatalog.RecentItems.Remove(item.Guid); + } + + recentCatalog.RecentItems.Insert(0, item.Guid); + + if (recentCatalog.RecentItems.Count > 20) + { + recentCatalog.RecentItems.RemoveAt(recentCatalog.RecentItems.Count - 1); + } + } + + /// + /// Initializes a new instance of the class. + /// + public JobsModuleSettings() + { + RecentCatalogsItems = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsV2Module.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsV2Module.cs new file mode 100644 index 000000000..64ad34a21 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/JobsV2Module.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.PPC.Common; +using Tango.PPC.Jobs.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.Jobs +{ + /// + /// Represents the PPC jobs module + /// + /// + [PPCModule(1, nameof(JobsView))] + public class JobsV2Module : PPCModuleBase + { + /// + /// Gets the module name. + /// + public override string Name + { + get + { + return "Jobs"; + } + } + + /// + /// Gets the module description. + /// + public override string Description + { + get + { + return "Manage and run jobs"; + } + } + + /// + /// Gets the module cover image. + /// + public override BitmapSource Image + { + get + { + return ResourceHelper.GetImageFromResources("Images/jobs.png"); + } + } + + /// + /// Gets the module entry point view type. + /// + public override Type MainViewType + { + get + { + return typeof(MainView); + } + } + + /// + /// Gets the permission required to see and load this module. + /// + public override Permissions Permission + { + get + { + return Permissions.RunPPC; + } + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/JobSelectedMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/JobSelectedMessage.cs new file mode 100644 index 000000000..721dce6ed --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/JobSelectedMessage.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.Messages +{ + /// + /// Notifies about a job being selected from the job list. + /// + public class JobSelectedMessage + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + + /// + /// Gets or sets the db context. + /// + public ObservablesContext Context { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/NavigatedToJobsModuleMessage.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/NavigatedToJobsModuleMessage.cs new file mode 100644 index 000000000..3f2be3f89 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Messages/NavigatedToJobsModuleMessage.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Jobs.Messages +{ + public class NavigatedToJobsModuleMessage + { + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobNavigationObject.cs new file mode 100644 index 000000000..0f5e39872 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobNavigationObject.cs @@ -0,0 +1,36 @@ +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 +{ + /// + /// Represents a job navigation object. + /// + public class JobNavigationObject + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + + /// + /// Gets or sets the navigation intent. + /// + public JobNavigationIntent Intent { get; set; } + } + + /// + /// Represents different job navigation intents. + /// + public enum JobNavigationIntent + { + Default, + NewJob, + SampleDye, + FineTuning, + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobSummeryNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobSummeryNavigationObject.cs new file mode 100644 index 000000000..912b42683 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/JobSummeryNavigationObject.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; + +namespace Tango.PPC.Jobs.NavigationObjects +{ + public class JobSummeryNavigationObject + { + public ObservablesContext Context { get; set; } + public Job Job { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/TwineCatalogNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/TwineCatalogNavigationObject.cs new file mode 100644 index 000000000..edd18a2c0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/TwineCatalogNavigationObject.cs @@ -0,0 +1,15 @@ +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 TwineCatalogNavigationObject + { + public ColorCatalog Catalog { get; set; } + public ColorCatalogsItem SelectedItem { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItem.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItem.cs new file mode 100644 index 000000000..4e3137e1c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItem.cs @@ -0,0 +1,32 @@ +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 +{ + /// + /// Represents a simple text message notification item which can be inserted into the application notifications panel. + /// + /// + public class NewSynchronizardJobsNotificationItem : NotificationItem + { + /// + /// Initializes a new instance of the class. + /// + public NewSynchronizardJobsNotificationItem() + { + CanClose = true; + } + + /// + /// Gets or sets the view type. + /// + public override Type ViewType + { + get { return typeof(NewSynchronizardJobsNotificationItemView); } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml new file mode 100644 index 000000000..5a57e3db7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + New job definitions were synchronized with your machine. Tap to refresh your job list. + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml.cs new file mode 100644 index 000000000..33db09386 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NotificationItems/NewSynchronizardJobsNotificationItemView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.NotificationItems +{ + /// + /// Represents the view. + /// + /// + /// + public partial class NewSynchronizardJobsNotificationItemView : UserControl + { + public NewSynchronizardJobsNotificationItemView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..41dc27f8b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango PPC Jobs V2 Module")] +[assembly: AssemblyVersion("1.0.0.0")] + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.Designer.cs new file mode 100644 index 000000000..69824181c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Jobs.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.PPC.Jobs.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.resx b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.Designer.cs new file mode 100644 index 000000000..07b7f7e97 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Jobs.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.settings b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resources/Styles.xaml new file mode 100644 index 000000000..b1f4b6d49 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resources/Styles.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj new file mode 100644 index 000000000..a2240ea28 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -0,0 +1,526 @@ + + + + + Debug + AnyCPU + {DBBD90F4-4135-475D-A8F8-6795D3A8F697} + library + Tango.PPC.Jobs + Tango.PPC.JobsV2 + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + ..\..\..\Build\PPC\Debug\ + TRACE;DEBUG + prompt + 4 + + + pdbonly + true + ..\..\..\Build\PPC\Release\ + TRACE + prompt + 4 + + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + + + + + + ..\..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + GlobalVersionInfo.cs + + + + JobProgressAppBarItemView.xaml + + + + + + RunningJobViewer.xaml + + + JobSummeryViewer.xaml + + + TwineCatalogViewer.xaml + + + + + + + + + + + AdvancedColorCorrectionView.xaml + + + + BasicColorCorrectionView.xaml + + + + ImportCsvJobView.xaml + + + + ImportTwnFileView.xaml + + + ImportColorProfileView.xaml + + + + + FineTuningPaletteView.xaml + + + + ColorProfileReceivedView.xaml + + + ImportJobView.xaml + + + + + CatalogSelectionView.xaml + + + JobCreationView.xaml + + + + + SpoolChangeView.xaml + + + + + + + + + + + + NewSynchronizardJobsNotificationItemView.xaml + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + + + + JobProgressView.xaml + + + JobsView.xaml + + + JobSummeryView.xaml + + + JobView.xaml + + + MainView.xaml + + + TwineCatalogView.xaml + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {b4fe6485-4161-4b36-bc08-67e0b53d01b7} + Tango.ColorConversion + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {b112d89a-a106-41ae-a0c1-4abc84c477f5} + Tango.DragAndDrop + + + {4399AF76-DB52-4CFB-8020-6F85BDB29FD5} + Tango.Explorer + + + {942134ac-6ea2-4500-8f22-0f739b70a05f} + Tango.Hive + + + {4206AC58-3B57-4699-8835-90BF6DB01A61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {e4927038-348d-4295-aaf4-861c58cb3943} + Tango.PMR + + + {8435223d-db6b-45e3-a08b-45b7416f8481} + Tango.Pulse + + + {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} + Tango.Settings + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {fd86424c-6e84-491b-8df9-3d0f5c236a2a} + Tango.Touch + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {0be74eee-22cb-4dba-b896-793b9e1a3ac0} + Tango.PPC.Common + + + {04febb02-f782-4b96-b47d-f6902afa43be} + Tango.PPC.Storage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobView.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobView.cs new file mode 100644 index 000000000..f63d2959e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobView.cs @@ -0,0 +1,31 @@ +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 +{ + /// + /// Represents the job view contract. + /// + /// + public interface IJobView : IPPCView + { + /// + /// Displays the sample dye region. + /// + void DisplaySampleDye(); + + /// + /// Displays the fine tuning region. + /// + void DisplayFineTuning(); + + /// + /// Scrolls to top. + /// + void ScrollToTop(); + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobsView.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobsView.cs new file mode 100644 index 000000000..7a8907c36 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewContracts/IJobsView.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 IJobsView : IPPCView + { + void ScrollToTop(); + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs new file mode 100644 index 000000000..1b91d2ee8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.PPC.Jobs.ViewModels; + +namespace Tango.PPC.Jobs +{ + public static class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + static ViewModelLocator() + { + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + TangoIOC.Default.Register(); + } + + /// + /// Gets the main view VM. + /// + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + /// + /// Gets the jobs list VM. + /// + public static JobsViewVM JobsViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + /// + /// Gets the job summery VM. + /// + public static JobSummeryViewVM JobSummeryViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + /// + /// Gets the job details VM. + /// + public static JobViewVM JobViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + /// + /// Gets the twine catalog view VM. + /// + public static TwineCatalogViewVM TwineCatalogViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + + /// + /// Gets the job progress view VM. + /// + public static JobProgressViewVM JobProgressViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobProgressViewVM.cs new file mode 100644 index 000000000..8756a6a57 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobProgressViewVM.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.Logging; +using Tango.PMR.Printing; +using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; +using Tango.PPC.Jobs.AppBarItems; +using Tango.PPC.Jobs.AppButtons; +using Tango.PPC.Jobs.Dialogs; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.PPC.Jobs.Views; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the job progress view model. + /// + /// + public class JobProgressViewVM : PPCViewModel + { + private StopPrintingButton _stop_job_btn; + private JobHandler _handler; + + #region Properties + + private Job _job; + /// + /// Gets or sets the job. + /// + public Job Job + { + get { return _job; } + set { _job = value; RaisePropertyChangedAuto(); } + } + + private RunningJobStatus _runningJobStatus; + /// + /// Gets or sets the running job status. + /// + public RunningJobStatus RunningJobStatus + { + get { return _runningJobStatus; } + set { _runningJobStatus = value; RaisePropertyChangedAuto(); } + } + + private bool _isDisplayJobOutline; + /// + /// Gets or sets a value indicating whether to display the job outline. + /// + public bool IsDisplayJobOutline + { + get { return _isDisplayJobOutline; } + set { _isDisplayJobOutline = value; RaisePropertyChangedAuto(); } + } + + private JobTicket _jobOutlineTicket; + /// + /// Gets or sets the job outline ticket. + /// + public JobTicket JobOutlineTicket + { + get { return _jobOutlineTicket; } + set { _jobOutlineTicket = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the go to job command. + /// + /// + /// The go to job command. + /// + public RelayCommand GoToJobCommand { get; set; } + + /// + /// Gets or sets the display job outline command. + /// + public RelayCommand DisplayJobOutlineCommand { get; set; } + + /// + /// Gets or sets the hide job outline command. + /// + public RelayCommand HideJobOutlineCommand { get; set; } + + #endregion + + public JobProgressViewVM() + { + _stop_job_btn = new StopPrintingButton(); + _stop_job_btn.Pressed += _stop_job_btn_Pressed; + + GoToJobCommand = new RelayCommand(GoToJob); + DisplayJobOutlineCommand = new RelayCommand(DisplayJobOutline); + HideJobOutlineCommand = new RelayCommand(HideJobOutline); + } + + #region Private Methods + + private void HideJobOutline() + { + IsDisplayJobOutline = false; + } + + private void DisplayJobOutline() + { + JobOutlineTicket = _handler.JobTicket; + IsDisplayJobOutline = true; + } + + private void GoToJob() + { + NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = _handler.Job }); + NavigationManager.ClearHistoryExcept(); + } + + #endregion + + #region Override Methods + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; + } + + /// + /// Called when the navigation system has navigated to this VM view. + /// + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + IsDisplayJobOutline = false; + + if (_handler != null && !_handler.Status.IsFailed) + { + _stop_job_btn.Push(); + } + } + + #endregion + + #region Event Handlers + + private void _stop_job_btn_Pressed() + { + if (_handler != null) + { + _handler.Cancel(); + } + } + + /// + /// Handles the PrintingStarted event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) + { + _handler = e.JobHandler; + Job = e.Job; + e.JobHandler.StatusChanged += JobHandler_StatusChanged; + e.JobHandler.SpoolChangeRequired += JobHandler_SpoolChangeRequired; + e.JobHandler.Stopped += JobHandler_Stopped; + e.JobHandler.CanCancelChanged += JobHandler_CanCancelChanged; + + _stop_job_btn.Push(); + _stop_job_btn.IsEnabled = true; + } + + private void MachineOperator_PrintingEnded(object sender, PrintingEventArgs e) + { + LogManager.Log("Printing ended, popping job stop button..."); + + if (_stop_job_btn != null) + { + _stop_job_btn.Pop(); + } + else + { + LogManager.Log("Job stop button instance was null!", LogCategory.Warning); + } + } + + /// + /// Handles the SpoolChangeRequired event of the JobHandler. + /// + /// The source of the event. + /// The instance containing the event data. + private void JobHandler_SpoolChangeRequired(object sender, SpoolChangeRequiredEventArgs e) + { + InvokeUI(async () => + { + if ((await NotificationProvider.ShowDialog(new SpoolChangeViewVM(e))).DialogResult) + { + e.Confirm(); + } + else + { + e.Abort(); + } + }); + } + + /// + /// Handles the Stopped event of the JobHandler. + /// + /// The source of the event. + /// The instance containing the event data. + private void JobHandler_Stopped(object sender, EventArgs e) + { + if (_handler != null) + { + _handler.StatusChanged -= JobHandler_StatusChanged; + _handler.SpoolChangeRequired -= JobHandler_SpoolChangeRequired; + _handler.Stopped -= JobHandler_Stopped; + _handler.CanCancelChanged -= JobHandler_CanCancelChanged; + } + } + + /// + /// Handles the JobHandler StatusChanged event. + /// + /// The sender. + /// The e. + private void JobHandler_StatusChanged(object sender, RunningJobStatus e) + { + InvokeUI(() => + { + RunningJobStatus = e; + }); + } + + /// + /// Handles the CanCancelChanged event of the JobHandler control. + /// + /// The source of the event. + /// The instance containing the event data. + private void JobHandler_CanCancelChanged(object sender, EventArgs e) + { + _stop_job_btn.IsEnabled = _handler.CanCancel; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobSummeryViewVM.cs new file mode 100644 index 000000000..467013607 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobSummeryViewVM.cs @@ -0,0 +1,192 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.ColorConversion; +using Tango.Core.Commands; +using Tango.Integration.Operation; +using Tango.PPC.Common; +using Tango.PPC.Common.Messages; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Jobs.Messages; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.PPC.Jobs.Views; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the job summary view model. + /// + /// + public class JobSummeryViewVM : PPCViewModel, INavigationObjectReceiver + { + private ObservablesContext _context; + private bool _canStartJob; + private bool _startingJob; + + private bool _isPreparingJob; + /// + /// Gets or sets a value indicating whether the job is currently preparing. + /// + public bool IsPreparingJob + { + get { return _isPreparingJob; } + set { _isPreparingJob = value; RaisePropertyChangedAuto(); } + } + + + private Job _job; + /// + /// Gets or sets the job. + /// + public Job Job + { + get { return _job; } + set { _job = value; RaisePropertyChangedAuto(); } + } + + private TimeSpan _estimatedDuration; + /// + /// Gets or sets the duration of the estimated. + /// + public TimeSpan EstimatedDuration + { + get { return _estimatedDuration; } + set { _estimatedDuration = value; RaisePropertyChangedAuto(); } + } + + private int _btsrSpoolTension; + public int BtsrSpoolTension + { + get { return _btsrSpoolTension; } + set { _btsrSpoolTension = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the dye command. + /// + public RelayCommand DyeCommand { get; set; } + + /// + /// Gets or sets the edit command. + /// + public RelayCommand EditCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public JobSummeryViewVM() + { + DyeCommand = new RelayCommand(StartJob, () => + { + return _canStartJob; + }); + EditCommand = new RelayCommand(EditJob); + } + + /// + /// Edits the job. + /// + private void EditJob() + { + LogManager.Log("Edit command pressed."); + NavigationManager.NavigateTo(false, nameof(JobView)); + } + + /// + /// Starts the job. + /// + private async void StartJob() + { + if (_startingJob) return; + + _startingJob = true; + _canStartJob = false; + InvalidateRelayCommands(); + NavigationManager.IsBackEnabled = false; + + try + { + LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); + + await PrintingManager.Print(Job, _context); + await NavigationManager.NavigateTo(false, nameof(JobProgressView)); + _startingJob = false; + } + catch (InsufficientLiquidQuantityException) + { + //Ignore.. + } + catch (OperationCanceledException) + { + //Ignore.. + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not start the current job."); + await NotificationProvider.ShowError($"{ex.Message}"); + } + finally + { + _startingJob = false; + _canStartJob = true; + NavigationManager.IsBackEnabled = true; + InvalidateRelayCommands(); + } + } + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + + } + + public async void OnNavigatedToWithObject(JobSummeryNavigationObject obj) + { + _canStartJob = false; + InvalidateRelayCommands(); + + _context = obj.Context; + Job = obj.Job; + + IsPreparingJob = true; + + Job = await new JobBuilder(_context).Set(Job.Guid) + .WithConfiguration() + .WithRML() + .WithUser() + .WithSegments() + .WithBrushStops() + .BuildAsync(); + + if (Job.Rml != null && _context != null) + { + BtsrSpoolTension = await Job.Rml.GetRequiredBtsrSpoolTension(_context, Job.SpoolType); + } + + await Task.Factory.StartNew(() => + { + try + { + IColorConverter _converter = new DefaultColorConverter(); + EstimatedDuration = Job.GetEstimatedDuration(_converter.GetRecommendedProcessParameters(Job, true)); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error calculating recommended process parameters."); + } + }); + + IsPreparingJob = false; + + _canStartJob = true; + InvalidateRelayCommands(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs new file mode 100644 index 000000000..408bbc615 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -0,0 +1,1650 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.PPC.Common; +using Tango.PPC.Jobs.Messages; +using System.Data.Entity; +using Tango.Core.Commands; +using System.Windows; +using Tango.Touch.Controls; +using System.Windows.Media; +using Tango.DragAndDrop; +using System.ComponentModel; +using System.Windows.Data; +using Tango.PPC.Jobs.Dialogs; +using Tango.PPC.Jobs.Views; +using System.Runtime.InteropServices; +using System.Threading; +using Tango.SharedUI.Helpers; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.PPC.Jobs.ViewContracts; +using System.Collections.ObjectModel; +using Tango.PPC.Common.Models; +using Tango.Logging; +using Tango.PPC.Common.Messages; +using Tango.BL.Builders; +using Tango.PPC.Jobs.AppButtons; +using Tango.Core.Threading; +using System.Diagnostics; +using System.Runtime.ExceptionServices; +using Tango.Explorer; +using Tango.PPC.Storage; +using System.IO; +using Tango.ColorConversion; +using Tango.Integration.Operation; +using Tango.BL.Enumerations; +using Tango.PPC.Common.Lubrication; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the selected job view model. + /// + /// + public class JobViewVM : PPCViewModel, INavigationObjectReceiver + { + private ObservablesContext _db; + private bool _can_navigate_back; + private Thread _check_gamut_thread; + private Job _job_to_load; + private JobNavigationIntent _job_to_load_intent; + private static Dictionary> _jobs_fine_tune_items; + public static StartPrintingButton _start_printing_btn; + private ActionTimer _volumeConversionTimer; + private IColorConverter _converter; + private string _current_job_string; + private bool startingJob = false; + + #region Properties + + private Job _job; + /// + /// Gets or sets the selected job. + /// + public Job Job + { + get { return _job; } + set { _job = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _segmentsCollectionView; + /// + /// Gets or sets the job segments collection view. + /// + public ICollectionView SegmentsCollectionView + { + get { return _segmentsCollectionView; } + set + { + _segmentsCollectionView = value; + RaisePropertyChangedAuto(); + } + } + + private List _colorSpaces; + /// + /// Gets or sets the available color spaces. + /// + public List ColorSpaces + { + get { return _colorSpaces; } + set { _colorSpaces = value; RaisePropertyChangedAuto(); } + } + + private List _rmls; + /// + /// Gets or sets the available RMLS. + /// + public List Rmls + { + get { return _rmls; } + set { _rmls = value; RaisePropertyChangedAuto(); } + } + + private Rml _selectedRML; + /// + /// Gets or sets the selected RML. + /// + public Rml SelectedRML + { + get { return _selectedRML; } + set { _selectedRML = value; RaisePropertyChangedAuto(); OnSelectedRmlChanged(); } + } + + private List _spoolTypes; + /// + /// Gets or sets the available spool types. + /// + public List SpoolTypes + { + get { return _spoolTypes; } + set { _spoolTypes = value; RaisePropertyChangedAuto(); } + } + + private List _customers; + /// + /// Gets or sets the available customers. + /// + public List Customers + { + get { return _customers; } + set { _customers = value; RaisePropertyChangedAuto(); } + } + + private String _customersFilter; + /// + /// Gets or sets the customers filter. + /// + public String CustomersFilter + { + get { return _customersFilter; } + set { _customersFilter = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the customers automatic complete provider. + /// + public AutoCompleteProvider CustomersAutoCompleteProvider { get; set; } + + private ObservableCollection _fineTuneItems; + /// + /// Gets or sets the fine tune items. + /// + public ObservableCollection FineTuneItems + { + get { return _fineTuneItems; } + set { _fineTuneItems = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _approvalFineTuneItems; + /// + /// Gets or sets the fine tune items. + /// + public ObservableCollection ApprovalFineTuneItems + { + get { return _approvalFineTuneItems; } + set { _approvalFineTuneItems = value; RaisePropertyChangedAuto(); } + } + + private bool _isFineTuneExpanded; + /// + /// Gets or sets a value indicating whether the fine tuning region is expanded. + /// + public bool IsFineTuneExpanded + { + get { return _isFineTuneExpanded; } + set + { + _isFineTuneExpanded = value; + RaisePropertyChangedAuto(); + + if (_isFineTuneExpanded) + { + SyncFineTuneItemsToBrushStops(); + } + } + } + + private bool _isJobDetailsExpanded; + /// + /// Gets or sets a value indicating whether the job details area is expanded. + /// + public bool IsJobDetailsExpanded + { + get { return _isJobDetailsExpanded; } + set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } + } + + /// + /// Gets or sets the twine catalog automatic complete provider. + /// + public IAutoCompleteProvider CatalogAutoCompleteProvider { get; set; } + + private List _availableCatalogs; + public List AvailableCatalogs + { + get { return _availableCatalogs; } + set { _availableCatalogs = value; RaisePropertyChangedAuto(); } + } + + private RmlLubricationLevel _lubricationLevel; + public RmlLubricationLevel LubricationLevel + { + get { return _lubricationLevel; } + set { _lubricationLevel = value; RaisePropertyChangedAuto(); } + } + + private int _btsrSpoolTension; + public int BtsrSpoolTension + { + get { return _btsrSpoolTension; } + set { _btsrSpoolTension = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + + /// + /// Gets or sets the add solid segment command. + /// + public RelayCommand AddSolidSegmentCommand { get; set; } + + /// + /// Gets or sets the add gradient segment command. + /// + public RelayCommand AddGradientSegmentCommand { get; set; } + + /// + /// Gets or sets the add brush stop command. + /// + public RelayCommand AddBrushStopCommand { get; set; } + + /// + /// Gets or sets the segment dropped command. + /// + public RelayCommand SegmentDroppedCommand { get; set; } + + /// + /// Gets or sets the remove segment command. + /// + public RelayCommand RemoveSegmentCommand { get; set; } + + /// + /// Gets or sets the remove brush stop command. + /// + public RelayCommand RemoveBrushStopCommand { get; set; } + + /// + /// Gets or sets the remove job command. + /// + public RelayCommand RemoveJobCommand { get; set; } + + /// + /// Gets or sets the save job command. + /// + public RelayCommand SaveJobCommand { get; set; } + + /// + /// Gets or sets the replace brush stop command. + /// + public RelayCommand ReplaceBrushStopCommand { get; set; } + + /// + /// Gets or sets the twine catalog field tap command. + /// + public RelayCommand OpenCatalogCommand { get; set; } + + /// + /// Gets or sets the increase decrease samples to dye command. + /// + public RelayCommand IncreaseDecreaseSamplesToDyeCommand { get; set; } + + /// + /// Gets or sets the start sample dye command. + /// + public RelayCommand StartSampleDyeCommand { get; set; } + + /// + /// Gets or sets the dye command. + /// + public RelayCommand DyeCommand { get; set; } + + /// + /// Gets or sets the approve sample command. + /// + public RelayCommand ApproveSampleCommand { get; set; } + + /// + /// Gets or sets the repeat sample dye command. + /// + public RelayCommand RepeatSampleDyeCommand { get; set; } + + /// + /// Gets or sets another sample command. + /// + public RelayCommand AnotherSampleCommand { get; set; } + + /// + /// Gets or sets the invoke fine tuning palette command. + /// + public RelayCommand InvokeFineTuningPaletteCommand { get; set; } + + /// + /// Gets or sets the reset fine tuning command. + /// + public RelayCommand ResetFineTuningCommand { get; set; } + + /// + /// Gets or sets the start fine tuning command. + /// + public RelayCommand StartFineTuningCommand { get; set; } + + /// + /// Gets or sets the approve fine tuning command. + /// + public RelayCommand ApproveFineTuningCommand { get; set; } + + /// + /// Gets or sets the repeat fine tuning command. + /// + public RelayCommand RepeatFineTuningCommand { get; set; } + + /// + /// Gets or sets the export embroidery command. + /// + public RelayCommand ExportEmbroideryCommand { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes the class. + /// + static JobViewVM() + { + _jobs_fine_tune_items = new Dictionary>(); + } + + /// + /// Initializes a new instance of the class. + /// + public JobViewVM() + { + _converter = new DefaultColorConverter(); + + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + + RegisterForMessage(HandleJobSelectedMessage); + + FineTuneItems = new ObservableCollection(); + ApprovalFineTuneItems = new ObservableCollection(); + + CustomersAutoCompleteProvider = new AutoCompleteProvider((customer, filter) => + { + return customer.Name.ToLower().StartsWith(filter != null ? filter.ToLower() : String.Empty); + }); + + + CatalogAutoCompleteProvider = new AutoCompleteProvider((item, filter) => + { + return !String.IsNullOrWhiteSpace(filter) && item.Name.ToLower().StartsWith(filter.ToLower()); + }); + + //Initialize Commands + AddSolidSegmentCommand = new RelayCommand(() => AddSolidSegment()); + AddBrushStopCommand = new RelayCommand(AddBrushStop); + AddGradientSegmentCommand = new RelayCommand(() => AddGradientSegment()); + SegmentDroppedCommand = new RelayCommand((e) => + { + DragAndDropSegment( + (e.Draggable as FrameworkElement).DataContext as Segment, + (e.Droppable as FrameworkElement).DataContext as Segment); + }); + + RemoveSegmentCommand = new RelayCommand(RemoveSegment); + RemoveBrushStopCommand = new RelayCommand(RemoveBrushStop); + RemoveJobCommand = new RelayCommand(RemoveJob); + SaveJobCommand = new RelayCommand(() => SaveJob()); + ReplaceBrushStopCommand = new RelayCommand(InvokeColorAdjustmentForBrushStop); + IncreaseDecreaseSamplesToDyeCommand = new RelayCommand((x) => + { + if (x == "+") + { + Job.SampleUnitsOrMeters++; + } + else + { + Job.SampleUnitsOrMeters--; + } + }); + + _check_gamut_thread = new Thread(CheckGamutThreadMethod); + _check_gamut_thread.IsBackground = true; + + StartSampleDyeCommand = new RelayCommand(StartSampleDye, CanStartJob); + DyeCommand = new RelayCommand(StartJob, CanStartJob); + + ApproveSampleCommand = new RelayCommand(ApproveSampleDye); + RepeatSampleDyeCommand = new RelayCommand(RepeatSampleDye); + AnotherSampleCommand = new RelayCommand(DyeAnotherSample); + InvokeFineTuningPaletteCommand = new RelayCommand(InvokeFineTuningPalette); + ResetFineTuningCommand = new RelayCommand(() => ResetFineTuning(true)); + StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected) && CanStartJob()); + RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); + ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); + OpenCatalogCommand = new RelayCommand(OpenCatalog); + ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); + } + + #endregion + + #region Job Management + + /// + /// Loads the job. + /// + private async void LoadJob() + { + try + { + if (!(_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))) + { + View.ScrollToTop(); + + LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); + + //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + IsFree = false; + + _can_navigate_back = false; + + if (_db != null) + { + if (Job != null) + { + //Job.RmlChanged -= OnRmlChanged; + Job.NameChanged -= Job_NameChanged; + + foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).ToList()) + { + stop.ColorSpaceChanged -= Stop_ColorSpaceChanged; + stop.ColorCatalogChanged -= Stop_ColorCatalogChanged; + } + } + + if (Rmls != null) + { + Rmls.Where(x => x.Cct != null && x.Cct.Data != null).ToList().ForEach(x => x.Cct.Data = null); + Rmls.ForEach(x => x.Cct = null); + + if (SelectedRML != null) + { + SelectedRML.Cct = null; + SelectedRML = null; + } + + Rmls = null; + } + + _db.Dispose(); + GC.Collect(); + } + + _db = ObservablesContext.CreateDefault(); + + Job = await new JobBuilder(_db).Set(_job_to_load.Guid) + .WithConfiguration() + .WithUser() + .WithSegments() + .WithBrushStops() + .BuildAsync(); + + //Job.RmlChanged -= OnRmlChanged; + //Job.RmlChanged += OnRmlChanged; + Job.NameChanged -= Job_NameChanged; + Job.NameChanged += Job_NameChanged; + + Job.ValidateOnPropertyChanged = true; + + //GetLubricationLevel(); + //await SetSpoolTension(Job.Rml); + + LogManager.Log("Loading RMLS..."); + Rmls = (await new RmlsCollectionBuilder(_db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToList(); + LogManager.Log("Loading Color Spaces..."); + ColorSpaces = await _db.ColorSpaces.Where(x => x.Code != (int)BL.Enumerations.ColorSpaces.CMYK).ToListAsync(); + LogManager.Log("Loading Spool Types..."); + SpoolTypes = await _db.SpoolTypes.ToListAsync(); + LogManager.Log("Loading Customers..."); + Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); + + AvailableCatalogs = await new CatalogsCollectionBuilder(_db).SetAll().WithGroups().WithItems().ForSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); + + _selectedRML = Job.Rml; + RaisePropertyChanged(nameof(SelectedRML)); + + await LoadRML(_selectedRML); + + if (!_check_gamut_thread.IsAlive) + { + _check_gamut_thread.Start(); + } + + SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); + + //ResetFineTuning(); + + _job_to_load = null; + + _current_job_string = Job.ToJobFileWhenLoaded().ToString(); + } + + if (!_jobs_fine_tune_items.ContainsKey(Job.Guid) && Job.JobFineTuningStatus == BL.Enumerations.FineTuningStatuses.PendingApproval) + { + Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Unspecified; + } + + if (_job_to_load_intent == JobNavigationIntent.NewJob) + { + IsJobDetailsExpanded = true; + } + + LogManager.Log($"Job editing state = '{Job.JobEditingState}'."); + + if (Job.JobEditingState == BL.Enumerations.EditingStates.SampleDye && Job.JobSampleDyeStatus == BL.Enumerations.SampleDyeStatuses.PendingApproval) + { + LogManager.Log("Directing view to display sample dye region."); + View.DisplaySampleDye(); + } + else if (Job.JobEditingState == BL.Enumerations.EditingStates.FineTuning && Job.JobFineTuningStatus == BL.Enumerations.FineTuningStatuses.PendingApproval) + { + LogManager.Log("Directing view to display fine tuning region."); + View.DisplayFineTuning(); + } + + ValidateBrushStops(); + + RegisterJobBrushStopsEvents(); + + DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); + } + catch (Exception ex) + { + IsFree = true; + LogManager.Log(ex, $"Error loading job '{(_job_to_load != null ? _job_to_load.Name : "null")}'"); + await NotificationProvider.ShowError("An error occurred while trying to load the selected job."); + _can_navigate_back = true; + await NavigationManager.NavigateBack(); + } + finally + { + IsFree = true; + } + } + + private void Job_NameChanged(object sender, string e) + { + DyeCommand.RaiseCanExecuteChanged(); + } + + /// + /// Saves the job. + /// + private async void SaveJob(bool displayNotification = true) + { + try + { + if (Job.Validate(_db)) + { + LogManager.Log("Saving job..."); + + if (!String.IsNullOrWhiteSpace(CustomersFilter)) + { + if (!Customers.Exists(x => x.Name == CustomersFilter)) + { + var newCustomer = new Customer() + { + OrganizationGuid = MachineProvider.Machine.OrganizationGuid, + Name = CustomersFilter, + }; + + _db.Customers.Add(newCustomer); + + Job.Customer = newCustomer; + } + } + + Job.LastUpdated = DateTime.UtcNow; + Job.IsSynchronized = false; + Job.JobStatus = BL.Enumerations.JobStatuses.Draft; + Job.MarkModified(_db); + await _db.SaveChangesAsync(); + _current_job_string = Job.ToJobFileWhenLoaded().ToString(); + + if (displayNotification) + { + await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); + } + + RaiseMessage(new JobSavedMessage() { Job = Job }); + } + else + { + await NotificationProvider.ShowError($"Error saving job. {Job.ValidationErrors.FirstOrDefault()}"); + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving job '{Job.Name}'."); + await NotificationProvider.ShowError("An error occurred while trying to save the job."); + } + } + + /// + /// Removes the job. + /// + private async void RemoveJob() + { + try + { + LogManager.Log("Removing job..."); + + if (await NotificationProvider.ShowQuestion("Are you sure you want to delete the this job?")) + { + await Job.DeleteCascadeAsync(_db); + RaiseMessage(new JobRemovedMessage() { Job = Job }); + _can_navigate_back = true; + await NavigationManager.NavigateBack(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error removing job '{Job.Name}'."); + await NotificationProvider.ShowError("An error occurred while trying to remove the job."); + } + } + + /// + /// Starts the job. + /// + private async void StartJob() + { + if (startingJob) return; + + try + { + Debug.WriteLine("Job Starting..."); + startingJob = true; + LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); + var handler = await PrintingManager.Print(Job, _db); + await NavigationManager.NavigateTo(nameof(JobProgressView)); + startingJob = false; + } + catch (InsufficientLiquidQuantityException) + { + //Ignore.. + } + catch (OperationCanceledException) + { + //Ignore.. + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not start the current job."); + await NotificationProvider.ShowError($"{ex.Message}."); + } + finally + { + startingJob = false; + } + } + + /// + /// Determines whether this instance [can start job]. + /// + private bool CanStartJob() + { + try + { + return Job != null && Job.Validate(_db) && !Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent && !x.IsWhite).ToList().Exists(x => x.IsOutOfGamut || (x.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume && x.IsLiquidVolumesOutOfRange)); + } + catch (Exception ex) + { + Debug.WriteLine(ex); + return false; + } + } + + #endregion + + #region RML Changed + + private async void OnSelectedRmlChanged() + { + await LoadRML(SelectedRML); + } + + private async Task LoadRML(Rml rml) + { + if (rml != null) + { + if (Job.Rml != rml || rml.Cct == null) + { + bool updateVolumes = Job.Rml != rml; + + Job.Rml = await new RmlBuilder(_db) + .Set(rml.Guid) + .WithActiveParametersGroup() + .WithCCT() + .WithCAT(MachineProvider.Machine.Guid) + .WithLiquidFactors() + .WithSpools() + .BuildAsync(); + + foreach (var segment in Job.Segments) + { + SetSegmentLiquidVolumes(segment); + } + + GetLubricationLevel(); + await SetSpoolTension(rml); + + if (updateVolumes) + { + NotificationProvider.SetGlobalBusyMessage("Updating job liquid volumes..."); + foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) + { + try + { + var output = await _converter.ConvertAsync(stop, false, false); + output.ApplyOnBrushStopVolumesOnly(stop); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.Segment.SegmentIndex}, stop {stop.StopIndex}."); + } + } + NotificationProvider.ReleaseGlobalBusyMessage(); + } + } + } + } + + #endregion + + #region Segments Management + + /// + /// Adds a new solid segment. + /// + private Segment AddSolidSegment() + { + try + { + LogManager.Log("Adding new solid segment..."); + var s = Job.AddSolidSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); + SetSegmentLiquidVolumes(s); + RegisterJobBrushStopsEvents(); + return s; + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not add a new solid segment."); + NotificationProvider.ShowError("An error occurred while trying to add a new segment."); + return null; + } + } + + /// + /// Adds a new gradient segment. + /// + private Segment AddGradientSegment() + { + try + { + LogManager.Log("Adding new gradient segment..."); + var s = Job.AddGradientSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 10); + SetSegmentLiquidVolumes(s); + RegisterJobBrushStopsEvents(); + return s; + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not add a new gradient segment."); + NotificationProvider.ShowError("An error occurred while trying to add a new segment."); + return null; + } + } + + /// + /// Called when a segment has been dragged and dropped into another segment. + /// + /// The dragged job. + /// The dropped job. + private void DragAndDropSegment(Segment draggedSegment, Segment droppedSegment) + { + LogManager.Log($"Segment Drag & Drop '{draggedSegment.SegmentIndex}' => '{droppedSegment.SegmentIndex}'."); + + if (draggedSegment.SegmentIndex > droppedSegment.SegmentIndex) + { + draggedSegment.SegmentIndex = droppedSegment.SegmentIndex - 1; + } + else + { + draggedSegment.SegmentIndex = droppedSegment.SegmentIndex + 1; + } + + ArrangeSegmentsIndices(); + } + + /// + /// Removes the segment. + /// + /// The segment. + private async void RemoveSegment(Segment segment) + { + if (Job.Segments.Count > 1) + { + try + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to remove the selected segment?")) + { + LogManager.Log($"Removing job segment {segment.SegmentIndex}"); + + segment.BrushStops.ToList().ForEach(x => + { + x.ColorSpaceChanged -= Stop_ColorSpaceChanged; + _db.BrushStops.Remove(x); + }); + _db.Segments.Remove(segment); + + ArrangeSegmentsIndices(); + + DyeCommand.RaiseCanExecuteChanged(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not remove segment."); + await NotificationProvider.ShowError("An error occurred while trying to add a new segment."); + } + } + else + { + await NotificationProvider.ShowInfo("A job must contain at least one color segment."); + } + } + + /// + /// Sets the segment liquid volumes. + /// + /// The segment. + private void SetSegmentLiquidVolumes(Segment segment) + { + foreach (var stop in segment.BrushStops) + { + stop.SetLiquidVolumes(Job.Machine.Configuration, Job.Rml, Job.Rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + + var lub = stop.LiquidVolumes.FirstOrDefault(x => x.IdsPack.LiquidType.Code == (int)BL.Enumerations.LiquidTypes.Lubricant); + if (lub != null) + { + lub.Volume = 100; + } + } + } + + private void ArrangeSegmentsIndices() + { + int index = 1; + + foreach (var segment in Job.Segments.OrderBy(x => x.SegmentIndex)) + { + segment.SegmentIndex = index++; + } + + SegmentsCollectionView.Refresh(); + } + + #endregion + + #region Brush Stops Management + + private void RegisterJobBrushStopsEvents() + { + if (Job != null) + { + foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).ToList()) + { + stop.ColorSpaceChanged -= Stop_ColorSpaceChanged; + stop.ColorSpaceChanged += Stop_ColorSpaceChanged; + + stop.ColorCatalogChanged -= Stop_ColorCatalogChanged; + stop.ColorCatalogChanged += Stop_ColorCatalogChanged; + } + } + } + + private void Stop_ColorSpaceChanged(object sender, ColorSpace colorSpace) + { + BrushStop stop = sender as BrushStop; + stop.Segment.BrushStops.Where(x => x != stop).ToList().ForEach(x => x.ColorSpace = stop.ColorSpace); + + DyeCommand.RaiseCanExecuteChanged(); + } + + private void Stop_ColorCatalogChanged(object sender, ColorCatalog catalog) + { + BrushStop stop = sender as BrushStop; + + if (stop.ColorSpace != null && stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) + { + if (stop.ColorCatalogsItem != null) + { + try + { + if (catalog != null && catalog.AllItemsOrdered.Count > 0) + { + stop.ColorCatalogsItem = catalog.GetClosestItem(stop.ColorCatalogsItem.Color); + } + else + { + stop.ColorCatalogsItem = null; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error getting closest catalog color."); + stop.ColorCatalogsItem = null; + } + } + } + } + + /// + /// Adds a new brush stop to the specified segment. + /// + /// The segment. + private void AddBrushStop(Segment segment) + { + LogManager.Log($"Adding new brush stop to segment {segment.SegmentIndex}."); + segment.AddBrushStop(); + SetSegmentLiquidVolumes(segment); + RegisterJobBrushStopsEvents(); + } + + /// + /// Removes the brush stop. + /// + /// The brush stop. + private void RemoveBrushStop(BrushStop brushStop) + { + if (brushStop.Segment.BrushStops.Count > 2) + { + LogManager.Log($"removing brush stop {brushStop.StopIndex} from segment {brushStop.Segment.SegmentIndex}."); + var segment = brushStop.Segment; + brushStop.ColorSpaceChanged -= Stop_ColorSpaceChanged; + _db.BrushStops.Remove(brushStop); + ArrangeBrushStopsIndices(segment); + } + else + { + NotificationProvider.ShowInfo("Gradient segments must contain at least two colors."); + } + } + + /// + /// Invokes the color adjustment for the specified brush stop. + /// + /// The brush stop. + private async void InvokeColorAdjustmentForBrushStop(BrushStop brushStop) + { + try + { + LogManager.Log($"Invoking triplet color adjustment dialog for brush stop {brushStop.StopIndex} at segment {brushStop.Segment.SegmentIndex}."); + + LogManager.Log("Retrieving color conversion suggestions for brush stop..."); + PMR.ColorLab.ConversionOutput conversionOutput = null; + + if (brushStop.IsOutOfGamut) + { + conversionOutput = _converter.Convert(brushStop, false); + } + + BasicColorCorrectionViewVM vm = null; + List suggestions = null; + + if (brushStop.IsOutOfGamut) + { + vm = await NotificationProvider.ShowDialog(new BasicColorCorrectionViewVM() + { + InvalidBrushStop = brushStop, + Suggestions = new List() { new ColorConversionSuggestion(conversionOutput.SingleCoordinates, 0, 0) }, + }); + } + + if (vm == null || vm.Result == BasicColorCorrectionViewVM.ColorCorrectionDialogResult.MoreOptions) + { + NotificationProvider.SetGlobalBusyMessage("Generating color hive..."); + + await Task.Factory.StartNew(() => + { + conversionOutput = _converter.Convert(brushStop, true); + + suggestions = conversionOutput.CreateHiveSuggestions(); + + if (vm == null) + { + var center = suggestions.GetCenterSuggestion(); + center.Coordinates.Red = brushStop.Red; + center.Coordinates.Green = brushStop.Green; + center.Coordinates.Blue = brushStop.Blue; + + center.Coordinates.L = brushStop.L; + center.Coordinates.A = brushStop.A; + center.Coordinates.B = brushStop.B; + } + }); + + NotificationProvider.ReleaseGlobalBusyMessage(); + LogManager.Log("Invoking hive color conversion dialog..."); + vm = await NotificationProvider.ShowDialog(new AdvancedColorCorrectionViewVM() + { + InvalidBrushStop = brushStop, + Suggestions = suggestions, + IsOutOfGamut = brushStop.IsOutOfGamut, + }); + } + + if (vm.Result == BasicColorCorrectionViewVM.ColorCorrectionDialogResult.Confirmed) + { + LogManager.Log($"Color suggestion selected: {vm.SelectedSuggestion.Color.ToString()}."); + + if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + { + brushStop.Red = vm.SelectedSuggestion.Coordinates.Red; + brushStop.Green = vm.SelectedSuggestion.Coordinates.Green; + brushStop.Blue = vm.SelectedSuggestion.Coordinates.Blue; + } + else if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) + { + brushStop.L = vm.SelectedSuggestion.Coordinates.L; + brushStop.A = vm.SelectedSuggestion.Coordinates.A; + brushStop.B = vm.SelectedSuggestion.Coordinates.B; + } + else if (brushStop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + vm.SelectedSuggestion.ApplyOnBrushStop(brushStop); + } + + brushStop.Corrected = true; + brushStop.IsOutOfGamut = false; + brushStop.OutOfGamutChecked = true; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error while invoking color adjustment dialog."); + await NotificationProvider.ShowError("An error occurred while trying to convert the selected color."); + } + finally + { + NotificationProvider.ReleaseGlobalBusyMessage(); + DyeCommand.RaiseCanExecuteChanged(); + } + } + + /// + /// Called when the brush stop field value has been changed (This called from the view!). + /// + /// The brush stop. + [HandleProcessCorruptedStateExceptions] + public void OnBrushStopFieldValueChanged(BrushStop stop) + { + if (stop != null && stop.ColorSpace != null) + { + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Catalog) + { + DyeCommand.RaiseCanExecuteChanged(); + return; + } + + _volumeConversionTimer.ResetReplace(() => + { + + try + { + var output = _converter.Convert(stop, false); + + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + stop.Red = output.SingleCoordinates.Red; + stop.Green = output.SingleCoordinates.Green; + stop.Blue = output.SingleCoordinates.Blue; + stop.L = output.SingleCoordinates.L; + stop.A = output.SingleCoordinates.A; + stop.B = output.SingleCoordinates.B; + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) + { + output.ApplyOnBrushStopVolumesOnly(stop); + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + { + output.ApplyOnBrushStopVolumesOnly(stop); + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + + try + { + var closestItem = AvailableCatalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(stop.Color); + stop.ColorCatalog = closestItem.ColorCatalogsGroup.ColorCatalog; + stop.ColorCatalogsItem = closestItem; + } + catch { } + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + } + finally + { + InvokeUI(() => DyeCommand.RaiseCanExecuteChanged()); + } + + }); + + } + } + + /// + /// Opens the twine catalog for the specified brush stop. + /// + /// The stop. + private async void OpenCatalog(BrushStop stop) + { + if (stop.ColorCatalog == null) + { + await NotificationProvider.ShowInfo("Please select a color catalog first."); + return; + } + + var catalogItem = await NavigationManager.NavigateForResult(new TwineCatalogNavigationObject() + { + SelectedItem = stop.ColorCatalogsItem, + Catalog = stop.ColorCatalog + }, true); + + if (catalogItem != null) + { + stop.ColorCatalogsItem = catalogItem; + } + } + + private void ArrangeBrushStopsIndices(Segment segment) + { + for (int i = 0; i < segment.BrushStops.Count; i++) + { + segment.BrushStops[i].StopIndex = i + 1; + } + } + + private bool ValidateBrushStops() + { + return Job.Segments.SelectMany(x => x.BrushStops).ToList().All(x => x.Validate(_db)); + } + + #endregion + + #region Job Selection Message + + /// + /// Handles the job selected message. + /// + /// The message. + private void HandleJobSelectedMessage(JobSelectedMessage message) + { + _job_to_load = message.Job; + } + + #endregion + + #region Sample Dye + + /// + /// Starts a sample dye. + /// + private async void StartSampleDye() + { + try + { + LogManager.Log("Sample dye command pressed..."); + + await PrintingManager.PrintSample(Job, _db); + + await NavigationManager.NavigateTo(nameof(JobProgressView)); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); + await NotificationProvider.ShowError(ex.Message); + } + } + + /// + /// Sets the job status back to not approved. + /// + private void RepeatSampleDye() + { + LogManager.Log("Repeat sample dye command pressed..."); + Job.JobEditingState = BL.Enumerations.EditingStates.Default; + Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Unspecified; + } + + /// + /// Approves the sample dye. + /// + private void ApproveSampleDye() + { + LogManager.Log("Approve sample dye command pressed..."); + + Job.JobEditingState = BL.Enumerations.EditingStates.Default; + Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Approved; + + Job.SampleDyeApproveDate = DateTime.UtcNow; + SaveJob(false); + } + + /// + /// Dyes another sample. + /// + private void DyeAnotherSample() + { + LogManager.Log("Dye another sample dye command pressed..."); + + Job.JobEditingState = BL.Enumerations.EditingStates.Default; + Job.JobSampleDyeStatus = BL.Enumerations.SampleDyeStatuses.Unspecified; + } + + #endregion + + #region Fine Tuning + + /// + /// Synchronizes the fine tune items to brush stops. + /// + private async void SyncFineTuneItemsToBrushStops(bool displayBusy = false) + { + try + { + if (Job != null) + { + if (_jobs_fine_tune_items.ContainsKey(Job.Guid)) + { + FineTuneItems = _jobs_fine_tune_items[Job.Guid].ToObservableCollection(); + } + else + { + if (displayBusy) + { + NotificationProvider.SetGlobalBusyMessage("Generating suggestions..."); + } + + FineTuneItems.Clear(); + + foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.IsTransparent).Where(x => x.ColorSpace.Space == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace.Space == BL.Enumerations.ColorSpaces.LAB).DistinctBy(x => x.Color)) + { + var conversionoutput = await _converter.ConvertAsync(stop, true); + FineTuneItem item = new FineTuneItem(conversionoutput); + item.BrushStop = stop; + item.BrushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.Color == stop.Color).ToList(); + item.SelectedSuggestion = item.Suggestions.GetCenterSuggestion(); + item.SelectedChanged += () => StartFineTuningCommand.RaiseCanExecuteChanged(); + FineTuneItems.Add(item); + } + + _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); + + NotificationProvider.ReleaseGlobalBusyMessage(); + } + + ApprovalFineTuneItems = FineTuneItems.Where(x => x.IsSelected).ToObservableCollection(); + + StartFineTuningCommand.RaiseCanExecuteChanged(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error while trying to synchronize fine tuning items with brush stops."); + } + finally + { + NotificationProvider.ReleaseGlobalBusyMessage(); + } + } + + /// + /// Invokes the fine tuning palette dialog. + /// + /// The fine tune item. + private async void InvokeFineTuningPalette(FineTuneItem fineTuneItem) + { + LogManager.Log("Invoke fine tuning palette command pressed..."); + + try + { + FineTuningPaletteViewVM vm = new FineTuningPaletteViewVM(fineTuneItem, Job); + await NotificationProvider.ShowDialog(vm); + + if (vm.DialogResult) + { + fineTuneItem.Suggestions = vm.Suggestions; + fineTuneItem.SelectedSuggestion = vm.SelectedSuggestion; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error invoking the fine tunning palette"); + await NotificationProvider.ShowError("An error occurred while trying to display the fine tunning palette."); + } + finally + { + NotificationProvider.ReleaseGlobalBusyMessage(); + } + } + + /// + /// Resets the fine tuning. + /// + private void ResetFineTuning(bool displayBusy = false) + { + if (Job != null && _jobs_fine_tune_items.ContainsKey(Job.Guid)) + { + _jobs_fine_tune_items.Remove(Job.Guid); + } + + SyncFineTuneItemsToBrushStops(displayBusy); + } + + /// + /// Starts the fine tuning. + /// + private async void StartFineTuning() + { + try + { + LogManager.Log("Start fine tunning job command pressed..."); + + _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); + + await PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); + + await NavigationManager.NavigateTo(nameof(JobProgressView)); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error executing fine tuning job."); + await NotificationProvider.ShowError(ex.Message); + } + } + + /// + /// Approves the fine tuning. + /// + private void ApproveFineTuning() + { + LogManager.Log("Approve fine tuning command pressed."); + + Job.JobEditingState = BL.Enumerations.EditingStates.Default; + Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Approved; + + foreach (var item in ApprovalFineTuneItems) + { + foreach (var stop in item.BrushStops) + { + stop.Color = item.SelectedSuggestion.Color; + } + } + + + Job.FineTuningApproveDate = DateTime.UtcNow; + SaveJob(false); + + if (_jobs_fine_tune_items.ContainsKey(Job.Guid)) + { + _jobs_fine_tune_items.Remove(Job.Guid); + } + + SyncFineTuneItemsToBrushStops(); + } + + /// + /// Repeats the fine tuning. + /// + private void RepeatFineTuning() + { + LogManager.Log("Repeat fine tuning command pressed."); + + Job.JobEditingState = BL.Enumerations.EditingStates.Default; + Job.JobFineTuningStatus = BL.Enumerations.FineTuningStatuses.Unspecified; + } + + #endregion + + #region Out Of Gamut Check Thread + + /// + /// Iterates over all brush stops and checks for out of gamut. + /// + [HandleProcessCorruptedStateExceptions] + private void CheckGamutThreadMethod() + { + while (true) + { + Thread.Sleep(500); + + if (Job != null && Job.Rml.Cct != null && IsVisible) + { + var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace != null).Where(x => (x.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB || x.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) && !x.Corrected && !x.OutOfGamutChecked).ToList(); + + foreach (var stop in brushStops) + { + try + { + stop.IsOutOfGamut = _converter.IsOutOfGamut(stop); + stop.OutOfGamutChecked = true; + } + catch (AccessViolationException) + { + LogManager.Log($"Out of gamut check failed for brush stop {stop.StopIndex} at segment {stop.Segment.SegmentIndex}.", LogCategory.Warning); + continue; + } + catch + { + LogManager.Log($"Out of gamut check failed for brush stop {stop.StopIndex} at segment {stop.Segment.SegmentIndex}.", LogCategory.Warning); + } + } + + if (brushStops.Count > 0) + { + InvokeUI(() => + { + DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); + }); + } + } + } + } + + #endregion + + #region Lubrication Level + + private void GetLubricationLevel() + { + if (Job != null) + { + LubricationLevel = Settings.LubricationLevels.FirstOrDefault(x => x.RmlGuid == Job.RmlGuid); + } + else + { + LubricationLevel = null; + } + } + + #endregion + + #region Spool Tension + + private async Task SetSpoolTension(Rml rml) + { + if (rml != null && _db != null) + { + BtsrSpoolTension = await rml.GetRequiredBtsrSpoolTension(_db, Job.SpoolType); + } + } + + #endregion + + #region Export Embroidery + + private async void ExportEmbroidery() + { + try + { + if (!StorageProvider.IsConnected) + { + await NotificationProvider.ShowError("No storage device connected."); + return; + } + + var result = await NavigationManager. + NavigateForResult( + new Storage.Models.StorageNavigationRequest() + { + Intent = Storage.Models.StorageNavigationIntent.SaveFile, + DefaultFileName = Job.Name + Path.GetExtension(Job.EmbroideryFileName), + Filter = Path.GetExtension(Job.EmbroideryFileName), + Title = "Export Embroidery File", + }); + + if (result != null) + { + File.WriteAllBytes(Path.HasExtension(result.Path) ? result.Path : result.Path + Path.GetExtension(Job.EmbroideryFileName), Job.EmbroideryFileData); + await NotificationProvider.ShowSuccess("Embroidery file exported successfully."); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting embroidery file."); + await NotificationProvider.ShowError("An error occurred while trying to save the selected embroidery file."); + } + } + + #endregion + + #region IPPC ViewModel Overrides + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); + + MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; + } + + private void MachineOperator_PrintingEnded(object sender, Integration.Operation.PrintingEventArgs e) + { + if (IsVisible) + { + _start_printing_btn.Push(); + } + } + + /// + /// Called when the navigation system has navigated to this VM view. + /// + public override void OnNavigatedTo() + { + if (!MachineProvider.MachineOperator.IsPrinting) + { + _start_printing_btn.Push(); + } + + base.OnNavigatedTo(); + LoadJob(); + } + + /// + /// Called when the navigation system has navigated from this VM view. + /// + public override void OnNavigatedFrom() + { + _start_printing_btn.Pop(); + + base.OnNavigatedFrom(); + _job_to_load_intent = JobNavigationIntent.Default; + } + + /// + /// Called before the navigation system navigates back from this object. + /// Return false to abort the navigation. + /// + /// + public async override Task OnNavigateBackRequest() + { + bool result = true; + + if (!IsFree) return false; + + if (!_can_navigate_back) + { + bool jobChainged = false; + + if (Job != null) + { + string job_string = Job.ToJobFileWhenLoaded().ToString(); + jobChainged = job_string != _current_job_string; + } + + if (jobChainged) + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to exit this job without saving changes?")) + { + Job = null; + SegmentsCollectionView = null; + } + else + { + result = false; + } + } + else + { + Job = null; + SegmentsCollectionView = null; + } + } + + return result; + } + + public override void OnApplicationReady() + { + base.OnApplicationReady(); + + _start_printing_btn = new StartPrintingButton(DyeCommand, MachineProvider.MachineOperator); + } + #endregion + + #region INavigationObjectReceiver + + public void OnNavigatedToWithObject(JobNavigationObject e) + { + _job_to_load_intent = e.Intent; + _job_to_load = e.Job; + } + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs new file mode 100644 index 000000000..a51c44457 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs @@ -0,0 +1,1073 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Tango.Core.DI; +using Tango.DragAndDrop; +using Tango.PPC.Common; +using Tango.PPC.Common.Messages; +using Tango.PPC.Jobs.Dialogs; +using Tango.PPC.Jobs.Messages; +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; +using Tango.Settings; +using Tango.Integration.ExternalBridge; +using System.Windows.Media; +using Tango.PMR.TCC; +using Tango.Pulse; +using System.Windows.Media.Imaging; +using Tango.Touch.Components; +using Tango.PPC.Jobs.ViewContracts; +using Tango.Core.ExtensionMethods; +using Tango.PPC.Common.Synchronization; +using Tango.PPC.Jobs.NotificationItems; +using Tango.PPC.Storage.Models; +using Tango.BL.Helpers; +using Tango.ColorConversion; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the jobs list view model. + /// + /// + public class JobsViewVM : PPCViewModel + { + private ObservablesContext _db; //Holds the db context for the job list. + private ObservableCollection _catalogs; //Holds the available color catalogs for the site. + private ObservableCollection _rmls; //Holds the available RML for the site. + private List _colorSpaces; //Holds the available color spaces. + private bool _isJobsSynchronizationNotificationActive; + + public enum JobsCategory + { + Draft, + History + } + + #region Properties + + private ObservableCollection _jobs; + /// + /// Gets or sets the collection of jobs. + /// + public ObservableCollection Jobs + { + get { return _jobs; } + set { _jobs = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _draftJobsCollectionView; + /// + /// Gets or sets the jobs collection view. + /// + public ICollectionView DraftJobsCollectionView + { + get { return _draftJobsCollectionView; } + set + { + _draftJobsCollectionView = value; + RaisePropertyChangedAuto(); + } + } + + private ICollectionView _historyJobsCollectionView; + /// + /// Gets or sets the jobs collection view. + /// + public ICollectionView HistoryJobsCollectionView + { + get { return _historyJobsCollectionView; } + set + { + _historyJobsCollectionView = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection _selectedJobs; + /// + /// Gets or sets the selected jobs. + /// + public ObservableCollection SelectedJobs + { + get { return _selectedJobs; } + set { _selectedJobs = value; RaisePropertyChangedAuto(); } + } + + private bool _isLoadingJobs; + /// + /// Gets or sets a value indicating whether this instance is loading jobs. + /// + public bool IsLoadingJobs + { + get { return _isLoadingJobs; } + set { _isLoadingJobs = value; RaisePropertyChangedAuto(); } + } + + private bool _isMultiSelecting; + /// + /// Gets or sets a value indicating whether this the jobs list is in multi select mode. + /// + public bool IsMultiSelecting + { + get { return _isMultiSelecting; } + set { _isMultiSelecting = value; RaisePropertyChangedAuto(); } + } + + private int _selectedCategoryIndex; + /// + /// Gets or sets the index of the selected category. + /// + public int SelectedCategoryIndex + { + get { return _selectedCategoryIndex; } + set + { + _selectedCategoryIndex = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(SelectedCategory)); + } + } + + /// + /// Gets or sets the selected category. + /// + public JobsCategory SelectedCategory + { + get { return (JobsCategory)SelectedCategoryIndex; } + set + { + if (SelectedCategoryIndex != value.ToInt32()) + { + SelectedCategoryIndex = value.ToInt32(); + Filter = null; + } + } + } + + private String _filter; + /// + /// Gets or sets the search filter. + /// + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private ICollectionFilter _collectionFilter; + public ICollectionFilter CollectionFilter + { + get { return _collectionFilter; } + set { _collectionFilter = value; RaisePropertyChangedAuto(); } + } + + + #endregion + + #region Commands + + /// + /// Gets or sets the job selected command. + /// + public RelayCommand JobSelectedCommand { get; set; } + + /// + /// Gets or sets the job drag and drop command. + /// + public RelayCommand JobDragedDroppedCommand { get; set; } + + /// + /// Gets or sets the clear selection command. + /// + public RelayCommand ClearSelectionCommand { get; set; } + + /// + /// Gets or sets the add job command. + /// + public RelayCommand AddJobCommand { get; set; } + + /// + /// Gets or sets the delete jobs command. + /// + public RelayCommand DeleteJobsCommand { get; set; } + + /// + /// Gets or sets the clone jobs command. + /// + public RelayCommand CloneJobsCommand { get; set; } + + /// + /// Gets or sets the export job command. + /// + public RelayCommand ExportJobCommand { get; set; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public JobsViewVM() + { + Jobs = new ObservableCollection(); + SelectedJobs = new ObservableCollection(); + + JobSelectedCommand = new RelayCommand((x) => SelectJob(x as Job)); + JobDragedDroppedCommand = new RelayCommand((e) => + { + Job draggedJob = e.Draggable.DataContext as Job; + Job droppedJob = e.Droppable.DataContext as Job; + + DragAndDropJob(draggedJob, droppedJob); + }); + + ClearSelectionCommand = new RelayCommand(ClearSelection); + AddJobCommand = new RelayCommand(() => AddNewJob()); + DeleteJobsCommand = new RelayCommand(() => DeleteJobs(SelectedJobs)); + CloneJobsCommand = new RelayCommand(() => CloneJobs(SelectedJobs)); + ExportJobCommand = new RelayCommand(ExportJob); + + RegisterForMessage(HandleJobRemovedMessage); + RegisterForMessage(HandleJobSavedMessage); + RegisterForMessage((x) => Filter = null); + + CollectionFilter = new DefaultCollectionFilter(); + CollectionFilter.RegisterFilter(item => + { + var job = item as Job; + + if (job != null) + { + if (String.IsNullOrEmpty(Filter)) + { + return true; + } + else + { + return (job.Name.ToLower().Contains(Filter.ToLower()) || (job.Customer != null && job.Customer.Name.ToLower().StartsWith(Filter.ToLower()))); + } + } + else + { + return true; + } + }); + } + + #endregion + + #region Drag & Drop + + /// + /// Called when a job has been dragged and dropped into another job. + /// + /// The dragged job. + /// The dropped job. + private void DragAndDropJob(Job draggedJob, Job droppedJob) + { + LogManager.Log($"Job Drag & Drop '{draggedJob.Name}' => '{droppedJob.Name}'."); + + if (draggedJob.JobIndex > droppedJob.JobIndex) + { + draggedJob.JobIndex = droppedJob.JobIndex - 1; + } + else + { + draggedJob.JobIndex = droppedJob.JobIndex + 1; + } + + int index = 1; + + foreach (var job in Jobs.OrderBy(x => x.JobIndex)) + { + job.JobIndex = index++; + } + + DraftJobsCollectionView.Refresh(); + } + + #endregion + + #region Job Selection & Loading + + /// + /// Selects the job. + /// + /// The job. + public async void SelectJob(Job job, bool directlyToEdit = false) + { + //if (!ApplicationManager.IsInTechnicianMode && job.ColorSpace != null && job.ColorSpace.Code == ColorSpaces.Volume.ToInt32()) + //{ + // await NotificationProvider.ShowError("The selected job is supported only in technician mode."); + // return; + //} + + LogManager.Log($"Job '{job.Name}' selected."); + + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); + + if (!directlyToEdit && MachineProvider.MachineOperator.CanPrint) + { + await NavigationManager.NavigateWithObject(new JobSummeryNavigationObject() + { + Context = _db, + Job = job, + }); + } + else + { + await NavigationManager.NavigateTo(nameof(JobView)); + } + } + + /// + /// Loads the jobs from database. + /// + public void LoadJobs(Action onCompleted = null) + { + try + { + LogManager.Log("Loading machine jobs..."); + + Task.Factory.StartNew(() => + { + IsLoadingJobs = true; + + Thread.Sleep(500); + + _db = ObservablesContext.CreateDefault(); + + _colorSpaces = _db.ColorSpaces.ToList(); + + var jobs = new JobsCollectionBuilder(_db).Set(x => x.MachineGuid == MachineProvider.Machine.Guid).WithSegments().WithBrushStops().WithCustomer().WithColorSpace().Build(); + + InvokeUI(() => + { + Jobs = jobs; + DraftJobsCollectionView = new ListCollectionView(Jobs); + DraftJobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + DraftJobsCollectionView.Filter = new Predicate(x => + { + var job = x as Job; + return job.JobStatus == JobStatuses.Draft; + }); + + + HistoryJobsCollectionView = new ListCollectionView(Jobs); + HistoryJobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); + HistoryJobsCollectionView.Filter = new Predicate(x => + { + var job = x as Job; + return job.JobStatus != JobStatuses.Draft; + }); + + IsLoadingJobs = false; + LogManager.Log("Machine jobs loaded!"); + onCompleted?.Invoke(); + }); + }); + } + catch (Exception ex) + { + LogManager.Log(ex); + NotificationProvider.ShowError("An error occurred while trying to load the machine jobs."); + } + } + + /// + /// Clears the job selection. + /// + public void ClearSelection() + { + SelectedJobs.Clear(); + IsMultiSelecting = false; + } + + /// + /// Adds a new job. + /// + private async void AddNewJob(Color? colorProfile = null, TwnFile twnFile = null) + { + try + { + LogManager.Log("Adding new job..."); + + var settings = SettingsManager.Default.GetOrCreate(); + + var machine = MachineProvider.Machine; + + JobCreationViewVM vm = new JobCreationViewVM( + Settings.SupportedJobTypes.Count > 0 ? Settings.SupportedJobTypes : Enum.GetValues(typeof(JobTypes)).Cast().ToList(), + Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x != ColorSpaces.CMYK).ToList() + ); + + if (_catalogs.Count == 0) + { + vm.SupportedColorSpaces.Remove(ColorSpaces.Catalog); + } + + CatalogSelectionViewVM catalogVM = new CatalogSelectionViewVM(_catalogs.ToList(), _catalogs.ToList().SingleOrDefault(x => x.Guid == settings.LastSelectedCatalogGuid)); + + if (settings.LastJobType != null) + { + vm.SelectedJobType = settings.LastJobType.Value; + } + else + { + vm.SelectedJobType = Settings.SupportedJobTypes.FirstOrDefault(); + } + + if (settings.LastJobColorSpace != null) + { + vm.SelectedColorSpace = settings.LastJobColorSpace.Value.IsUserSpace() ? settings.LastJobColorSpace.Value : ColorSpaces.Catalog; + } + else + { + var space = Settings.SupportedColorSpaces.FirstOrDefault(); + vm.SelectedColorSpace = space.IsUserSpace() ? space : ColorSpaces.Catalog; + } + + if (colorProfile != null || twnFile != null) + { + vm.SupportedColorSpaces = new List() { ColorSpaces.RGB }; + vm.SelectedColorSpace = vm.SupportedColorSpaces.First(); + } + + if (twnFile != null) + { + vm.SupportedJobTypes = new List() { JobTypes.Embroidery }; + vm.SelectedJobType = vm.SupportedJobTypes.First(); + } + + if (twnFile == null) + { + if (Settings.SupportedJobTypes.Count != 1 || Settings.SupportedColorSpaces.Count != 1) + { + vm = await NotificationProvider.ShowDialog(vm); + if (!vm.DialogResult) return; + + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + if (catalogVM.SelectedCatalog == null) + { + catalogVM.SelectedCatalog = _catalogs.FirstOrDefault(); + } + + if (_catalogs.Count == 0) + { + await NotificationProvider.ShowError("No color catalogs found. Please selected another color space."); + return; + } + else if (_catalogs.Count > 1) + { + catalogVM = await NotificationProvider.ShowDialog(catalogVM); + + if (!catalogVM.DialogResult) + { + return; + } + } + } + } + else + { + vm.SelectedJobType = Settings.SupportedJobTypes.First(); + vm.SelectedColorSpace = Settings.SupportedColorSpaces.First(); + } + } + + settings.LastJobType = vm.SelectedJobType; + settings.LastJobColorSpace = vm.SelectedColorSpace; + + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + settings.LastSelectedCatalogGuid = catalogVM.SelectedCatalog.Guid; + } + + settings.Save(); + + Job job = new Job(); + job.LastUpdated = DateTime.UtcNow; + job.JobSource = JobSource.Local; + job.Name = "untitled"; + job.NumberOfHeads = 1; + job.NumberOfUnits = 1; + job.SampleUnitsOrMeters = 1; + job.CreationDate = DateTime.UtcNow; + job.JobStatus = JobStatuses.Draft; + job.JobType = vm.SelectedJobType; + job.EnableLubrication = true; + job.ColorSpaceGuid = Adapter.ColorSpaces.FirstOrDefault(x => x.Code == vm.SelectedColorSpace.ToInt32()).Guid; + job.ColorSpace = _colorSpaces.SingleOrDefault(x => x.Guid == job.ColorSpaceGuid); + job.MachineGuid = MachineProvider.Machine.Guid; + job.UserGuid = null; + job.RmlGuid = (Settings.DefaultRmlGuid != null && _rmls.Select(x => x.Guid).Contains(Settings.DefaultRmlGuid)) ? Settings.DefaultRmlGuid : _rmls.FirstOrDefault().Guid; + job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid; + job.SpoolTypeGuid = Settings.DefaultSpoolTypeGuid != null ? Settings.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; + + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + job.ColorCatalogGuid = catalogVM.SelectedCatalog.Guid; + } + + if (Jobs.Count > 0) + { + job.JobIndex = Jobs.Max(x => x.JobIndex) + 1; + } + + if (colorProfile == null) + { + var segment = job.AddSolidSegment(Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 100); + + try + { + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + segment.BrushStops[0].ColorCatalogGuid = catalogVM.SelectedCatalog.Guid; + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error setting first segment brush stop color catalog guide."); + } + } + else + { + job.AddSolidSegment(colorProfile.Value, Settings.DefaultSegmentLength > 0 ? Settings.DefaultSegmentLength : 100); + job.Name = $"SnapMatch {colorProfile.Value.R}, {colorProfile.Value.G}, {colorProfile.Value.B}"; + } + + if (twnFile != null) + { + job.Name = twnFile.Name; + job.NumberOfUnits = Math.Max(twnFile.NumberOfCopies, 1); + job.EmbroideryFileName = twnFile.Name + "." + twnFile.EmbroideryFileFormat; + job.EmbroideryFileData = twnFile.EmbroideryFile; + job.EmbroideryJpeg = twnFile.ThumbnailData; + + job.Segments.Clear(); + + int index = 1; + + foreach (var segment in twnFile.Segments) + { + Segment s = new Segment(); + s.Job = job; + s.SegmentIndex = index++; + s.Name = "Embroidery Segment"; + s.Length = segment.Length / 100d; + + int sIndex = 1; + + foreach (var stop in segment.BrushStops) + { + BrushStop st = new BrushStop(); + st.Segment = s; + st.StopIndex = sIndex++; + st.OffsetPercent = stop.Offset * 100d; + st.Red = stop.R; + st.Green = stop.G; + st.Blue = stop.B; + st.ColorSpaceGuid = job.ColorSpaceGuid; + s.BrushStops.Add(st); + } + + job.Segments.Add(s); + } + } + + _db.Jobs.Add(job); + + await _db.SaveChangesAsync(); + + Jobs.Add(job); + + LogManager.Log($"Job {job.Name} added successfully."); + + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); + + await Task.Delay(200); + await NavigationManager.NavigateWithObject(new JobNavigationObject() + { + Job = job, + Intent = JobNavigationIntent.NewJob + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error creating new job."); + await NotificationProvider.ShowError("An error occurred while trying to add a new job."); + } + } + + /// + /// Deletes the specified jobs from db. + /// + /// The jobs. + private async void DeleteJobs(ObservableCollection jobs) + { + try + { + LogManager.Log($"Removing selected jobs:\n{jobs.Select(x => x.Name).ToList().ToJsonString()}"); + + if (await NotificationProvider.ShowQuestion("Are you sure you want to delete the selected jobs")) + { + foreach (var job in jobs) + { + await job.DeleteCascadeAsync(_db); + Jobs.Remove(job); + } + + await _db.SaveChangesAsync(); + ClearSelection(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error removing selected jobs."); + await NotificationProvider.ShowError("An error occurred while trying to remove the selected jobs."); + } + } + + /// + /// Clones the specified jobs. + /// + /// The jobs. + private async void CloneJobs(ObservableCollection jobs) + { + try + { + LogManager.Log($"Cloning selected jobs:\n{jobs.Select(x => x.Name).ToList().ToJsonString()}"); + + int index = Jobs.Max(x => x.JobIndex); + + List clonedJobs = new List(); + + foreach (var job in SelectedJobs) + { + var cloned = job.Clone(); + cloned.JobIndex = ++index; + _db.Jobs.Add(cloned); + clonedJobs.Add(cloned); + } + + await _db.SaveChangesAsync(); + + foreach (var job in clonedJobs) + { + Jobs.Add(job); + } + + ClearSelection(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error cloning selected jobs."); + await NotificationProvider.ShowError("An error occurred while trying to clone the selected jobs."); + } + } + + /// + /// Called when the search filter has been changed + /// + private void OnFilterChanged() + { + if (DraftJobsCollectionView != null && HistoryJobsCollectionView != null) + { + CollectionFilter.RaiseFilterChanged(); + View.ScrollToTop(); + } + } + + #endregion + + #region Message Handling + + /// + /// Handles the job removed message. + /// + /// The MSG. + private void HandleJobRemovedMessage(JobRemovedMessage msg) + { + try + { + LogManager.Log("JobRemovedMessage message received, removing job from list..."); + var job = Jobs.SingleOrDefault(x => x.Guid == msg.Job.Guid); + Jobs.Remove(job); + _db.Entry(job).State = System.Data.Entity.EntityState.Detached; + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not remove job"); + } + } + + /// + /// Handles the job saved message. + /// + /// The MSG. + private void HandleJobSavedMessage(JobSavedMessage msg) + { + LogManager.Log("JobSavedMessage message received."); + LoadJobs(); + } + + #endregion + + #region Override Methods + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + LoadJobs(); + + ExternalBridgeService.ColorProfileRequest += ExternalBridgeService_ColorProfileRequest; + } + + public async override void OnApplicationReady() + { + base.OnApplicationReady(); + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Job.Extension, HandleJobFileLoaded); + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.ColorProfile.Extension, HandleColorProfileFileLoaded); + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Pulse.Extension, HandlePulseFileLoaded); + StorageProvider.RegisterFileHandler(ExplorerFileDefinition.CsvFile.Extension, HandleCsvJobFileLoaded); + + //Load catalogs. + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + _catalogs = await new CatalogsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).BuildAsync(); + _rmls = await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync(); + } + + MachineDataSynchronizer.SynchronizationEnded += MachineDataSynchronizer_SynchronizationEnded; + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + JobViewVM._start_printing_btn?.Pop(); + Filter = null; + } + + #endregion + + #region Job Export + + private async void ExportJob() + { + var selected_job = SelectedJobs.FirstOrDefault(); + if (selected_job == null) return; + + var selectedJobs = SelectedJobs.ToList(); + + ClearSelection(); + + var result = await NavigationManager. + NavigateForResult( + new StorageNavigationRequest() + { + Intent = selectedJobs.Count == 1 ? StorageNavigationIntent.SaveFile : StorageNavigationIntent.SaveFiles, + DefaultFileName = selected_job.Name, + Filter = ExplorerFileDefinition.Job.Extension, + Title = selectedJobs.Count == 1 ? "Save Job File" : "Save Job Files", + }); + + if (result != null) + { + if (selectedJobs.Count == 1) + { + try + { + var jobFile = await selected_job.ToJobFile(); + + using (FileStream fs = new FileStream(result.Path + ExplorerFileDefinition.Job.Extension, FileMode.Create)) + { + jobFile.WriteTo(fs); + } + + await NotificationProvider.ShowSuccess("Job saved successfully."); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving job {selected_job.Name} to file."); + await NotificationProvider.ShowError($"An error occurred while trying to save the job.\n{ex.Message}"); + } + } + else + { + foreach (var job in selectedJobs) + { + try + { + var jobFile = await job.ToJobFile(); + + using (FileStream fs = new FileStream(Path.Combine(result.Path, jobFile.Name.ToValidFileName()) + ExplorerFileDefinition.Job.Extension, FileMode.Create)) + { + jobFile.WriteTo(fs); + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving job {job.Name} to file."); + await NotificationProvider.ShowError($"An error occurred while trying to save the job.\n{ex.Message}"); + } + } + + await NotificationProvider.ShowSuccess("Jobs saved successfully."); + } + } + } + + #endregion + + #region Handle Job File Loading From Storage + + private async void HandleJobFileLoaded(List jobFiles) + { + var vm = await NotificationProvider.ShowDialog(); + + if (vm.DialogResult) + { + using (ObservablesContext jobContext = ObservablesContext.CreateDefault()) + { + foreach (var jobFile in jobFiles) + { + try + { + JobFile jFile = JobFile.Parser.ParseFrom(File.ReadAllBytes(jobFile.Path)); + var job = await Job.FromJobFile(jFile, MachineProvider.Machine.Guid, null); + job.JobSource = JobSource.Local; + jobContext.Jobs.Add(job); + await jobContext.SaveChangesAsync(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error occurred while trying to import job from file {jobFile.Path}."); + await NotificationProvider.ShowError($"An error occurred while trying to import the selected job file.\n{ex.Message}"); + } + } + + LoadJobs(() => + { + //Editing of a job is currently deprecated due to enabling multiple job imports. + //if (vm.ImportAndEdit) + //{ + // var postJob = Jobs.SingleOrDefault(x => x.Guid == job.Guid); + // if (postJob != null) + // { + // SelectJob(postJob, true); + // } + //} + }); + } + } + } + + #endregion + + #region Handle CSV Job File Loading From Storage + + private async void HandleCsvJobFileLoaded(List files) + { + var item = files.FirstOrDefault(); + if (item == null) return; + + var vm = new ImportCsvJobViewVM(); + vm.Name = Path.GetFileNameWithoutExtension(item.Name); + await vm.Init(); + await NotificationProvider.ShowDialog(vm); + + if (vm.DialogResult && vm.SelectedRml != null) + { + try + { + NotificationProvider.SetGlobalBusyMessage("Importing job from file..."); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var segments = await SegmentsCsvHelper.FromFile(item.Path, MachineProvider.Machine, db); + + Job job = new Job(); + job.LastUpdated = DateTime.UtcNow; + job.JobSource = JobSource.Local; + job.Name = vm.Name; + job.NumberOfHeads = 1; + job.NumberOfUnits = 1; + job.SampleUnitsOrMeters = 1; + job.CreationDate = DateTime.UtcNow; + job.JobStatus = JobStatuses.Draft; + job.JobType = JobTypes.Knitting; + job.EnableLubrication = true; + job.MachineGuid = MachineProvider.Machine.Guid; + job.RmlGuid = vm.SelectedRml.Guid; + job.Machine = await new MachineBuilder(db).Set(job.MachineGuid).WithCats().WithConfiguration().BuildAsync(); + job.Rml = await new RmlBuilder(db).Set(job.RmlGuid).WithActiveParametersGroup().WithCAT(MachineProvider.Machine.Guid).WithCCT().WithLiquidFactors().BuildAsync(); + job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid; + job.SpoolTypeGuid = Settings.DefaultSpoolTypeGuid != null ? Settings.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; + + foreach (var segment in segments) + { + segment.Job = job; + job.Segments.Add(segment); + } + + IColorConverter converter = new DefaultColorConverter(); + + foreach (var stop in segments.SelectMany(x => x.BrushStops.Where(y => y.BrushColorSpace == ColorSpaces.Volume))) + { + var output = converter.Convert(stop, false); + var suggestion = output.CreateSingleSuggestion(); + stop.Color = suggestion.Color; + } + + db.Jobs.Add(job); + await db.SaveChangesAsync(); + LoadJobs(); + } + + NotificationProvider.ReleaseGlobalBusyMessage(); + } + catch (Exception ex) + { + NotificationProvider.ReleaseGlobalBusyMessage(); + LogManager.Log(ex, "Error importing job from CSV."); + await NotificationProvider.ShowError($"Error importing job from csv file.\n{ex.FlattenMessage()}"); + } + } + } + + #endregion + + #region Handle TCC File Loading From Storage + + private async void HandleColorProfileFileLoaded(List tccFiles) + { + var tccFile = tccFiles.FirstOrDefault(); + + try + { + DetectionColorFile tcc = DetectionColorFile.Parser.ParseFrom(File.ReadAllBytes(tccFile.Path)); + + var vm = await NotificationProvider.ShowDialog(new ImportColorProfileViewVM() + { + Color = Color.FromRgb( + (byte)tcc.ProcessedColor.R, + (byte)tcc.ProcessedColor.G, + (byte)tcc.ProcessedColor.B), + }); + + if (vm.DialogResult) + { + AddNewJob(vm.Color); + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error occurred while trying to import detection color from file {tccFile.Path}."); + await NotificationProvider.ShowError($"An error occurred while trying to import the selected detection color.\n{ex.Message}"); + } + } + + #endregion + + #region Handle Pulse TWN Loading From Storage + + private async void HandlePulseFileLoaded(List twnFiles) + { + var twnFile = twnFiles.FirstOrDefault(); + + TwnFile twn = TwnFile.FromFile(twnFile.Path); + BitmapSource preview = twn.Thumbnail.ToBitmapSource(); + + var vm = await NotificationProvider.ShowDialog(new ImportTwnFileViewVM() + { + Thumbnail = preview, + }); + + if (vm.DialogResult) + { + AddNewJob(null, twn); + } + } + + #endregion + + #region Handle New Synchronized Jobs + + private void MachineDataSynchronizer_SynchronizationEnded(object sender, SynchronizationEndedEventArgs e) + { + if (e.NewChangedJobs > 0 && !_isJobsSynchronizationNotificationActive) + { + _isJobsSynchronizationNotificationActive = true; + + var item = NotificationProvider.PushNotification(); + item.Pressed += (_, __) => + { + _isJobsSynchronizationNotificationActive = false; + LoadJobs(() => + { + NotificationProvider.ShowSuccess("Your job list is now synchronized."); + }); + }; + item.Closed += (_, __) => + { + _isJobsSynchronizationNotificationActive = false; + }; + } + } + + #endregion + + #region Color Profile Request + + private void ExternalBridgeService_ColorProfileRequest(object sender, ColorProfileRequestEventArgs e) + { + InvokeUI(async () => + { + var vm = await NotificationProvider.ShowDialog(new ColorProfileReceivedViewVM() + { + Color = Color.FromRgb( + (byte)e.Request.DetectionColor.R, + (byte)e.Request.DetectionColor.G, + (byte)e.Request.DetectionColor.B), + }); + + if (vm.DialogResult) + { + e.Approve(); + AddNewJob(vm.Color); + } + else + { + e.Decline(); + } + }); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..769a9a5c9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/MainViewVM.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Integration.Operation; +using Tango.PPC.Common; +using Tango.PPC.Common.Notifications; +using Tango.PPC.Common.Notifications.NotificationItems; +using Tango.PPC.Jobs.AppBarItems; +using Tango.PPC.Jobs.Messages; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.PPC.Jobs.Views; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the main view ViewModel. + /// + /// + public class MainViewVM : PPCViewModel + { + private NotificationItem _last_failed_job_notification; + private JobHandler _handler; + private bool resuming; + private JobProgressAppBarItem _appBarItem; + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + MachineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; + MachineProvider.MachineOperator.ResumingJob += MachineOperator_ResumingJob; + MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; + NavigationManager.CurrentVMChanged += NavigationManager_CurrentVMChanged; + } + + private void MachineOperator_PrintingEnded(object sender, PrintingEventArgs e) + { + _appBarItem?.Close(); + _appBarItem = null; + } + + private void NavigationManager_CurrentVMChanged(object sender, PPCViewModel vm) + { + if (vm.GetType() == typeof(JobProgressViewVM)) + { + _appBarItem?.Close(); + _appBarItem = null; + } + else if (vm.GetType() != typeof(JobSummeryViewVM) && _appBarItem == null && MachineProvider.MachineOperator.IsPrinting && _handler != null && !_handler.IsCanceled) + { + _appBarItem = NotificationProvider.PushAppBarItem(); + _appBarItem.Pressed += (_, __) => + { + _appBarItem?.Close(); + NavigationManager.NavigateTo(nameof(JobProgressView)); + }; + } + } + + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) + { + _handler = e.JobHandler; + + if (resuming) + { + resuming = false; + + InvokeUI(() => + { + NavigationManager.NavigateTo(nameof(JobProgressView)); + + if (_last_failed_job_notification != null) + { + _last_failed_job_notification.Close(); + _last_failed_job_notification = null; + } + }); + } + } + + private void MachineOperator_ResumingJob(object sender, ResumingJobEventArgs e) + { + LogManager.Log($"Job resume request '{e.JobGuid}' approving..."); + + try + { + e.Approve(); + resuming = true; + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to resume the job."); + InvokeUI(() => + { + NotificationProvider.ShowError("An error occurred while trying to resume a job in progress."); + }); + } + } + + /// + /// Handles the PrintingFailed event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingFailed(object sender, PrintingFailedEventArgs e) + { + String message = $"{e.Exception.FlattenMessage()}"; + + _last_failed_job_notification = NotificationProvider.PushNotification(new MessageNotificationItem( + $"'{e.Job.Name}' failed at position {e.JobHandler.Status.ProgressMinusSettingUp.ToString("0.0")} out of {e.JobHandler.Status.TotalProgressMinusSettingUp.ToString("0.0")} meters.", + message, MessageNotificationItem.MessageNotificationItemTypes.Error, () => + { + NavigationManager.NavigateWithObject(e.Job); + NavigationManager.ClearHistoryExcept(); + }, NotificationItem.NotificationPriority.VeryHigh)); + } + + /// + /// Handles the PrintingCompleted event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingCompleted(object sender, PrintingEventArgs e) + { + LogManager.Log($"'{e.Job.Name}' printing complete. Job designation is {e.Job.Designation}."); + + if (e.Job.Designation == BL.Enumerations.JobDesignations.SampleDye) + { + NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' sample dye completed successfully", e.Job.Name), "Tap to approve or repeat.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + { + NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = e.Job, Intent = JobNavigationIntent.SampleDye }); + NavigationManager.ClearHistoryExcept(); + })); + } + else if (e.Job.Designation == BL.Enumerations.JobDesignations.FineTuning) + { + NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' fine tuning completed successfully", e.Job.Name), "Tap to approve or repeat.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + { + NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = e.Job, Intent = JobNavigationIntent.FineTuning }); + NavigationManager.ClearHistoryExcept(); + })); + } + else + { + NotificationProvider.PushNotification(new MessageNotificationItem(String.Format("'{0}' completed successfully", e.Job.Name), "Tap to view this job details.", MessageNotificationItem.MessageNotificationItemTypes.Success, () => + { + NavigationManager.NavigateWithObject(new JobNavigationObject() { Job = e.Job }); + NavigationManager.ClearHistoryExcept(); + }, NotificationItem.NotificationPriority.VeryHigh)); + } + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + RaiseMessage(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/TwineCatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/TwineCatalogViewVM.cs new file mode 100644 index 000000000..937c23588 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/TwineCatalogViewVM.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.Settings; + +namespace Tango.PPC.Jobs.ViewModels +{ + /// + /// Represents the twine catalog view model. + /// + /// + /// + public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider + { + private bool _confirmed; + private ObservablesContext _db; + + private ColorCatalog _catalog; + /// + /// Gets or sets the catalog. + /// + public ColorCatalog Catalog + { + get { return _catalog; } + set { _catalog = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalog _recent; + /// + /// Gets or sets the recent catalog items as a complete catalog. + /// + public ColorCatalog Recent + { + get { return _recent; } + set { _recent = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + /// + /// Gets or sets the filter. + /// + /// + /// The filter. + /// + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); } + } + + private ColorCatalogsItem _selectedItem; + /// + /// Gets or sets the selected item. + /// + public ColorCatalogsItem SelectedItem + { + get { return _selectedItem; } + set + { + _selectedItem = value; RaisePropertyChangedAuto(); + } + } + + /// + /// Gets or sets the OK command. + /// + public RelayCommand OKCommand { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public TwineCatalogViewVM() + { + OKCommand = new RelayCommand(Confirm); + } + + /// + /// Called when the application has been started. + /// + public override void OnApplicationStarted() + { + _db = ObservablesContext.CreateDefault(); + } + + /// + /// Called when the navigation system has navigated to this VM view. + /// + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + _confirmed = false; + Filter = "CATALOG"; + } + + /// + /// Confirms this instance. + /// + private void Confirm() + { + if (SelectedItem != null) + { + var settings = SettingsManager.Default.GetOrCreate(); + settings.AddRecentCatalogItem(Catalog, SelectedItem); + SettingsManager.Default.Save(); + } + + _confirmed = true; + NavigationManager.NavigateBack(); + } + + /// + /// Called when the navigation system requests a result when it is navigating away from this instance. + /// + /// + public ColorCatalogsItem GetNavigationResult() + { + if (_confirmed) + { + return SelectedItem; + } + else + { + return null; + } + } + + /// + /// Called when the navigation object has been received + /// + /// The brush stop. + public virtual void OnNavigationObjectReceived(TwineCatalogNavigationObject obj) + { + IsFree = false; + + Filter = "CATALOG"; + + Catalog = obj.Catalog; + + ColorCatalog recentCatalog = new ColorCatalog(); + recentCatalog.Name = Catalog.Name; + + var settings = SettingsManager.Default.GetOrCreate(); + + var settingsCatalog = settings.RecentCatalogsItems.SingleOrDefault(x => x.Guid == Catalog.Guid); + if (settingsCatalog != null) + { + var allItems = Catalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).ToList(); + + foreach (var itemGuid in settingsCatalog.RecentItems) + { + var realItem = allItems.SingleOrDefault(x => x.Guid == itemGuid); + + if (realItem != null) + { + var group = recentCatalog.ColorCatalogsGroups.SingleOrDefault(x => x.Guid == realItem.ColorCatalogsGroup.Guid); + if (group == null) + { + group = new ColorCatalogsGroup(); + group.Guid = realItem.ColorCatalogsGroup.Guid; + group.Name = realItem.ColorCatalogsGroup.Name; + group.GroupIndex = realItem.ColorCatalogsGroup.GroupIndex; + recentCatalog.ColorCatalogsGroups.Add(group); + } + + group.ColorCatalogsItems.Add(realItem); + } + } + } + + Recent = recentCatalog; + + SelectedItem = obj.SelectedItem; + + IsFree = true; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml new file mode 100644 index 000000000..ec8801dc1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml @@ -0,0 +1,232 @@ + + + + + + + + + + + (Sample) + (Fine Tuning) + + + + + + + + + + + + + + + + + + + + + + Completed + + + + + m + + + + + + + Getting Ready... + + + + + + + + Time Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Go to job + + + + + Display Job Outline + + + + + + + + + + + + + Hide Job Outline + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml.cs new file mode 100644 index 000000000..90692296c --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobProgressView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for JobProgressView.xaml + /// + public partial class JobProgressView : UserControl + { + public JobProgressView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml new file mode 100644 index 000000000..34ddeca8a --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + EDIT + + + + + + DYE + + + + + + + + + + + + + + + + + + + + + + + + + + Length + + + + + m + + + + + + + + + Time + + + + + + + + + + + + + + + + Required tensioner level is + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml.cs new file mode 100644 index 000000000..e83270e6b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobSummeryView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for JobView.xaml + /// + public partial class JobSummeryView : UserControl + { + public JobSummeryView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml new file mode 100644 index 000000000..af14f7522 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -0,0 +1,1242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #. + + + + + Color code: + + + + + + + + + + + + + + + Position (m): + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Segment # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ADD COLOR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Details + + + + + + + + + + + + Job name: + + + + + Customer: + + + + + Thread type: + + + + + + + + Lubrication + + + + + + + + Required tensioner level is + + + + + + + Comment: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Color & Length + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SOLID SEGMENT + + + + + + + + + + + + + GRADIENT SEGMENT + + + + + + + Include white gap between segments + + + + + + + + + + + + + + + + + Output + + + + + + + + + + + + + + + + + + Embroidery File + + + + + + + + Export the attached embroidery file to storage. + EXPORT FILE + + + + + + + + + + + + Job Summary + + + + + + + + + + + + + + + + + + + + + + + (+%) + + + + + + + + + + + % + + + + + + + + + + Additional Tools + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + () + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs new file mode 100644 index 000000000..86a8d2a37 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.DI; +using Tango.PPC.Jobs.ViewContracts; +using Tango.PPC.Jobs.ViewModels; +using static Tango.SharedUI.Controls.NavigationControl; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for JobView.xaml + /// + public partial class JobView : UserControl, INavigationView, IJobView + { + private JobViewVM _vm; + private bool _is_edit_docked; + + public JobView() + { + InitializeComponent(); + + Loaded += (_, __) => + { + _vm = DataContext as JobViewVM; + }; + + TangoIOC.Default.Register(this); + } + + public void OnNavigatedTo() + { + + } + + private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + _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); + } + + public async void DisplayFineTuning() + { + //expander_fine_tuning.IsExpanded = true; + //await Task.Delay(500); + //scrollViewer.ScrollToElement(expander_fine_tuning); + } + + public void OnNavigatedFrom() + { + + } + + private void scrollViewer_Scrolling(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + if (_vm.Job != null && _vm.Job.Segments != null && _vm.Job.Segments.Count > 3) + { + var position = scrollViewer.GetElementPosition(listSegments); + var stackOutputPosition = scrollViewer.GetElementPosition(stackOutput); + + if (stackOutputPosition.Y > 100) + { + if (position.Y < 110 && !_is_edit_docked) + { + DockEditing(); + } + else if (position.Y > 110 && _is_edit_docked) + { + FloatEditing(); + } + } + else + { + borderEditDock.Visibility = Visibility.Collapsed; + } + } + else if (_is_edit_docked) + { + FloatEditing(); + } + } + + private void DockEditing() + { + _is_edit_docked = true; + borderDockFloat.Child = null; + borderEditDock.Child = dockEdit; + borderEditDock.Visibility = Visibility.Visible; + } + + private void FloatEditing() + { + _is_edit_docked = false; + borderEditDock.Child = null; + borderDockFloat.Child = dockEdit; + borderEditDock.Visibility = Visibility.Collapsed; + } + + private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; + + if (liquidVolume != null) + { + _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); + } + } + + public void ScrollToTop() + { + FloatEditing(); + scrollViewer.ScrollToTop(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml new file mode 100644 index 000000000..e7823d33d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Jobs V2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DRAFT + HISTORY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml.cs new file mode 100644 index 000000000..23785881d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobsView.xaml.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.Core.DI; +using Tango.PPC.Jobs.ViewContracts; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for JobsView.xaml + /// + public partial class JobsView : UserControl, IJobsView + { + public JobsView() + { + InitializeComponent(); + TangoIOC.Default.Register(this); + } + + private async void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (dataGridJobs != null) + { + await Task.Delay(200); + + if (navigationLinks.SelectedIndex == 0) + { + dataGridJobs.LayoutRows(false); + dataGridJobs.ScrollViewer.ScrollToTop(); + } + else + { + dataGridJobsHistory.LayoutRows(false); + dataGridJobsHistory.ScrollViewer.ScrollToTop(); + } + } + } + + public void ScrollToTop() + { + if (dataGridJobs != null && dataGridJobs.ScrollViewer != null) + { + dataGridJobs.ScrollViewer.ScrollToTop(); + } + + if (dataGridJobsHistory != null && dataGridJobsHistory.ScrollViewer != null) + { + dataGridJobsHistory.ScrollViewer.ScrollToTop(); + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml new file mode 100644 index 000000000..505ccc312 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml.cs new file mode 100644 index 000000000..afba4c396 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml new file mode 100644 index 000000000..19e1f722f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + Catalog + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml.cs new file mode 100644 index 000000000..57600322f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/TwineCatalogView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for TwineCatalogColorCorrectionView.xaml + /// + public partial class TwineCatalogView : UserControl + { + public TwineCatalogView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/app.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/app.config new file mode 100644 index 000000000..ec465920b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/app.config @@ -0,0 +1,97 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config new file mode 100644 index 000000000..4cf1b4859 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 7aba9a1ef..e057dae47 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -360,6 +360,11 @@ + + Use Legacy Jobs Module + + + Always Start in Technician Mode -- cgit v1.3.1 From 7e48879b1a0131852823576da270d4c1b215e4d1 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 22 Aug 2021 13:07:20 +0300 Subject: DIsable brush stop synchronization on new jobs module. --- .../Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 3 ++- .../PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index a2240ea28..09aa0a5db 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -423,6 +423,7 @@ + @@ -520,7 +521,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs index a51c44457..254d33ef1 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs @@ -741,8 +741,9 @@ namespace Tango.PPC.Jobs.ViewModels /// public override void OnApplicationStarted() { - LoadJobs(); + BrushStop.ColorSynchronizationMode = BrushStop.ColorSynchronizationModes.None; + LoadJobs(); ExternalBridgeService.ColorProfileRequest += ExternalBridgeService_ColorProfileRequest; } -- cgit v1.3.1 From d3c16022ce28a12ea879d4143b6712319bc93a04 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 22 Sep 2021 19:53:03 +0300 Subject: Color selection and fine tuning tool --- .../Converters/ColorTabToVisibilityConverter.cs | 28 + .../Images/ColorSelection/Heart.png | Bin 0 -> 838 bytes .../Images/ColorSelection/Red_heart.png | Bin 0 -> 616 bytes .../Images/ColorSelection/Triangle.png | Bin 0 -> 279 bytes .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 833 ++++++++++++++ .../Modules/Tango.PPC.JobsV2/Models/JobModel.cs | 411 +++++++ .../Tango.PPC.JobsV2/Models/SegmentModel.cs | 494 ++++++++ .../ColorSelectionNavigationObject.cs | 20 + .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 27 +- .../Modules/Tango.PPC.JobsV2/ViewModelLocator.cs | 13 + .../ViewModels/ColorSelectionToolViewVM.cs | 259 +++++ .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 200 +++- .../Views/ColorSelectionToolView.xaml | 245 ++++ .../Views/ColorSelectionToolView.xaml.cs | 52 + .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml | 1181 +++++--------------- .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs | 4 +- .../Modules/Tango.PPC.JobsV2/Views/MainView.xaml | 1 + .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 1 + Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 74 +- .../Tango.BL/Enumerations/ColorSpaces.cs | 7 + .../Tango.ColorPickers/ColorPickerSlider.cs | 1 - .../Tango.ColorPickers/Tango.ColorPickers.csproj | 19 +- .../Tango.ColorPickers/Themes/Generic.xaml | 2 +- .../Tango.ColorPickers/packages.config | 5 + .../Controls/TouchColorPickerControl.cs | 262 +++++ .../Controls/TouchColorPickerControl.xaml | 41 + .../Controls/TouchColorPickerHSBControl.cs | 445 ++++++++ .../Controls/TouchColorPickerHSBControl.xaml | 37 + .../Controls/TouchColorPickerRGBControl.cs | 359 ++++++ .../Controls/TouchColorPickerRGBControl.xaml | 34 + .../Tango.Touch/Controls/TouchColorPickerSlider.cs | 168 +++ .../Controls/TouchColorPickerSlider.xaml | 131 +++ .../Tango.Touch/Controls/TouchNumericTextBox.cs | 2 +- .../Controls/TouchNumericUpDownConrol.cs | 164 +++ .../Controls/TouchNumericUpDownConrol.xaml | 106 ++ .../Tango.Touch/Controls/TouchSlider.xaml | 45 + .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 29 + .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 6 + .../Utilities/Tango.UITests/App.config | 14 +- .../Utilities/Tango.UITests/Tango.UITests.csproj | 10 +- 40 files changed, 4760 insertions(+), 970 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Heart.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Red_heart.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Triangle.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.ColorPickers/packages.config create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerControl.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerControl.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerHSBControl.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerHSBControl.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerRGBControl.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerRGBControl.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerSlider.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchColorPickerSlider.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchNumericUpDownConrol.xaml (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs new file mode 100644 index 000000000..9189d6172 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using static Tango.PPC.Jobs.ViewModels.ColorSelectionToolViewVM; + +namespace Tango.PPC.Jobs.Converters +{ + public class ColorTabToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ColorTab selected = (ColorTab)Enum.Parse(typeof(ColorTab), parameter.ToString()); + ColorTab colorTab = (ColorTab)value; + + return colorTab.Equals(selected) ? Visibility.Visible : Visibility.Hidden; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Heart.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Heart.png new file mode 100644 index 000000000..1abee7650 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Heart.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Red_heart.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Red_heart.png new file mode 100644 index 000000000..1d8002603 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Red_heart.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Triangle.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Triangle.png new file mode 100644 index 000000000..58af21001 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/Triangle.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs new file mode 100644 index 000000000..010007a19 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -0,0 +1,833 @@ +using System; +using ColorMine.ColorSpaces; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.SharedUI; +using System.Windows.Media; +using Tango.BL.Enumerations; +using Tango.Core.Threading; +using Tango.ColorConversion; +using System.Reflection; + +namespace Tango.PPC.Jobs.Models +{ + public class BrushStopModel : ViewModel + { + private ActionTimer _volumeConversionTimer; + private IColorConverter _converter; + + #region Property + + protected Double _cyan; + + /// + /// Gets or sets the BrushStopModel cyan. + /// + public Double Cyan + { + get + { + return _cyan; + } + + set + { + if (_cyan != value) + { + _cyan = value; + RaisePropertyChangedAuto(); + OnCMYKChanged(); + } + } + } + + protected Double _magenta; + + /// + /// Gets or sets the BrushStopModel magenta. + /// + + public Double Magenta + { + get + { + return _magenta; + } + + set + { + if (_magenta != value) + { + _magenta = value; + RaisePropertyChangedAuto(); + OnCMYKChanged(); + } + } + } + + protected Double _yellow; + + /// + /// Gets or sets the BrushStopModel yellow. + /// + + public Double Yellow + { + get + { + return _yellow; + } + + set + { + if (_yellow != value) + { + _yellow = value; + RaisePropertyChangedAuto(); + OnCMYKChanged(); + } + } + } + + protected Double _black; + + /// + /// Gets or sets the BrushStopModel black. + /// + public Double Black + { + get + { + return _black; + } + + set + { + if (_black != value) + { + _black = value; + RaisePropertyChangedAuto(); + OnCMYKChanged(); + } + } + } + + protected Int32 _red; + + /// + /// Gets or sets the BrushStopModel red. + /// + public Int32 Red + { + get + { + return _red; + } + set + { + if (_red != value) + { + _red = value; + RaisePropertyChangedAuto(); + OnRGBChanged(); + } + } + } + + protected Int32 _green; + + /// + /// Gets or sets the BrushStopModel green. + /// + public Int32 Green + { + get + { + return _green; + } + set + { + if (_green != value) + { + _green = value; + RaisePropertyChangedAuto(); + OnRGBChanged(); + } + } + } + + protected Int32 _blue; + + /// + /// Gets or sets the BrushStopModel blue. + /// + public Int32 Blue + { + get + { + return _blue; + } + set + { + if (_blue != value) + { + _blue = value; + RaisePropertyChangedAuto(); + OnRGBChanged(); + } + } + } + + protected Double _l; + + /// + /// Gets or sets the BrushStopModel l. + /// + + public Double L + { + get + { + return _l; + } + + set + { + if (_l != value) + { + _l = value; + RaisePropertyChangedAuto(); + OnLABChanged(); + } + } + } + + protected Double _a; + + /// + /// Gets or sets the BrushStopModel a. + /// + public Double A + { + get + { + return _a; + } + set + { + if (_a != value) + { + _a = value; + RaisePropertyChangedAuto(); + OnLABChanged(); + } + } + } + + protected Double _b; + + /// + /// Gets or sets the BrushStopModel b. + /// + public Double B + { + get + { + return _b; + } + set + { + if (_b != value) + { + RaisePropertyChangedAuto(); + OnLABChanged(); + } + } + } + + //HSB??? + private double _hue; + + public double Hue + { + get { return _hue; } + set + { + if (_hue != value) + { + _hue = value; + OnHSBChanged(); + RaisePropertyChangedAuto(); + } + + } + } + + private double _saturation; + + public double Saturation + { + get { return _saturation; } + set + { + if (_saturation != value) + { + _saturation = value; + OnHSBChanged(); + RaisePropertyChangedAuto(); + } + } + } + + private double _brightness; + + public double Brightness + { + get { return _brightness; } + set + { + if (_brightness != value) + { + _brightness = value; + OnHSBChanged(); + RaisePropertyChangedAuto(); + } + + } + } + + + protected Boolean _istransparent; + + /// + /// Gets or sets the BrushStopModel is transparent. + /// + public Boolean IsTransparent + { + get + { + return _istransparent; + } + set + { + if (_istransparent != value) + { + _istransparent = value; + RaisePropertyChangedAuto(); + + } + } + } + + protected Double _offsetpercent; + + /// + /// Gets or sets the brushstopbase offset percent. + /// + public Double OffsetPercent + { + get + { + return _offsetpercent; + } + set + { + if (_offsetpercent != value) + { + _offsetpercent = value; + RaisePropertyChangedAuto(); + OnOffsetPercentChanged(); + } + } + } + + protected Int32 _stopindex; + + /// + /// Gets or sets the brushstopbase stop index. + /// + public Int32 StopIndex + { + get + { + return _stopindex; + } + + set + { + if (_stopindex != value) + { + _stopindex = value; + RaisePropertyChangedAuto(); + OnStopIndexChanged(); + + } + } + } + + private bool _isFirst; + + public bool IsFirst + { + get { return _isFirst; } + set { _isFirst = value; } + } + private bool _isLast; + + public bool IsLast + { + get { return _isLast; } + set { _isLast = value; } + } + + private bool _isFirstColorBrush; + + public bool IsFirstColorBrush + { + get { return _isFirstColorBrush; } + set { _isFirstColorBrush = value; } + } + + private bool _isSecondColorBrush; + + public bool IsSecondColorBrush + { + get { return _isSecondColorBrush; } + set { _isSecondColorBrush = value; } + } + + protected ColorSpaces _colorspace; + + public virtual ColorSpaces ColorSpace + { + get + { + return _colorspace; + } + + set + { + if (_colorspace != value) + { + _colorspace = value; + } + } + } + protected ColorCatalogsItem _colorcatalogsitem; + + public virtual ColorCatalogsItem ColorCatalogsItem + { + get + { + return _colorcatalogsitem; + } + + set + { + if (_colorcatalogsitem != value) + { + _colorcatalogsitem = value; + } + } + } + + + private System.Windows.Media.Color _color; + public System.Windows.Media.Color Color + { + get + { + return _color; + } + set + { + if(_color != value) + { + _color = value; + RaisePropertyChangedAuto(); + } + } + } + + private System.Windows.Media.Color _displayedColor; + + public System.Windows.Media.Color DisplayedColor + { + get { return _displayedColor; } + set { + _displayedColor = value; + RaisePropertyChangedAuto(); + } + } + + + public SolidColorBrush ColorBrush + { + get + { + if(Color == null) + { + InitColor(); + } + return new SolidColorBrush(Color); + } + } + + private SegmentModel _segmentmodel; + + public SegmentModel SegmentModel + { + get { return _segmentmodel; } + set { _segmentmodel = value; } + } + + private BrushStop _dummyBrushStop; + + public BrushStop DummyBrushStop + { + get { return _dummyBrushStop; } + set { _dummyBrushStop = value; } + } + + private bool _isMiddle; + + public bool IsMiddle + { + get { return _isMiddle; } + set { _isMiddle = value; + RaisePropertyChangedAuto(); + } + } + + #endregion + + public BrushStopModel(SegmentModel segmentModel) + { + _hue = 0; + _saturation = 0; + _brightness = 100; + _l = 100; + _a = 0; + _b = 0; + _red = _green = _blue = 255; + _cyan = _magenta = _yellow = _black = 0; + IsMiddle = IsFirstColorBrush = IsSecondColorBrush = false; + SegmentModel = segmentModel; + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + _converter = new DefaultColorConverter(); + _displayedColor = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); + Color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue); + ColorSpace = ColorSpaces.RGB; + } + + #region Methods + + private void InitColor() + { + if (ColorSpace == ColorSpaces.Catalog) + { + if (ColorCatalogsItem != null) + { + Color = Color.FromRgb((byte)ColorCatalogsItem.Red, (byte)ColorCatalogsItem.Green, (byte)ColorCatalogsItem.Blue); + } + else + { + Color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + } + } + else + { + Color = Color.FromRgb((byte)_red, (byte)_green, (byte)_blue); + } + } + + private void CreateDummyBrushStop() + { + if (DummyBrushStop == null) + { + if (SegmentModel == null || SegmentModel.Job == null || SegmentModel.Job.Rml == null || SegmentModel.Job.Machine == null) + return; + + DummyBrushStop = new BrushStop() + { + ColorSpace = new BL.Entities.ColorSpace() + }; + Configuration configuration = SegmentModel.Job.Machine.Configuration; + Rml rml = SegmentModel.Job.Rml; + + DummyBrushStop.SetLiquidVolumes(configuration, rml, rml.GetActiveProcessGroup().ProcessParametersTables.FirstOrDefault()); + var lub = DummyBrushStop.LiquidVolumes.FirstOrDefault(x => x.IdsPack.LiquidType.Code == (int)BL.Enumerations.LiquidTypes.Lubricant); + if (lub != null) + { + lub.Volume = 100; + } + } + } + + private void OnCMYKChanged() + { + Cmyk cmyk = new Cmyk(Cyan, Magenta, Yellow, Black); + Rgb rgb = new Rgb(cmyk.ToRgb()); + _red = (int)rgb.R; + _green = (int)rgb.G; + _blue = (int)rgb.B; + + Lab lab = rgb.To(); + _l = lab.L; + _a = lab.A; + _b = lab.B; + + var hsb = rgb.To(); + _hue = hsb.H; + _saturation = hsb.S *100; + _brightness = hsb.B *100; + + ColorSpace = ColorSpaces.CMYK; + + if (DummyBrushStop == null) + CreateDummyBrushStop(); + + + if (DummyBrushStop != null) + { + DummyBrushStop.ColorSpace.Space = BL.Enumerations.ColorSpaces.CMYK; + DummyBrushStop.Red = this.Red; + DummyBrushStop.Green = this.Green; + DummyBrushStop.Blue = this.Blue; + OnBrushStopFieldValueChanged(DummyBrushStop); + } + } + + + private void OnRGBChanged() + { + Rgb rgb = new Rgb(Red, Green, Blue); + Lab lab = rgb.To(); + _l = lab.L; + _a = lab.A; + _b = lab.B; + + var hsb = rgb.To(); + _hue = hsb.H; + _saturation = hsb.S * 100; + _brightness = hsb.B * 100; + + var cmyk = rgb.To(); + _cyan = cmyk.C; + _yellow = cmyk.Y; + _magenta = cmyk.M; + _black = cmyk.K; + + ColorSpace = ColorSpaces.RGB; + + if (DummyBrushStop == null) + CreateDummyBrushStop(); + + + if (DummyBrushStop != null) + { + DummyBrushStop.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; + DummyBrushStop.Red = this.Red; + DummyBrushStop.Green = this.Green; + DummyBrushStop.Blue = this.Blue; + OnBrushStopFieldValueChanged(DummyBrushStop); + } + } + + private void OnHSBChanged() + { + Hsb hsb = new Hsb(Hue, Saturation/100, Brightness/100); + Rgb rgb = new Rgb(hsb.ToRgb()); + _red = (int)rgb.R; + _green = (int)rgb.G; + _blue = (int)rgb.B; + + Lab lab = rgb.To(); + _l = lab.L; + _a = lab.A; + _b = lab.B; + + var cmyk = rgb.To(); + _cyan = cmyk.C; + _yellow = cmyk.Y; + _magenta = cmyk.M; + _black = cmyk.K; + + ColorSpace = ColorSpaces.HSB; + + if (DummyBrushStop == null) + CreateDummyBrushStop(); + + + if (DummyBrushStop != null) + { + DummyBrushStop.ColorSpace.Space = BL.Enumerations.ColorSpaces.RGB; + DummyBrushStop.Red = this.Red; + DummyBrushStop.Green = this.Green; + DummyBrushStop.Blue = this.Blue; + OnBrushStopFieldValueChanged(DummyBrushStop); + } + } + + private void OnLABChanged() + { + Lab lab = new Lab(L, A, B); + Rgb rgb = new Rgb(lab.ToRgb()); + _red = (int)rgb.R; + _green = (int)rgb.G; + _blue = (int)rgb.B; + + var hsb = rgb.To(); + _hue = hsb.H; + _saturation = hsb.S; + _brightness = hsb.B; + + var cmyk = rgb.To(); + _cyan = cmyk.C; + _yellow = cmyk.Y; + _magenta = cmyk.M; + _black = cmyk.K; + + ColorSpace = ColorSpaces.LAB; + + if (DummyBrushStop == null) + CreateDummyBrushStop(); + + + if (DummyBrushStop != null) + { + DummyBrushStop.ColorSpace.Space = BL.Enumerations.ColorSpaces.LAB; + DummyBrushStop.Red = this.Red; + DummyBrushStop.Green = this.Green; + DummyBrushStop.Blue = this.Blue; + OnBrushStopFieldValueChanged(DummyBrushStop); + } + } + + private void OnOffsetPercentChanged() + { + //lenth? + } + + private void OnStopIndexChanged() + { + //throw new NotImplementedException(); + } + + public BrushStopModel Clone() + { + var cloned = (BrushStopModel)Activator.CreateInstance(typeof(BrushStopModel), SegmentModel); + + foreach (var prop in typeof(BrushStopModel).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) + { + if (!prop.PropertyType.IsGenericTypeAndNotNullable()) + { + prop.SetValue(cloned, prop.GetValue(this)); + } + } + + cloned.SegmentModel = SegmentModel; + + return cloned; + } + + public static Color GetRelativeRGB(Color first, Color second, double firstOffset, double secondOffset, double offset) + { + var color = new Color(); + var range = (secondOffset - firstOffset); + var realoffset = offset - firstOffset; + + color.ScA = (float)(realoffset * (second.ScA - first.ScA) / range + first.ScA); + color.ScR = (float)(realoffset * (second.ScR - first.ScR) / range + first.ScR); + color.ScG = (float)(realoffset * (second.ScG - first.ScG) / range + first.ScG); + color.ScB = (float)(realoffset * (second.ScB - first.ScB) / range + first.ScB); + + return color; + } + + #endregion + + #region changes + + public void RaiseColorChangeHSB() + { + RaisePropertyChanged(nameof(Hue)); + RaisePropertyChanged(nameof(Saturation)); + RaisePropertyChanged(nameof(Brightness)); + } + + public void RaiseColorChangeRGB() + { + RaisePropertyChanged(nameof(Red)); + RaisePropertyChanged(nameof(Green)); + RaisePropertyChanged(nameof(Blue)); + } + + public void RaiseOffsetChanged() + { + RaisePropertyChanged(nameof(OffsetPercent)); + //RaisePropertyChanged(nameof(OffsetMeters)); + //RaisePropertyChanged(nameof(IsFirst)); + //RaisePropertyChanged(nameof(IsLast)); + //RaisePropertyChanged(nameof(IsMiddle)); + } + + public void OnBrushStopFieldValueChanged(BrushStop stop) + { + if (stop != null && stop.ColorSpace != null) + { + _volumeConversionTimer.ResetReplace(() => + { + try + { + Configuration configuration = SegmentModel.Job.Machine.Configuration; + Rml rml = SegmentModel.Job.Rml; + var output = _converter.Convert(stop, configuration, rml, false, SegmentModel.Job.Machine.LightInksInstalled, false); + //_converter.Convert(stop, false); + + if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + { + DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + + //stop.Red = output.SingleCoordinates.Red; + //stop.Green = output.SingleCoordinates.Green; + //stop.Blue = output.SingleCoordinates.Blue; + //stop.L = output.SingleCoordinates.L; + //stop.A = output.SingleCoordinates.A; + //stop.B = output.SingleCoordinates.B; + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) + { + Lab lab = new Lab(output.SingleCoordinates.L, output.SingleCoordinates.A, output.SingleCoordinates.B); + Rgb rgb = new Rgb(lab.ToRgb()); + //DisplayedColor = Color.FromArgb(255, (byte)rgb.R, (byte)rgb.G, (byte)rgb.B); + + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + { + DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + + stop.Corrected = false; + stop.OutOfGamutChecked = false; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + } + + }); + + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs new file mode 100644 index 000000000..cb896198d --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs @@ -0,0 +1,411 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Models +{ + public class JobModel : ViewModel + { + + #region Properties + protected String _name; + + + public String Name + { + get + { + return _name; + } + + set + { + if (_name != value) + { + _name = value; + RaisePropertyChangedAuto(); + } + } + } + protected DateTime _creationdate; + + /// + /// Gets or sets the JobModel creation date. + /// + public DateTime CreationDate + { + get + { + return _creationdate; + } + set + { + if (_creationdate != value) + { + _creationdate = value; + RaisePropertyChangedAuto(); + } + } + } + + private double _lastLength; + public double Length + { + get + { + _lastLength = GetLength(); + return _lastLength; + } + } + + private double GetLength() + { + if (Segments != null) + { + return Segments.Sum(x => x.LengthWithFactor) + ((EnableInterSegment && IsAllSegmentsPerSpool) ? (InterSegmentLength * (Segments.Count > 0 ? Segments.Count - 1 : Segments.Count)) : 0); + } + else + { + return 0; + } + } + + protected Double _lengthpercentagefactor; + + /// + /// Gets or sets the JobModel length percentage factor. + /// + + public Double LengthPercentageFactor + { + get + { + return _lengthpercentagefactor; + } + + set + { + if (_lengthpercentagefactor != value) + { + _lengthpercentagefactor = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Int32 _numberofunits; + /// + /// Gets or sets the JobModel number of units. + /// + public Int32 NumberOfUnits + { + get + { + return _numberofunits; + } + + set + { + if (_numberofunits != value) + { + _numberofunits = value; + RaisePropertyChangedAuto(); + + } + } + } + + protected Boolean _enableintersegment; + + /// + /// Gets or sets the JobModel enable inter segment. + /// + public Boolean EnableInterSegment + { + get + { + return _enableintersegment; + } + + set + { + if (_enableintersegment != value) + { + _enableintersegment = value; + RaisePropertyChangedAuto(); + + } + } + } + + protected Double _intersegmentlength; + + /// + /// Gets or sets the JobModel inter segment length. + /// + public Double InterSegmentLength + { + get + { + return _intersegmentlength; + } + + set + { + if (_intersegmentlength != value) + { + _intersegmentlength = value; + RaisePropertyChangedAuto(); + } + } + } + + protected SpoolsDistributions _spoolsdistribution; + public bool IsAllSegmentsPerSpool + { + get { return ((SpoolsDistributions)_spoolsdistribution) == SpoolsDistributions.AllSegments; } + set + { + _spoolsdistribution = value ? SpoolsDistributions.AllSegments : SpoolsDistributions.SingleSegment; + RaisePropertyChangedAuto(); + } + } + /// + /// Gets the total job segments length multiplied by number of units if it is an embroidery job. + /// + public double LengthIncludingNumberOfUnits + { + get + { + _lastLength = GetLength(); + var l = _lastLength * Math.Max(NumberOfUnits, 1); + + if (EnableInterSegment && NumberOfUnits > 1) + { + l += ((NumberOfUnits - 1) * InterSegmentLength); + } + + return l; + } + } + + protected Rml _rml; + + /// + /// Gets or sets the JobModel rml. + /// + public virtual Rml Rml + { + get + { + return _rml; + } + + set + { + if (_rml != value) + { + _rml = value; + RaisePropertyChangedAuto(); + } + } + } + + protected ColorSpace _colorspace; + + /// + /// Gets or sets the JobModel color spaces. + /// + public virtual ColorSpace ColorSpace + { + get + { + return _colorspace; + } + set + { + if (_colorspace != value) + { + _colorspace = value; + RaisePropertyChangedAuto(); + } + } + } + + protected Customer _customer; + + /// + /// Gets or sets the JobModel customer. + /// + + public virtual Customer Customer + { + get + { + return _customer; + } + set + { + if (_customer != value) + { + _customer = value; + RaisePropertyChangedAuto(); + } + } + } + protected Machine _machine; + + /// + /// Gets or sets the JobModel machine. + /// + public virtual Machine Machine + { + get + { + return _machine; + } + + set + { + if (_machine != value) + { + _machine = value; + RaisePropertyChangedAuto(); + } + } + } + + protected SpoolType _spooltype; + + /// + /// Gets or sets the JobModel spool types. + /// + + public virtual SpoolType SpoolType + { + get + { + return _spooltype; + } + + set + { + if (_spooltype != value) + { + _spooltype = value; + RaisePropertyChangedAuto(); + + } + } + } + + protected User _user; + + /// + /// Gets or sets the JobModel user. + /// + + public virtual User User + { + get + { + return _user; + } + + set + { + if (_user != value) + { + _user = value; + RaisePropertyChangedAuto(); + } + } + } + + protected SynchronizedObservableCollection _segments; + + /// + /// Gets or sets the JobModel segments. + /// + + public virtual SynchronizedObservableCollection Segments + { + get + { + return _segments; + } + set + { + if (_segments != value) + { + _segments = value; + //OnSegmentsChanged(value); + } + } + } + + public ObservableCollection EffectiveSegments + { + get + { + if (EnableInterSegment && IsAllSegmentsPerSpool) + { + int max = Segments.Max(x => x.SegmentIndex); + + ObservableCollection effectiveSegments = new ObservableCollection(); + + foreach (var s in Segments.ToList().OrderBy(x => x.SegmentIndex)) + { + effectiveSegments.Add(s); + + if (s.SegmentIndex != max) + { + effectiveSegments.Add(CreateInterSegment(InterSegmentLength)); + } + } + + return effectiveSegments; + } + else + { + return Segments.OrderBy(x => x.SegmentIndex).ToObservableCollection(); + } + } + } + + #endregion + + public JobModel() + { + _segments = new SynchronizedObservableCollection(); + } + + #region modifications + + public static SegmentModel CreateInterSegment(double length) + { + SegmentModel segment = new SegmentModel() + { + IsInterSegment = true, + Length = length, + Name = "Inter Segment" + }; + segment.BrushStops.Add(new BrushStopModel(segment) + { + ColorSpace = ColorSpaces.RGB, + Color = System.Windows.Media.Colors.White, + }); + return segment; + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs new file mode 100644 index 000000000..dc3619129 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs @@ -0,0 +1,494 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Threading; +using Tango.SharedUI; +using System.Windows; +using System.Windows.Media; +using System.Collections.Specialized; +using System.Reflection; +using Tango.BL.Enumerations; + +namespace Tango.PPC.Jobs.Models +{ + public class SegmentModel : ViewModel + { + private double _lastLength; + private LinearGradientBrush _brush; + private ActionTimer _brushStopCollectionChangedActionTimer; + + #region Properties + + protected String _name; + + /// + /// Gets or sets the SegmentModel name. + /// + public String Name + { + get + { + return _name; + } + + set + { + if (_name != value) + { + _name = value; + RaisePropertyChangedAuto(); + } + } + } + protected Double _length; + /// + /// Gets or sets the length. + /// + public Double Length + { + get + { + return _length; + } + set + { + if (_length != value) + { + _length = value; + OnLengthChanged(value); + RaisePropertyChangedAuto(); + } + } + } + + protected Int32 _segmentindex; + /// + /// Gets or sets the index of the segment. + /// + public Int32 SegmentIndex + { + get + { + return _segmentindex; + } + set + { + if (_segmentindex != value) + { + _segmentindex = value; + RaisePropertyChangedAuto(); + } + } + } + private bool _isInterSegment; + /// + /// Gets or sets a value indicating whether this segment is an inter segment. + /// + public bool IsInterSegment + { + get { return _isInterSegment; } + set { _isInterSegment = value; + RaisePropertyChangedAuto(); } + } + + public double LengthWithFactor + { + get { return Job != null && !IsInterSegment ? (Length + Length * (Job.LengthPercentageFactor / 100)) : Length; } + } + + + protected SynchronizedObservableCollection _brushstops; + + /// + /// Gets or sets the segmentbase brush stops. + /// + + public SynchronizedObservableCollection BrushStops + { + get + { + return _brushstops; + } + + set + { + if (_brushstops != value) + { + _brushstops = value; + OnBrushStopsChanged(_brushstops); + RaisePropertyChangedAuto(); + } + } + } + + private JobModel _job; + + public JobModel Job + { + get + { + return _job; + } + + set + { + if (_job != value) + { + _job = value; + } + } + } + + public Brush SegmentBrush + { + get + { + return GetSegmentBrush(); + } + } + + public bool IsOffsetChanged { get; set; } + + private double _leftOffset; + + public double LeftOffset + { + get { return _leftOffset; } + set { _leftOffset = value; + RaisePropertyChangedAuto(); + if (BrushStops.Count > 2) + { + BrushStops[1].OffsetPercent = _leftOffset/2; + IsOffsetChanged = true; + RaiseSegmentBrushChanged(); + IsOffsetChanged = false; + } + } + } + + private double _middleOffset; + + public double MiddleOffset + { + get { return _middleOffset; } + set { _middleOffset = value; + RaisePropertyChangedAuto(); + if (BrushStops.Count > 4) + { + BrushStops[2].OffsetPercent = _middleOffset; + + IsOffsetChanged = true; + RaiseSegmentBrushChanged(); + IsOffsetChanged = false; + } + } + } + + private double _rightOffset; + + public double RightOffset + { + get { return _rightOffset; } + set { _rightOffset = value; + RaisePropertyChangedAuto(); + if (BrushStops.Count > 4) + { + BrushStops[3].OffsetPercent = _rightOffset; + IsOffsetChanged = true; + RaiseSegmentBrushChanged(); + IsOffsetChanged = false; + } + } + } + + public bool HasColors + { + get + { + return BrushStops.Count > 0; + } + } + + public bool IsGradient + { + get + { + return BrushStops.Count > 1; + } + } + + /// + /// Gets the second brush stop. + /// + public BrushStopModel SecondBrushStop + { + get + { + if (BrushStops.Count > 1) + return BrushStops.Where(x => x.IsSecondColorBrush).FirstOrDefault(); + + return null; + } + } + + /// + /// Gets the first brush stop. + /// + public BrushStopModel FirstBrushStop + { + get + { + if (BrushStops.Count == 1) + return BrushStops[0]; + if (BrushStops.Count > 1) + return BrushStops.Where(x => x.IsFirstColorBrush).FirstOrDefault(); + + return null; + } + + } + + /// + /// Gets the middle brush stop. + /// + public BrushStopModel MiddleBrushStop + { + get + { + if (BrushStops.Count > 1) + return BrushStops.Where(x => x.IsMiddle).FirstOrDefault(); + + return null; + } + } + + #endregion + + public SegmentModel(JobModel jobModel) + { + BrushStops = new SynchronizedObservableCollection(); + Length = 5; + Job = jobModel; + LeftOffset = 0; + MiddleOffset = 50; + RightOffset = 100; + IsOffsetChanged = false; + } + + public SegmentModel() + { + BrushStops = new SynchronizedObservableCollection(); + LeftOffset = 0; + MiddleOffset = 50; + RightOffset = 100; + IsOffsetChanged = false; + } + #region Public Methods + + /// + /// Gets the segment brush. + /// + /// + public LinearGradientBrush GetSegmentBrush() + { + if (_brush == null || _brush.GradientStops.Count != BrushStops.Count || IsOffsetChanged) + { + GradientStopCollection stops = new GradientStopCollection(); + + + foreach (var stop in BrushStops.ToList().OrderBy(x => x.StopIndex).ToList()) + { + stops.Add(new GradientStop(stop.IsTransparent ? Colors.Transparent : stop.Color, stop.OffsetPercent / 100d)); + } + + LinearGradientBrush brush = new LinearGradientBrush(); + brush.StartPoint = new Point(0, 0); + brush.EndPoint = new Point(1, 0); + + brush.GradientStops = stops; + + _brush = brush; + return brush; + } + else + { + for (int i = 0; i < BrushStops.Count; i++) + { + _brush.GradientStops[i].Color = BrushStops[i].IsTransparent ? Colors.Transparent : BrushStops[i].Color; + _brush.GradientStops[i].Offset = BrushStops[i].OffsetPercent / 100d; + } + + return _brush; + } + } + + public SegmentModel Clone() + { + var cloned = (SegmentModel)Activator.CreateInstance(typeof(SegmentModel), this.Job); + + foreach (var prop in typeof(SegmentModel).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.SetMethod != null)) + { + if (!prop.PropertyType.IsGenericTypeAndNotNullable()) + { + prop.SetValue(cloned, prop.GetValue(this)); + } + } + cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToSynchronizedObservableCollection(); + cloned.Job = Job; + cloned.SegmentIndex = SegmentIndex + 1; + + return cloned; + } + + /// + /// Creates the gradient brushes. + /// + public void CreateGradientBrushes(BrushStopModel firstBrush, BrushStopModel secondBrush) + { + BrushStops.Clear(); + BrushStopModel brushStop = firstBrush.Clone(); + brushStop.StopIndex = 1; + brushStop.OffsetPercent = 0; + brushStop.IsFirst = true; + BrushStops.Add(brushStop); + + BrushStopModel colorbrushStop = firstBrush.Clone(); + colorbrushStop.IsFirstColorBrush = true; + colorbrushStop.StopIndex = 2; + colorbrushStop.OffsetPercent = 0; + BrushStops.Add(colorbrushStop); + + BrushStopModel middleBrushStop = firstBrush.Clone(); + middleBrushStop.StopIndex = 3; + middleBrushStop.IsMiddle = true; + middleBrushStop.OffsetPercent = 50; + middleBrushStop.Color = BrushStopModel.GetRelativeRGB(firstBrush.Color, secondBrush.Color, 0, 1, 0.5); + middleBrushStop.DisplayedColor = BrushStopModel.GetRelativeRGB(firstBrush.DisplayedColor, secondBrush.DisplayedColor, 0, 1, 0.5); + BrushStops.Add(middleBrushStop); + + AddOrReplaceSecondBrush(secondBrush); + } + + public void AddOrReplaceSecondBrush(BrushStopModel secondBrush) + { + RemoveSecondColorOfGradient(); + + BrushStopModel secondbrushStop = secondBrush.Clone(); + secondbrushStop.StopIndex = 4; + secondbrushStop.IsSecondColorBrush = true; + secondbrushStop.OffsetPercent = 100; + BrushStops.Add(secondbrushStop); + + BrushStopModel lastSecondBrushStop = secondBrush.Clone(); + lastSecondBrushStop.StopIndex = 5; + secondBrush.OffsetPercent = 100; + secondBrush.IsLast = true; + BrushStops.Add(lastSecondBrushStop); + } + + public void UpdateMiddleColorBrush() + { + if (MiddleBrushStop != null && SecondBrushStop != null && FirstBrushStop != null) + { + MiddleBrushStop.Color = BrushStopModel.GetRelativeRGB(FirstBrushStop.Color, SecondBrushStop.Color, 0, 1, 0.5); + MiddleBrushStop.DisplayedColor = BrushStopModel.GetRelativeRGB(FirstBrushStop.DisplayedColor, SecondBrushStop.DisplayedColor, 0, 1, 0.5); + } + } + + + public void RemoveSecondColorOfGradient() + { + if (BrushStops.Count < 5) + return ; + BrushStops.RemoveAt(4); + BrushStops.RemoveAt(3); + } + + #endregion + + #region Brush Stops Collection Changed + + private void BrushStops_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (_brushStopCollectionChangedActionTimer == null) + { + _brushStopCollectionChangedActionTimer = new ActionTimer(TimeSpan.FromMilliseconds(100)); + } + + _brushStopCollectionChangedActionTimer.ResetReplace(() => + { + foreach (var stop in BrushStops.ToList()) + { + stop.RaiseOffsetChanged(); + } + + if (BrushStops.Count > 0) + { + BrushStops.First().OffsetPercent = 0; + } + if (BrushStops.Count > 1) + { + BrushStops.Last().OffsetPercent = 100; + } + RaiseSegmentBrushChanged(); + }); + } + + /// + /// Raises the property changed event. + /// + public void RaiseSegmentBrushChanged() + { + RaisePropertyChanged(nameof(SegmentBrush)); + RaisePropertyChanged(nameof(HasColors)); + RaisePropertyChanged(nameof(IsGradient)); + RaisePropertyChanged(nameof(FirstBrushStop)); + RaisePropertyChanged(nameof(SecondBrushStop)); + } + #endregion + + #region Properties Changed + + /// + /// Called when the Length has changed. + /// + /// + protected void OnLengthChanged(double length) + { + if (_lastLength != length) + { + BrushStops.ToList().ForEach(x => x.RaiseOffsetChanged()); + _lastLength = Length; + RaisePropertyChanged(nameof(LengthWithFactor)); + } + } + + /// + /// Called when the BrushStops has changed. + /// + /// + protected void OnBrushStopsChanged(SynchronizedObservableCollection brushstops) + { + if (brushstops != null) + { + brushstops.CollectionChanged -= BrushStops_CollectionChanged; + brushstops.CollectionChanged += BrushStops_CollectionChanged; + + foreach (var stop in brushstops.ToList()) + { + stop.RaiseOffsetChanged(); + } + + RaiseSegmentBrushChanged(); + } + } + + + + #endregion + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs new file mode 100644 index 000000000..f8c1e81a0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.NavigationObjects +{ + public class ColorSelectionNavigationObject + { + public SegmentModel SelectedSegment { get; set; } + public BrushStopModel BrushStopForEdit { get; set; } + /// + /// True when first brush is open for editing + /// + public bool IsEditingMode { get; set; } + } + +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index 09aa0a5db..5ec29360d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -136,6 +136,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -183,6 +187,7 @@ + @@ -237,6 +242,10 @@ + + + + @@ -260,12 +269,16 @@ + + + ColorSelectionToolView.xaml + JobProgressView.xaml @@ -296,6 +309,10 @@ + + {37e4ceab-b54b-451f-b535-04cf7da9c459} + ColorMine + {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL @@ -304,6 +321,10 @@ {b4fe6485-4161-4b36-bc08-67e0b53d01b7} Tango.ColorConversion + + {f9df9435-a4f3-43c5-a6cd-aad6689b42ae} + Tango.ColorPickers + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core @@ -423,7 +444,6 @@ - @@ -518,6 +538,11 @@ + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs index 1b91d2ee8..4f357be2c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs @@ -21,6 +21,7 @@ namespace Tango.PPC.Jobs TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -88,5 +89,17 @@ namespace Tango.PPC.Jobs return TangoIOC.Default.GetInstance(); } } + + + /// + /// Gets the twine catalog view VM. + /// + public static ColorSelectionToolViewVM ColorSelectionToolViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs new file mode 100644 index 000000000..ce53f1441 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.ColorConversion; +using Tango.Core.Commands; +using Tango.Core.Threading; +using Tango.PPC.Common; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Jobs.Models; +using Tango.PPC.Jobs.NavigationObjects; +using Tango.PPC.Jobs.ViewContracts; + +namespace Tango.PPC.Jobs.ViewModels +{ + public class ColorSelectionToolViewVM : PPCViewModel, INavigationResultProvider + { + public enum ColorTab + { + HSB, + CIELab, + RGB, + SMYK, + Catalogs + } + + private ActionTimer _volumeConversionTimer; + private IColorConverter _converter; + + + #region Properties + private bool _confirmed; + + public bool EditingMode { get; set; } + + private int _selectedColorTabIndex; + /// + /// Gets or sets the index of the selected category. + /// + public int SelectedColorTabIndex + { + get { return _selectedColorTabIndex; } + set + { + _selectedColorTabIndex = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(SelectedColorTab)); + OnSelectedtabChanged(); + } + } + + /// + /// Gets or sets the selected category. + /// + public ColorTab SelectedColorTab + { + get { return (ColorTab)SelectedColorTabIndex; } + set + { + if (SelectedColorTabIndex != value.ToInt32()) + { + SelectedColorTabIndex = value.ToInt32(); + } + } + } + + private int _segmentIndex; + + public int SegmentIndex + { + get { return _segmentIndex; } + set { _segmentIndex = value; + RaisePropertyChangedAuto(); + } + } + + + private BrushStopModel _firstBrushStop; + + public BrushStopModel FirstBrushStop + { + get { return _firstBrushStop; } + set { _firstBrushStop = value; + RaisePropertyChangedAuto(); } + } + + + private BrushStopModel _secondBrushStop; + + public BrushStopModel SecondBrushStop + { + get { return _secondBrushStop; } + set { + _secondBrushStop = value; + RaisePropertyChangedAuto(); } + } + + private BrushStopModel _selectedBrushStop; + + public BrushStopModel SelectedBrushStop + { + get { return _selectedBrushStop; } + set + { + _selectedBrushStop = value; + RaisePropertyChangedAuto(); + } + } + + + public bool IsSecondbrushAvailable + { + get { return SecondBrushStop != null; } + } + + #endregion + + #region Command + /// + /// Gets or sets the OK command. + /// + public RelayCommand OKCommand { get; set; } + #endregion + + public ColorSelectionToolViewVM() + { + OKCommand = new RelayCommand(Confirm); + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + _converter = new DefaultColorConverter(); + } + + /// + /// Confirms this instance. + /// + private void Confirm() + { + _confirmed = true; + + NavigationManager.NavigateBack(); + } + + public BrushStopModel GetNavigationResult() + { + if (_confirmed) + { + if(EditingMode) + { + FirstBrushStop.ColorSpace = SelectedBrushStop.ColorSpace; + FirstBrushStop.Color = SelectedBrushStop.Color; + + //TODO copy RGB ... + FirstBrushStop.DisplayedColor = SelectedBrushStop.DisplayedColor; + } + return SelectedBrushStop; + } + else + { + return null; + } + } + + public void OnNavigationObjectReceived(ColorSelectionNavigationObject obj) + { + SegmentIndex = obj.SelectedSegment.SegmentIndex; + FirstBrushStop = obj.BrushStopForEdit; + if(obj.IsEditingMode) + { + SecondBrushStop = new BrushStopModel(obj.SelectedSegment); + SelectedBrushStop = SecondBrushStop; + } + else + { + SelectedBrushStop = obj.BrushStopForEdit; + } + + EditingMode = obj.IsEditingMode; + _confirmed = false; + } + + private void OnSelectedtabChanged() + { + switch (SelectedColorTab) + { + case ColorTab.HSB: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.RaiseColorChangeHSB(); + } + + return; + } + case ColorTab.RGB: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.RaiseColorChangeRGB(); + } + return; + } + } + } + + + //public void OnBrushStopFieldValueChanged(BrushStopModel stop) + //{ + // if (stop != null && stop.ColorSpace != null) + // { + // _volumeConversionTimer.ResetReplace(() => + // { + + // try + // { + // var output = _converter.Convert(stop, false); + + // if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.Volume) + // { + // stop.Red = output.SingleCoordinates.Red; + // stop.Green = output.SingleCoordinates.Green; + // stop.Blue = output.SingleCoordinates.Blue; + // stop.L = output.SingleCoordinates.L; + // stop.A = output.SingleCoordinates.A; + // stop.B = output.SingleCoordinates.B; + // stop.Corrected = false; + // stop.OutOfGamutChecked = false; + // } + // else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.LAB) + // { + // output.ApplyOnBrushStopVolumesOnly(stop); + // stop.Corrected = false; + // stop.OutOfGamutChecked = false; + // } + // else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) + // { + // output.ApplyOnBrushStopVolumesOnly(stop); + // stop.Corrected = false; + // stop.OutOfGamutChecked = false; + // } + + // try + // { + // var closestItem = AvailableCatalogs.SelectMany(x => x.AllItemsOrdered).GetClosestItem(stop.Color); + // stop.ColorCatalog = closestItem.ColorCatalogsGroup.ColorCatalog; + // stop.ColorCatalogsItem = closestItem; + // } + // catch { } + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + // } + + // }); + + // } + //} + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 408bbc615..9b7a29242 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -39,6 +39,7 @@ using Tango.ColorConversion; using Tango.Integration.Operation; using Tango.BL.Enumerations; using Tango.PPC.Common.Lubrication; +using Tango.PPC.Jobs.Models; namespace Tango.PPC.Jobs.ViewModels { @@ -69,9 +70,21 @@ namespace Tango.PPC.Jobs.ViewModels public Job Job { get { return _job; } - set { _job = value; RaisePropertyChangedAuto(); } + set { + _job = value; + RaisePropertyChangedAuto(); } } + private JobModel _jobModel; + + public JobModel JobModel + { + get { return _jobModel; } + set { _jobModel = value; + RaisePropertyChangedAuto(); } + } + + private ICollectionView _segmentsCollectionView; /// /// Gets or sets the job segments collection view. @@ -85,7 +98,7 @@ namespace Tango.PPC.Jobs.ViewModels RaisePropertyChangedAuto(); } } - + private List _colorSpaces; /// /// Gets or sets the available color spaces. @@ -253,17 +266,17 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Gets or sets the remove segment command. /// - public RelayCommand RemoveSegmentCommand { get; set; } + public RelayCommand RemoveSegmentCommand { get; set; } /// /// Gets or sets the remove brush stop command. /// - public RelayCommand RemoveBrushStopCommand { get; set; } + public RelayCommand RemoveBrushStopCommand { get; set; } /// /// Gets or sets the remove job command. /// - public RelayCommand RemoveJobCommand { get; set; } + public RelayCommand AddColorCommand { get; set; } /// /// Gets or sets the save job command. @@ -388,11 +401,12 @@ namespace Tango.PPC.Jobs.ViewModels (e.Droppable as FrameworkElement).DataContext as Segment); }); - RemoveSegmentCommand = new RelayCommand(RemoveSegment); - RemoveBrushStopCommand = new RelayCommand(RemoveBrushStop); - RemoveJobCommand = new RelayCommand(RemoveJob); - SaveJobCommand = new RelayCommand(() => SaveJob()); - ReplaceBrushStopCommand = new RelayCommand(InvokeColorAdjustmentForBrushStop); + //RemoveSegmentCommand = new RelayCommand(RemoveSegment); + //RemoveBrushStopCommand = new RelayCommand(RemoveBrushStop); + AddColorCommand = new RelayCommand(AddColor); + + //SaveJobCommand = new RelayCommand(() => SaveJob()); + //ReplaceBrushStopCommand = new RelayCommand(InvokeColorAdjustmentForBrushStop); IncreaseDecreaseSamplesToDyeCommand = new RelayCommand((x) => { if (x == "+") @@ -486,7 +500,7 @@ namespace Tango.PPC.Jobs.ViewModels .WithBrushStops() .BuildAsync(); - //Job.RmlChanged -= OnRmlChanged; + //Job.RmlChanged += OnRmlChanged; Job.NameChanged -= Job_NameChanged; Job.NameChanged += Job_NameChanged; @@ -517,11 +531,66 @@ namespace Tango.PPC.Jobs.ViewModels _check_gamut_thread.Start(); } - SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); - SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); + // SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); + // SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); //ResetFineTuning(); - + ///NEW CODE Save to MODEL + var jobModel = new JobModel() + { + Name = Job.Name, + CreationDate = Job.CreationDate, + LengthPercentageFactor = Job.LengthPercentageFactor, + NumberOfUnits = Job.NumberOfUnits, + IsAllSegmentsPerSpool = Job.IsAllSegmentsPerSpool, + Rml = Job.Rml, + ColorSpace = Job.ColorSpace, + SpoolType = Job.SpoolType, + User = Job.User, + Machine = Job.Machine + }; + + foreach( var segm in Job.Segments) + { + SegmentModel segmentModel = new SegmentModel(jobModel) + { + Name = segm.Name, + Length = segm.Length, + SegmentIndex = segm.SegmentIndex, + IsInterSegment = segm.IsInterSegment, + Job = jobModel + }; + + foreach ( var brushStop in segm.BrushStops) + { + BrushStopModel brushStopModel = new BrushStopModel(segmentModel) + { + Cyan = brushStop.Cyan, + Magenta = brushStop.Magenta, + Yellow = brushStop.Yellow, + Black = brushStop.Black, + Red = brushStop.Red, + Green = brushStop.Green, + Blue = brushStop.Blue, + L = brushStop.L, + A = brushStop.A, + B = brushStop.B, + OffsetPercent = brushStop.OffsetPercent, + IsTransparent = brushStop.IsTransparent, + Color = brushStop.Color, + DisplayedColor = brushStop.Color, + ColorSpace = brushStop.ColorSpace.Space, + ColorCatalogsItem = brushStop.ColorCatalogsItem + }; + AddBrushStop(segmentModel, brushStopModel); + } + jobModel.Segments.Add(segmentModel); + } + JobModel = jobModel; + SegmentsCollectionView = CollectionViewSource.GetDefaultView(JobModel.Segments); + SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(SegmentModel.SegmentIndex), ListSortDirection.Ascending)); + + /// _job_to_load = null; _current_job_string = Job.ToJobFileWhenLoaded().ToString(); @@ -630,29 +699,7 @@ namespace Tango.PPC.Jobs.ViewModels } } - /// - /// Removes the job. - /// - private async void RemoveJob() - { - try - { - LogManager.Log("Removing job..."); - - if (await NotificationProvider.ShowQuestion("Are you sure you want to delete the this job?")) - { - await Job.DeleteCascadeAsync(_db); - RaiseMessage(new JobRemovedMessage() { Job = Job }); - _can_navigate_back = true; - await NavigationManager.NavigateBack(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error removing job '{Job.Name}'."); - await NotificationProvider.ShowError("An error occurred while trying to remove the job."); - } - } + /// /// Starts the job. @@ -1188,6 +1235,85 @@ namespace Tango.PPC.Jobs.ViewModels return Job.Segments.SelectMany(x => x.BrushStops).ToList().All(x => x.Validate(_db)); } + /// + /// Click on AddColor button. Add newBrush; + /// + private async void AddColor(SegmentModel segment) + { + LogManager.Log($"Adding new color to segment {segment.SegmentIndex}."); + + var newBrushStop = await NavigationManager.NavigateForResult( + new ColorSelectionNavigationObject() + { + SelectedSegment = segment, + BrushStopForEdit = new BrushStopModel(segment), + IsEditingMode = false + }, true); + + AddBrushStop(segment, newBrushStop); + // SetSegmentLiquidVolumes(segment); + //RegisterJobBrushStopsEvents(); + } + + /// + /// Click on Edit Color button. Add newBrush; + /// + private async void EditColor(BrushStopModel brushStop) + { + SegmentModel segment = brushStop.SegmentModel; + LogManager.Log($"Edit brush stop."); + + var newBrushStop = await NavigationManager.NavigateForResult( + new ColorSelectionNavigationObject() + { + SelectedSegment = segment, + BrushStopForEdit = brushStop, + IsEditingMode = true + }, true); + } + + public async void AddBrushStop(SegmentModel segment, BrushStopModel newBrushStop) + { + if (newBrushStop == null || segment == null) + return; + + JobModel job = segment.Job; + + //SolidColor + if(segment.BrushStops.Count == 0) + { + newBrushStop.IsFirstColorBrush = true; + segment.BrushStops.Add(newBrushStop); + } + //Add SecondColor + else if(segment.BrushStops.Count == 1)// add gradient + { + BrushStopModel currentBrushStop = segment.BrushStops[0]; + segment.CreateGradientBrushes(segment.BrushStops[0], newBrushStop); + segment.RaiseSegmentBrushChanged(); + } + else + { + if (segment.BrushStops.Count < 5) + { + return;//error!!!! + } + await NotificationProvider.ShowInfo("Please note that gradient segment is now split into two gradients."); + + SegmentModel newSegmentModel = segment.Clone(); + newSegmentModel.SegmentIndex = segment.SegmentIndex + 1; + newSegmentModel.CreateGradientBrushes(newBrushStop, segment.SecondBrushStop); + newSegmentModel.RaiseSegmentBrushChanged(); + + segment.AddOrReplaceSecondBrush(newBrushStop); + segment.UpdateMiddleColorBrush(); + segment.RaiseSegmentBrushChanged(); + + //TODO update segment indexes??? + job.Segments.Add(newSegmentModel); + + } + } #endregion #region Job Selection Message diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml new file mode 100644 index 000000000..cb061078a --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + First Choice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + My Colors + + + + + + + + + + + + + + + Job Palette + + + OK + + + + + + + + + + + + + + + + + + + + HSB + CIELab + RGB + CMYK + Catalogs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Palette + + + OK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Palette + + + OK + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs new file mode 100644 index 000000000..9e2703372 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.PPC.Jobs.Converters; +using Tango.PPC.Jobs.ViewModels; +using Tango.Touch.Controls; +using static Tango.SharedUI.Controls.NavigationControl; +using static Tango.PPC.Jobs.ViewModels.ColorSelectionToolViewVM; + +namespace Tango.PPC.Jobs.Views +{ + /// + /// Interaction logic for ColorSelectionToolView.xaml + /// + public partial class ColorSelectionToolView : UserControl + { + private ColorSelectionToolViewVM _vm; + public ColorSelectionToolView() + { + InitializeComponent(); + + Loaded += (_, __) => + { + _vm = DataContext as ColorSelectionToolViewVM; + }; + + } + + + + private void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + //if(navigationCSTLinks.SelectedIndex == 2 && RGBPicker != null) + //{ + // await Task.Delay(300); + //} + } + + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml index af14f7522..487adf0bc 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml @@ -23,6 +23,9 @@ + + + @@ -63,11 +66,46 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -82,10 +120,20 @@ - - - - + + + + + + + + + + + + + + @@ -134,8 +182,8 @@ - - #. + + #. @@ -202,258 +250,203 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - Segment # - - - + + + + Segment # + + + + + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + - + - - + + + Add Color + + - + - + + - - - - - - - - + - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + - ADD COLOR - - + + + + + + Add New Segments - + + + - + @@ -475,250 +468,32 @@ - + - - - - - - Job Details - - - - - - - - - - - - Job name: - - - - - Customer: - - - - - Thread type: - - - - - - - - Lubrication - - - - - - - - Required tensioner level is - - - - - - - Comment: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - Color & Length - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + Color & Length + + + + + - - - - - - - SOLID SEGMENT - - - - - - - - - - - - - GRADIENT SEGMENT - - - - - - - Include white gap between segments - - - - - - - - - - - - - + - - Output + - - - - - - - - - - - - - Embroidery File - - - - - - - - Export the attached embroidery file to storage. - EXPORT FILE - - - - - - - @@ -730,7 +505,7 @@ - + @@ -740,20 +515,20 @@ - + - (+%) + (+%) @@ -762,7 +537,7 @@ - + % @@ -776,416 +551,13 @@ Additional Tools - - - + @@ -1199,43 +571,42 @@ - - - - - + - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs index 86a8d2a37..710f92e40 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs @@ -52,14 +52,14 @@ namespace Tango.PPC.Jobs.Views _vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop); } - public async void DisplaySampleDye() + public void DisplaySampleDye() { //expander_sample_dye.IsExpanded = true; //await Task.Delay(500); //scrollViewer.ScrollToElement(expander_sample_dye); } - public async void DisplayFineTuning() + public void DisplayFineTuning() { //expander_fine_tuning.IsExpanded = true; //await Task.Delay(500); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml index 505ccc312..77d2d200d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/MainView.xaml @@ -17,6 +17,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index b742c3b73..189454b9f 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -10,6 +10,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index 5272eb35d..4d7554231 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -13,7 +13,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs b/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs index d254475d9..1f1df04db 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/ColorSpaces.cs @@ -49,5 +49,12 @@ namespace Tango.BL.Enumerations [Description("Catalog")] Catalog = 4, + + /// + /// (Catalog) + /// + [Description("HSB")] + HSB = 5, + } } diff --git a/Software/Visual_Studio/Tango.ColorPickers/ColorPickerSlider.cs b/Software/Visual_Studio/Tango.ColorPickers/ColorPickerSlider.cs index a4fb5a2b0..e48c26e31 100644 --- a/Software/Visual_Studio/Tango.ColorPickers/ColorPickerSlider.cs +++ b/Software/Visual_Studio/Tango.ColorPickers/ColorPickerSlider.cs @@ -13,7 +13,6 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Xceed.Wpf.Toolkit.Core.Utilities; namespace Tango.ColorPickers { diff --git a/Software/Visual_Studio/Tango.ColorPickers/Tango.ColorPickers.csproj b/Software/Visual_Studio/Tango.ColorPickers/Tango.ColorPickers.csproj index 3929e312d..4e7d5769d 100644 --- a/Software/Visual_Studio/Tango.ColorPickers/Tango.ColorPickers.csproj +++ b/Software/Visual_Studio/Tango.ColorPickers/Tango.ColorPickers.csproj @@ -35,6 +35,12 @@ ..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll + + ..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll + + + ..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll + @@ -87,6 +93,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -97,18 +104,6 @@ {37e4ceab-b54b-451f-b535-04cf7da9c459} ColorMine - - {90b53209-c60c-4655-b28d-a1b3e1044ba3} - MaterialDesignColors.Wpf - - - {f079fb0a-a8ed-4216-b6a5-345756751a04} - MaterialDesignThemes.Wpf - - - {72e591d6-8f83-4d8c-8f67-9c325e623234} - Xceed.Wpf.Toolkit - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} Tango.Core diff --git a/Software/Visual_Studio/Tango.ColorPickers/Themes/Generic.xaml b/Software/Visual_Studio/Tango.ColorPickers/Themes/Generic.xaml index 9c6f8582a..b0544200b 100644 --- a/Software/Visual_Studio/Tango.ColorPickers/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.ColorPickers/Themes/Generic.xaml @@ -129,7 +129,7 @@ - +