aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-09-09 11:21:19 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-09-09 11:21:19 +0300
commit679ebf3c9ecb0271b765df122168d45be8a4a7cb (patch)
treef31dd6765645d5afca5729adcd61b5b3c4a1b84c /Software/Visual_Studio/PPC/Modules
parent96e602f99fd9989b6161de89fd37fd9d7ac65d19 (diff)
parentd2c6293957afc55bede9f00db65a50ac0f1b2bf4 (diff)
downloadTango-679ebf3c9ecb0271b765df122168d45be8a4a7cb.tar.gz
Tango-679ebf3c9ecb0271b765df122168d45be8a4a7cb.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModuleSettings.cs51
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/TwineCatalogViewVM.cs42
3 files changed, 83 insertions, 12 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
index e1edb66f2..ded395e08 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/CatalogSelectionView.xaml
@@ -33,7 +33,7 @@
<touch:TouchStaticListBox Margin="20" VerticalAlignment="Center" HorizontalAlignment="Center" Width="480" ItemsSource="{Binding Catalogs}" SelectedItem="{Binding SelectedCatalog,Mode=TwoWay}">
<touch:TouchStaticListBox.ItemsPanel>
<ItemsPanelTemplate>
- <UniformGrid Columns="{Binding Catalogs.Count}" />
+ <WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</touch:TouchStaticListBox.ItemsPanel>
<touch:TouchStaticListBox.ItemContainerStyle>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModuleSettings.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModuleSettings.cs
index 3d72509e0..85278d692 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModuleSettings.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/JobsModuleSettings.cs
@@ -3,6 +3,7 @@ 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;
@@ -14,15 +15,21 @@ namespace Tango.PPC.Jobs
/// <seealso cref="Tango.Settings.SettingsBase" />
public class JobsModuleSettings : SettingsBase
{
- /// <summary>
- /// Gets or sets the recent twine catalog colors.
- /// </summary>
- public List<String> RecentTwineCatalogColors { get; set; }
+ public class RecentCatalog
+ {
+ public String Guid { get; set; }
+ public List<String> RecentItems { get; set; }
+
+ public RecentCatalog()
+ {
+ RecentItems = new List<string>();
+ }
+ }
/// <summary>
- /// Gets or sets the recent coats catalog colors.
+ /// Gets or sets the recent catalogs items.
/// </summary>
- public List<String> RecentCoatsCatalogColors { get; set; }
+ public List<RecentCatalog> RecentCatalogsItems { get; set; }
/// <summary>
/// Gets or sets the last job color space.
@@ -40,12 +47,40 @@ namespace Tango.PPC.Jobs
public String LastSelectedCatalogGuid { get; set; }
/// <summary>
+ /// Adds a catalog item to the recent list.
+ /// </summary>
+ /// <param name="catalog">The catalog.</param>
+ /// <param name="item">The catalog item.</param>
+ 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);
+ }
+ }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="JobsModuleSettings"/> class.
/// </summary>
public JobsModuleSettings()
{
- RecentTwineCatalogColors = new List<string>();
- RecentCoatsCatalogColors = new List<string>();
+ RecentCatalogsItems = new List<RecentCatalog>();
}
}
}
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 d7d720434..b2e16c5eb 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
@@ -105,8 +105,12 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
private void Confirm()
{
- SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors.Add(SelectedItem.Guid);
- SettingsManager.Default.Save();
+ if (SelectedItem != null)
+ {
+ var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>();
+ settings.AddRecentCatalogItem(Catalog, SelectedItem);
+ SettingsManager.Default.Save();
+ }
_confirmed = true;
NavigationManager.NavigateBack();
@@ -137,7 +141,39 @@ namespace Tango.PPC.Jobs.ViewModels
IsFree = false;
Catalog = obj.Catalog;
- //Recent = CatalogLoader.GetRecent(Catalog, SettingsManager.Default.GetOrCreate<JobsModuleSettings>().RecentTwineCatalogColors);
+
+ ColorCatalog recentCatalog = new ColorCatalog();
+ recentCatalog.Name = Catalog.Name;
+
+ var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>();
+
+ 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;