From c5713f263db2aa8eda95e13c14ed31d1335b6bc0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 8 Jul 2019 17:50:11 +0300 Subject: Refactoring of all color catalogs objects !!! --- .../Controls/CoatsCatalogViewer.xaml | 27 ---- .../Controls/CoatsCatalogViewer.xaml.cs | 96 ------------- .../Controls/TwineCatalogViewer.xaml.cs | 22 +-- .../Converters/ColorSpaceToImageConverter.cs | 2 +- .../Converters/ColorSpaceToVisibilityConverter.cs | 2 +- .../TwineCatalogNavigationObject.cs | 5 +- .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 17 +-- .../PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs | 12 -- .../ViewModels/CoatsCatalogViewVM.cs | 153 --------------------- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 119 +++++++--------- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 4 +- .../ViewModels/TwineCatalogViewVM.cs | 38 +++-- .../Tango.PPC.Jobs/Views/CoatsCatalogView.xaml | 57 -------- .../Tango.PPC.Jobs/Views/CoatsCatalogView.xaml.cs | 28 ---- .../PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml | 40 +----- .../PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml | 1 - 16 files changed, 91 insertions(+), 532 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/CoatsCatalogViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml.cs (limited to 'Software/Visual_Studio/PPC/Modules') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml deleted file mode 100644 index db526419f..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - CATALOG - RECENT - - - - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml.cs deleted file mode 100644 index 573d90d45..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/CoatsCatalogViewer.xaml.cs +++ /dev/null @@ -1,96 +0,0 @@ -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.Catalogs; - -namespace Tango.PPC.Jobs.Controls -{ - /// - /// Interaction logic for CoatsCatalogViewer.xaml - /// - public partial class CoatsCatalogViewer : UserControl - { - private Catalog _originalCatalog; - - /// - /// Gets or sets the recent catalog items as a catalog. - /// - public Catalog Recent - { - get { return (Catalog)GetValue(RecentProperty); } - set { SetValue(RecentProperty, value); } - } - public static readonly DependencyProperty RecentProperty = - DependencyProperty.Register("Recent", typeof(Catalog), typeof(CoatsCatalogViewer), new PropertyMetadata(null)); - - /// - /// Gets or sets the catalog. - /// - public Catalog Catalog - { - get { return (Catalog)GetValue(CatalogProperty); } - set { SetValue(CatalogProperty, value); } - } - public static readonly DependencyProperty CatalogProperty = - DependencyProperty.Register("Catalog", typeof(Catalog), typeof(CoatsCatalogViewer), new PropertyMetadata(null)); - - /// - /// Gets or sets the selected catalog item. - /// - public CatalogItem SelectedItem - { - get { return (CatalogItem)GetValue(SelectedItemProperty); } - set { SetValue(SelectedItemProperty, value); } - } - public static readonly DependencyProperty SelectedItemProperty = - DependencyProperty.Register("SelectedItem", typeof(CatalogItem), typeof(CoatsCatalogViewer), 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(CoatsCatalogViewer), new PropertyMetadata(null, (d, e) => (d as CoatsCatalogViewer).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 CoatsCatalogViewer() - { - InitializeComponent(); - Filter = "CATALOG"; - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogViewer.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogViewer.xaml.cs index a84e29bd2..929e9cd76 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogViewer.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogViewer.xaml.cs @@ -12,7 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Tango.BL.Catalogs; +using Tango.BL.Entities; namespace Tango.PPC.Jobs.Controls { @@ -23,40 +23,40 @@ namespace Tango.PPC.Jobs.Controls /// public partial class TwineCatalogViewer : UserControl { - private Catalog _originalCatalog; + private ColorCatalog _originalCatalog; /// /// Gets or sets the recent catalog items as a catalog. /// - public Catalog Recent + public ColorCatalog Recent { - get { return (Catalog)GetValue(RecentProperty); } + get { return (ColorCatalog)GetValue(RecentProperty); } set { SetValue(RecentProperty, value); } } public static readonly DependencyProperty RecentProperty = - DependencyProperty.Register("Recent", typeof(Catalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + DependencyProperty.Register("Recent", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); /// /// Gets or sets the catalog. /// - public Catalog Catalog + public ColorCatalog Catalog { - get { return (Catalog)GetValue(CatalogProperty); } + get { return (ColorCatalog)GetValue(CatalogProperty); } set { SetValue(CatalogProperty, value); } } public static readonly DependencyProperty CatalogProperty = - DependencyProperty.Register("Catalog", typeof(Catalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + DependencyProperty.Register("Catalog", typeof(ColorCatalog), typeof(TwineCatalogViewer), new PropertyMetadata(null)); /// /// Gets or sets the selected catalog item. /// - public CatalogItem SelectedItem + public ColorCatalogsItem SelectedItem { - get { return (CatalogItem)GetValue(SelectedItemProperty); } + get { return (ColorCatalogsItem)GetValue(SelectedItemProperty); } set { SetValue(SelectedItemProperty, value); } } public static readonly DependencyProperty SelectedItemProperty = - DependencyProperty.Register("SelectedItem", typeof(CatalogItem), typeof(TwineCatalogViewer), new PropertyMetadata(null)); + DependencyProperty.Register("SelectedItem", typeof(ColorCatalogsItem), typeof(TwineCatalogViewer), new PropertyMetadata(null)); /// /// Gets or sets the current catalog filter. diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToImageConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToImageConverter.cs index c2790ee6d..f10bf0064 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToImageConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToImageConverter.cs @@ -24,7 +24,7 @@ namespace Tango.PPC.Jobs.Converters return ResourceHelper.GetImageFromResources("Images/NewJob/rgb.png"); case ColorSpaces.LAB: return ResourceHelper.GetImageFromResources("Images/NewJob/lab.png"); - case ColorSpaces.Twine: + case ColorSpaces.Catalog: return ResourceHelper.GetImageFromResources("Images/NewJob/twine.png"); case ColorSpaces.Volume: return ResourceHelper.GetImageFromResources("Images/NewJob/volume.png"); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToVisibilityConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToVisibilityConverter.cs index f7e3bb282..a8ba66eda 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToVisibilityConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Converters/ColorSpaceToVisibilityConverter.cs @@ -18,7 +18,7 @@ namespace Tango.PPC.Jobs.Converters if (colorSpace != null) { - if (colorSpace.Space == BL.Enumerations.ColorSpaces.Twine || colorSpace.Space == BL.Enumerations.ColorSpaces.Coats) + if (colorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) { return Visibility.Collapsed; } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs index cb1b892fd..edd18a2c0 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/NavigationObjects/TwineCatalogNavigationObject.cs @@ -9,8 +9,7 @@ namespace Tango.PPC.Jobs.NavigationObjects { public class TwineCatalogNavigationObject { - public Rml RML { get; set; } - - public BrushStop BrushStop { get; set; } + public ColorCatalog Catalog { get; set; } + public ColorCatalogsItem SelectedItem { get; set; } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 74fbc1bdb..5531c1c4c 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -72,10 +72,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer @@ -148,10 +144,6 @@ Designer MSBuild:Compile - - MSBuild:Compile - Designer - MSBuild:Compile Designer @@ -167,9 +159,6 @@ - - CoatsCatalogViewer.xaml - RunningJobViewer.xaml @@ -251,7 +240,6 @@ - JobProgressView.xaml @@ -268,9 +256,6 @@ MainView.xaml - - CoatsCatalogView.xaml - TwineCatalogView.xaml @@ -479,7 +464,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs index c419bb8e2..1b91d2ee8 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModelLocator.cs @@ -20,7 +20,6 @@ namespace Tango.PPC.Jobs TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); TangoIOC.Default.Register(); } @@ -79,17 +78,6 @@ namespace Tango.PPC.Jobs } } - /// - /// Gets the coats catalog view VM. - /// - public static CoatsCatalogViewVM CoatsCatalogViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } - } - /// /// Gets the job progress view VM. /// diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/CoatsCatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/CoatsCatalogViewVM.cs deleted file mode 100644 index ebeb5b704..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/CoatsCatalogViewVM.cs +++ /dev/null @@ -1,153 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.Catalogs; -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 coats catalog view model. - /// - /// - /// - public class CoatsCatalogViewVM : PPCViewModel, INavigationResultProvider - { - private bool _confirmed; - private ObservablesContext _db; - - private Catalog _catalog; - /// - /// Gets or sets the catalog. - /// - public Catalog Catalog - { - get { return _catalog; } - set { _catalog = value; RaisePropertyChangedAuto(); } - } - - private Catalog _recent; - /// - /// Gets or sets the recent catalog items as a complete catalog. - /// - public Catalog 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 CatalogItem _selectedItem; - /// - /// Gets or sets the selected item. - /// - public CatalogItem 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 CoatsCatalogViewVM() - { - 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() - { - SettingsManager.Default.GetOrCreate().RecentCoatsCatalogColors.Add(SelectedItem.Entity.Name); - SettingsManager.Default.Save(); - - _confirmed = true; - NavigationManager.NavigateBack(); - } - - /// - /// Called when the navigation system requests a result when it is navigating away from this instance. - /// - /// - public CatalogItem GetNavigationResult() - { - if (_confirmed) - { - return SelectedItem; - } - else - { - return null; - } - } - - /// - /// Called when the navigation object has been received - /// - /// The brush stop. - public async virtual void OnNavigationObjectReceived(TwineCatalogNavigationObject obj) - { - IsFree = false; - Catalog = await CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Coats, obj.RML, _db); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate().RecentCoatsCatalogColors); - IsFree = true; - - if (obj.BrushStop.ColorCatalog != null) - { - SelectedItem = Catalog.Groups.SelectMany(x => x.Items).SingleOrDefault(x => x.Entity.Guid == obj.BrushStop.ColorCatalog.Guid); - } - else - { - SelectedItem = null; - } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index fb1f240c5..08a5e1168 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -17,7 +17,6 @@ using System.ComponentModel; using System.Windows.Data; using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.Views; -using Tango.BL.Catalogs; using System.Runtime.InteropServices; using System.Threading; using Tango.SharedUI.Helpers; @@ -186,34 +185,39 @@ namespace Tango.PPC.Jobs.ViewModels set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } } - private List _twineCatalogItems; + private List _catalogItems; /// /// Gets or sets the twine catalog items. /// - public List TwineCatalogItems + public List CatalogItems { - get { return _twineCatalogItems; } - set { _twineCatalogItems = value; RaisePropertyChangedAuto(); } + get { return _catalogItems; } + set { _catalogItems = value; RaisePropertyChangedAuto(); } } + private ColorCatalogsItem _selectedCatalogItem; /// - /// Gets or sets the twine catalog automatic complete provider. + /// Gets or sets the selected catalog item. /// - public IAutoCompleteProvider TwineCatalogAutoCompleteProvider { get; set; } + public ColorCatalogsItem SelectedCatalogItem + { + get { return _selectedCatalogItem; } + set { _selectedCatalogItem = value; RaisePropertyChangedAuto(); } + } /// - /// Gets or sets the coats catalog automatic complete provider. + /// Gets or sets the twine catalog automatic complete provider. /// - public IAutoCompleteProvider CoatsCatalogAutoCompleteProvider { get; set; } + public IAutoCompleteProvider CatalogAutoCompleteProvider { get; set; } - private List _coatsCatalogItems; + private ColorCatalog _selectedCatalog; /// - /// Gets or sets the coats catalog items. + /// Gets or sets the selected catalog. /// - public List CoatsCatalogItems + public ColorCatalog SelectedCatalog { - get { return _coatsCatalogItems; } - set { _coatsCatalogItems = value; RaisePropertyChangedAuto(); } + get { return _selectedCatalog; } + set { _selectedCatalog = value; RaisePropertyChangedAuto(); } } #endregion @@ -268,12 +272,7 @@ namespace Tango.PPC.Jobs.ViewModels /// /// Gets or sets the twine catalog field tap command. /// - public RelayCommand OpenTwineCatalogCommand { get; set; } - - /// - /// Gets or sets the open coats catalog command. - /// - public RelayCommand OpenCoatsCatalogCommand { get; set; } + public RelayCommand OpenCatalogCommand { get; set; } /// /// Gets or sets the increase decrease samples to dye command. @@ -360,8 +359,7 @@ namespace Tango.PPC.Jobs.ViewModels FineTuneItems = new ObservableCollection(); ApprovalFineTuneItems = new ObservableCollection(); - TwineCatalogItems = new List(); - CoatsCatalogItems = new List(); + CatalogItems = new List(); CustomersAutoCompleteProvider = new AutoCompleteProvider((customer, filter) => { @@ -369,14 +367,9 @@ namespace Tango.PPC.Jobs.ViewModels }); - TwineCatalogAutoCompleteProvider = new AutoCompleteProvider((color, filter) => + CatalogAutoCompleteProvider = new AutoCompleteProvider((item, filter) => { - return !String.IsNullOrWhiteSpace(filter) && color.RmlGuid == Job.Rml.Guid && color.Name.ToLower().StartsWith(filter.ToLower()); - }); - - CoatsCatalogAutoCompleteProvider = new AutoCompleteProvider((color, filter) => - { - return !String.IsNullOrWhiteSpace(filter) && color.RmlGuid == Job.Rml.Guid && color.Name.ToLower().StartsWith(filter.ToLower()); + return !String.IsNullOrWhiteSpace(filter) && item.Name.ToLower().StartsWith(filter.ToLower()); }); //Initialize Commands @@ -421,8 +414,7 @@ namespace Tango.PPC.Jobs.ViewModels StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected) && CanStartJob()); RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); - OpenTwineCatalogCommand = new RelayCommand(OpenTwineCatalog); - OpenCoatsCatalogCommand = new RelayCommand(OpenCoatsCatalog); + OpenCatalogCommand = new RelayCommand(OpenCatalog); ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); } @@ -479,8 +471,12 @@ namespace Tango.PPC.Jobs.ViewModels SpoolTypes = await _db.SpoolTypes.ToListAsync(); LogManager.Log("Loading Customers..."); Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); - TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); - CoatsCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Coats).OrderBy(x => x.Name).ToListAsync(); + + if (Job.ColorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) + { + SelectedCatalog = await new ColorCatalogBuilder(_db).SetFirst().WithGroups().WithItems().BuildAsync(); + CatalogItems = SelectedCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).ToList(); + } foreach (var segment in Job.Segments) { @@ -655,24 +651,23 @@ namespace Tango.PPC.Jobs.ViewModels #region RML Changed - protected virtual async void OnRmlChanged(object sender, Rml rml) + protected virtual void OnRmlChanged(object sender, Rml rml) { - TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); - CoatsCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Coats).OrderBy(x => x.Name).ToListAsync(); - - //Replace all brush stops twine color catalogs. - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Twine).ToList()) - { - var replacement = TwineCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); - stop.ColorCatalog = replacement; - } - - //Replace all brush stops coats color catalogs. - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Coats).ToList()) - { - var replacement = CoatsCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); - stop.ColorCatalog = replacement; - } + //There is no need for that. + + ////Replace all brush stops twine color catalogs. + //foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Twine).ToList()) + //{ + // var replacement = CatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); + // stop.ColorCatalog = replacement; + //} + + ////Replace all brush stops coats color catalogs. + //foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Coats).ToList()) + //{ + // var replacement = CoatsCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); + // stop.ColorCatalog = replacement; + //} ResetFineTuning(); } @@ -935,31 +930,17 @@ namespace Tango.PPC.Jobs.ViewModels /// Opens the twine catalog for the specified brush stop. /// /// The stop. - private async void OpenTwineCatalog(BrushStop stop) - { - var catalogItem = await NavigationManager.NavigateForResult(new TwineCatalogNavigationObject() - { - BrushStop = stop, - RML = Job.Rml, - }, true); - - if (catalogItem != null) - { - stop.ColorCatalog = TwineCatalogItems.SingleOrDefault(x => x.Name == catalogItem.Entity.Name); - } - } - - private async void OpenCoatsCatalog(BrushStop stop) + private async void OpenCatalog(BrushStop stop) { - var catalogItem = await NavigationManager.NavigateForResult(new TwineCatalogNavigationObject() + var catalogItem = await NavigationManager.NavigateForResult(new TwineCatalogNavigationObject() { - BrushStop = stop, - RML = Job.Rml, + SelectedItem = stop.ColorCatalogsItem, + Catalog = SelectedCatalog }, true); if (catalogItem != null) { - stop.ColorCatalog = CoatsCatalogItems.SingleOrDefault(x => x.Name == catalogItem.Entity.Name); + stop.ColorCatalogsItem = catalogItem; } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 248003b30..b7a6ad94a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -421,12 +421,12 @@ namespace Tango.PPC.Jobs.ViewModels if (settings.LastJobColorSpace != null) { - vm.SelectedColorSpace = settings.LastJobColorSpace.Value.IsUserSpace() ? settings.LastJobColorSpace.Value : ColorSpaces.Twine; + vm.SelectedColorSpace = settings.LastJobColorSpace.Value.IsUserSpace() ? settings.LastJobColorSpace.Value : ColorSpaces.Catalog; } else { var space = machine.SupportedColorSpaces.FirstOrDefault(); - vm.SelectedColorSpace = space.IsUserSpace() ? space : ColorSpaces.Twine; + vm.SelectedColorSpace = space.IsUserSpace() ? space : ColorSpaces.Catalog; } if (colorProfile != null || twnFile != null) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs index a72013d26..d7d720434 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL; -using Tango.BL.Catalogs; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.PPC.Common; @@ -19,26 +18,26 @@ namespace Tango.PPC.Jobs.ViewModels /// /// /// - public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider + public class TwineCatalogViewVM : PPCViewModel, INavigationResultProvider { private bool _confirmed; private ObservablesContext _db; - private Catalog _catalog; + private ColorCatalog _catalog; /// /// Gets or sets the catalog. /// - public Catalog Catalog + public ColorCatalog Catalog { get { return _catalog; } set { _catalog = value; RaisePropertyChangedAuto(); } } - private Catalog _recent; + private ColorCatalog _recent; /// /// Gets or sets the recent catalog items as a complete catalog. /// - public Catalog Recent + public ColorCatalog Recent { get { return _recent; } set { _recent = value; RaisePropertyChangedAuto(); } @@ -57,11 +56,11 @@ namespace Tango.PPC.Jobs.ViewModels set { _filter = value; RaisePropertyChangedAuto(); } } - private CatalogItem _selectedItem; + private ColorCatalogsItem _selectedItem; /// /// Gets or sets the selected item. /// - public CatalogItem SelectedItem + public ColorCatalogsItem SelectedItem { get { return _selectedItem; } set @@ -106,7 +105,7 @@ namespace Tango.PPC.Jobs.ViewModels /// private void Confirm() { - SettingsManager.Default.GetOrCreate().RecentTwineCatalogColors.Add(SelectedItem.Entity.Name); + SettingsManager.Default.GetOrCreate().RecentTwineCatalogColors.Add(SelectedItem.Guid); SettingsManager.Default.Save(); _confirmed = true; @@ -117,7 +116,7 @@ namespace Tango.PPC.Jobs.ViewModels /// Called when the navigation system requests a result when it is navigating away from this instance. /// /// - public CatalogItem GetNavigationResult() + public ColorCatalogsItem GetNavigationResult() { if (_confirmed) { @@ -133,21 +132,16 @@ namespace Tango.PPC.Jobs.ViewModels /// Called when the navigation object has been received /// /// The brush stop. - public async virtual void OnNavigationObjectReceived(TwineCatalogNavigationObject obj) + public virtual void OnNavigationObjectReceived(TwineCatalogNavigationObject obj) { IsFree = false; - Catalog = await CatalogLoader.LoadCatalog(BL.Enumerations.ColorSpaces.Twine, obj.RML, _db); - Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate().RecentTwineCatalogColors); - IsFree = true; - if (obj.BrushStop.ColorCatalog != null) - { - SelectedItem = Catalog.Groups.SelectMany(x => x.Items).SingleOrDefault(x => x.Entity.Guid == obj.BrushStop.ColorCatalog.Guid); - } - else - { - SelectedItem = null; - } + Catalog = obj.Catalog; + //Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate().RecentTwineCatalogColors); + + SelectedItem = obj.SelectedItem; + + IsFree = true; } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml deleted file mode 100644 index 60f747ab9..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - Coats Catalog - - - - - - - - - - - - - - - - - - - - - - - Shade Card - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml.cs deleted file mode 100644 index c644b32b4..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/CoatsCatalogView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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 CoatsCatalogView : UserControl - { - public CoatsCatalogView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml index 957fead70..ec21ebade 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobView.xaml @@ -86,30 +86,10 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + @@ -161,11 +141,8 @@ - - - - - + + @@ -306,11 +283,8 @@ - - - - - + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml index 21361e74f..505ccc312 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/MainView.xaml @@ -16,7 +16,6 @@ - -- cgit v1.3.1