From 199aa2eb46bf1625d0bbc8b98efe35d158cff9be Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Tue, 8 Feb 2022 12:48:14 +0200 Subject: Implement MyColors in PPC Related Work Items: #4558 --- .../Dialogs/ColorSelectionView.xaml | 176 +++++++++- .../Dialogs/ColorSelectionViewVM.cs | 389 ++++++++++++++++++--- .../Images/ColorSelection/add_group.png | Bin 0 -> 1201 bytes .../Images/ColorSelection/close_mycolorsdlg.png | Bin 0 -> 994 bytes .../Images/ColorSelection/delete_color.png | Bin 0 -> 351 bytes .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 29 +- .../Tango.PPC.JobsV2/Models/ColorLibrary.cs | 83 +++++ .../Tango.PPC.JobsV2/Models/FavoriteColor.cs | 109 ++++++ .../Modules/Tango.PPC.JobsV2/Models/JobModel.cs | 2 +- .../Tango.PPC.JobsV2/Models/SegmentModel.cs | 2 +- .../Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs | 76 ++++ .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 16 + .../PPC/Modules/Tango.PPC.JobsV2/packages.config | 1 + .../Controls/TwineCatalogRenderer.cs | 6 +- .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 1 + .../PPC/Tango.PPC.Common/Resources/Styles.xaml | 30 +- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.Touch/Styles/TouchScrollViewer.xaml | 91 +++++ .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 6 +- .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 3 +- 20 files changed, 945 insertions(+), 77 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.png create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Styles/TouchScrollViewer.xaml diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml index abe89b0d7..7880e8639 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs" xmlns:vm="clr-namespace:Tango.PPC.Jobs.Dialogs" + xmlns:models="clr-namespace:Tango.PPC.Jobs.Models" xmlns:controls="clr-namespace:Tango.PPC.Jobs.Controls" xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" @@ -14,9 +15,8 @@ mc:Ignorable="d" Background="{StaticResource TangoMidBackgroundBrush}" d:DesignHeight="1280" d:DesignWidth="800" Width="750" Height="1200" - d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}"> + d:DataContext="{d:DesignInstance Type=vm:ColorSelectionViewVM, IsDesignTimeCreatable=False}" x:Name="colorSelectionView"> - @@ -26,6 +26,32 @@ + + + + @@ -109,17 +135,17 @@ - + - + - + @@ -159,6 +185,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -238,8 +350,6 @@ - - @@ -253,13 +363,12 @@ - - + @@ -288,6 +397,7 @@ /> + @@ -313,7 +423,7 @@ /> - + @@ -344,7 +454,7 @@ MaxKeyValue="{Binding MaxBlackValue, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -384,5 +494,49 @@ + + + + + + + + + + + + + + + + + + + + Add Group + + + Add + + + + + + + My Colors + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs index 0412cb64a..8ca9791f5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -1,5 +1,7 @@ -using System; +using ColorMine.ColorSpaces; +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; @@ -8,10 +10,13 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.ColorConversion; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.Core.Threading; using Tango.PPC.Common; using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; using Tango.PPC.Jobs.Models; +using Tango.PPC.Jobs.MyColors; using Tango.PPC.Jobs.NavigationObjects; using Tango.PPC.Jobs.ViewContracts; using Tango.SharedUI; @@ -46,10 +51,10 @@ namespace Tango.PPC.Jobs.Dialogs public bool IsEditingMode { get; set; } } - private ActionTimer _volumeConversionTimer; private IColorConverter _converter; - + [TangoInject] + public INotificationProvider NotificationProvider { get; set; } #region Properties @@ -74,7 +79,7 @@ namespace Tango.PPC.Jobs.Dialogs get { return _selectedColorTabIndex; } set { - if(_selectedColorTabIndex != value) + if (_selectedColorTabIndex != value) { _selectedColorTabIndex = value; RaisePropertyChangedAuto(); @@ -117,7 +122,8 @@ namespace Tango.PPC.Jobs.Dialogs /// public ColorTab SelectedColorTab { - get { + get + { return _selectedColorTab; } set @@ -125,38 +131,38 @@ namespace Tango.PPC.Jobs.Dialogs if (_selectedColorTab != value) { _selectedColorTab = value; - switch (SelectedColorTab) - { - case ColorTab.HSB: - { - SelectedColorTabIndex = 0; - break; - } - case ColorTab.CIELab: - { - SelectedColorTabIndex = 1; - break; - } - case ColorTab.RGB: - { - SelectedColorTabIndex = 2; - break; - } - case ColorTab.Volume: - { - SelectedColorTabIndex = 3; - break; - } - case ColorTab.Catalog: - { - SelectedColorTabIndex = 4; - break; - } - } - OnSelectedtabChanged(); RaisePropertyChangedAuto(); } + switch (_selectedColorTab) + { + case ColorTab.HSB: + { + SelectedColorTabIndex = 0; + break; + } + case ColorTab.CIELab: + { + SelectedColorTabIndex = 1; + break; + } + case ColorTab.RGB: + { + SelectedColorTabIndex = 2; + break; + } + case ColorTab.Volume: + { + SelectedColorTabIndex = 3; + break; + } + case ColorTab.Catalog: + { + SelectedColorTabIndex = 4; + break; + } + } + } } @@ -203,7 +209,7 @@ namespace Tango.PPC.Jobs.Dialogs } } } - + public double MaxCyanValue { get @@ -242,11 +248,13 @@ namespace Tango.PPC.Jobs.Dialogs public List Catalogs { get { return _catalogs; } - set { + set + { _catalogs = value; - RaisePropertyChangedAuto(); } + RaisePropertyChangedAuto(); + } } - + private ColorCatalog _selectedCatalog; public ColorCatalog SelectedCatalog { @@ -279,13 +287,113 @@ namespace Tango.PPC.Jobs.Dialogs set { _collectionFilter = value; RaisePropertyChangedAuto(); } } - private void OnFilterChanged() + private bool _MyColorsMode; + + public bool MyColorsMode { - if(CollectionFilter != null) - { - CollectionFilter.RaiseFilterChanged(); + get { return _MyColorsMode; } + set + { + _MyColorsMode = value; + OnMyColorModeChanged(); + RaisePropertyChangedAuto(); } } + + private ObservableCollection _libraries; + public ObservableCollection Libraries + { + get { return _libraries; } + set { _libraries = value; RaisePropertyChangedAuto(); } + } + + + private ColorLibrary SelectedColorLibrary { get; set; } + + private FavoriteColor _selectedColor; + + public FavoriteColor SelectedColor + { + get { return _selectedColor; } + set { _selectedColor = value; } + } + + private bool _editColorsGroupMode; + + public bool EditColorsGroupMode + { + get { return _editColorsGroupMode; } + set + { + _editColorsGroupMode = value; + RaisePropertyChangedAuto(); + } + } + + private bool _addGroupMode; + + public bool AddGroupMode + { + get { return _addGroupMode; } + set + { + _addGroupMode = value; + RaisePropertyChangedAuto(); + } + } + + private String _newGroupName; + public String NewGroupName + { + get { return _newGroupName; } + set + { + if (_newGroupName != value) + { + _newGroupName = value; + RaisePropertyChangedAuto(); + } + } + } + + private bool _saveMyColorMode; + /// + /// Gets or sets a value indicating whether open Save my colors control. + /// + public bool SaveMyColorMode + { + get { return _saveMyColorMode; } + set + { + _saveMyColorMode = value; + OnSaveMyColorModeChanged(); + RaisePropertyChangedAuto(); + } + } + + + #endregion + + #region commands + /// + /// Gets or sets the save my colors command. + /// + public RelayCommand SaveMyColorsCommand { get; set; } + public RelayCommand AddNewGroupCommand { get; set; } + public RelayCommand AddNewGroupAndColorCommand { get; set; } + public RelayCommand AddColorToLibraryCommand { get; set; } + + /// + /// Gets or sets the open my colors command. + /// + public RelayCommand OpenMyColorsCommand { get; set; } + public RelayCommand CloseMyColorsCommand { get; set; } + public RelayCommand AddGroupCommand { get; set; } + public RelayCommand DeleteGroupCommand { get; set; } + public RelayCommand SelectColorCommand { get; set; } + public RelayCommand EditColorsLibraryCommand { get; set; } + public RelayCommand DeleteColorCommand { get; set; } + #endregion public ColorSelectionViewVM() @@ -314,29 +422,46 @@ namespace Tango.PPC.Jobs.Dialogs return true; } }); + + SaveMyColorsCommand = new RelayCommand(SaveMyColors); + OpenMyColorsCommand = new RelayCommand(() => { MyColorsMode = true; }); + CloseMyColorsCommand = new RelayCommand(() => { MyColorsMode = false; }); + SelectColorCommand = new RelayCommand(SelectColor); + AddGroupCommand = new RelayCommand(AddGroup); + AddNewGroupCommand = new RelayCommand(AddNewGroup); + AddNewGroupAndColorCommand = new RelayCommand(AddNewGroupAndColor); + AddColorToLibraryCommand = new RelayCommand(AddColorToLibrary); + DeleteGroupCommand = new RelayCommand(DeleteGroup); + EditColorsLibraryCommand = new RelayCommand(EditColorsLibrary); + DeleteColorCommand = new RelayCommand(DeleteColor); + MyColorsMode = false; + EditColorsGroupMode = false; + SaveMyColorMode = false; } + #region Show and Selection tab + public override void OnShow() { Catalogs = DialogEditObject.Catalogs; base.OnShow(); - + SegmentIndex = DialogEditObject.SelectedSegment.SegmentIndex; IsEditMode = DialogEditObject.IsEditingMode; if (DialogEditObject.IsEditingMode) { InitialBrushStop = DialogEditObject.BrushStopForEdit; - + SelectedBrushStop = InitialBrushStop.Clone(); - + SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; - if(SelectedBrushStop.ColorSpace == ColorSpaces.Volume) + if (SelectedBrushStop.ColorSpace == ColorSpaces.Volume) SelectedColorTab = ColorTab.Volume; if (SelectedBrushStop.ColorSpace == ColorSpaces.LAB) { SelectedColorTab = ColorTab.CIELab; - } - else if(SelectedBrushStop.ColorSpace == ColorSpaces.Catalog) + } + else if (SelectedBrushStop.ColorSpace == ColorSpaces.Catalog) { SelectedColorTab = ColorTab.Catalog; if (SelectedBrushStop.ColorCatalogsItem != null) @@ -347,7 +472,7 @@ namespace Tango.PPC.Jobs.Dialogs { SelectedCatalog = Catalogs.FirstOrDefault(); } - } + } else if (SelectedBrushStop.ColorSpace == ColorSpaces.HSB) SelectedColorTab = ColorTab.HSB; else if (SelectedBrushStop.ColorSpace == ColorSpaces.RGB) @@ -365,6 +490,8 @@ namespace Tango.PPC.Jobs.Dialogs OKCommand.RaiseCanExecuteChanged(); SelectedBrushStop.LiquidVolumesOutOfRangeChanged -= OnLiquidVolumesOutOfRangeChanged; SelectedBrushStop.LiquidVolumesOutOfRangeChanged += OnLiquidVolumesOutOfRangeChanged; + + Libraries = MyColorsEngine.Default.GetAll().ToObservableCollection(); } private void OnSelectedtabChanged() @@ -415,7 +542,7 @@ namespace Tango.PPC.Jobs.Dialogs } } - protected void OnColorSelectionItemChanged( object sender, EventArgs args) + protected void OnColorSelectionItemChanged(object sender, EventArgs args) { if (SelectedBrushStop.ColorCatalogsItem != null) { @@ -425,9 +552,20 @@ namespace Tango.PPC.Jobs.Dialogs else SelectedCatalog = Catalogs.FirstOrDefault(); } - + + #endregion + #region Methods + private void OnFilterChanged() + { + if (CollectionFilter != null) + { + CollectionFilter.RaiseFilterChanged(); + } + } + + private double GetMaxCMYKValueOrDefault(LiquidTypes type) { if (SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null && SelectedBrushStop.SegmentModel.Job != null && SelectedBrushStop.SegmentModel.Job.Rml != null) @@ -454,7 +592,7 @@ namespace Tango.PPC.Jobs.Dialogs private void OnLiquidVolumesOutOfRangeChanged(object sender, EventArgs e) { - + OKCommand.RaiseCanExecuteChanged(); } @@ -472,9 +610,154 @@ namespace Tango.PPC.Jobs.Dialogs protected override bool CanOK() { - return SelectedBrushStop!= null && !SelectedBrushStop.LiquidVolumesOutOfRange; + return SelectedBrushStop != null && !SelectedBrushStop.LiquidVolumesOutOfRange; + } + + #endregion + + #region MyColors + + private void SaveMyColors() + { + SaveMyColorMode = !SaveMyColorMode; + } + + private void OnSaveMyColorModeChanged() + { + NewGroupName = ""; + } + private void OnMyColorModeChanged() + { + NewGroupName = ""; + AddGroupMode = false; + } + /// + /// Adds the new group in Save My Colors list. + /// + /// The name of the new Library. + private void AddNewGroup(string name) + { + if (!String.IsNullOrEmpty(name)) + { + Libraries.Add(MyColorsEngine.Default.AddLibrary(name)); + NewGroupName = ""; + } + } + + private void AddNewGroupAndColor(string name) + { + if (!String.IsNullOrEmpty(name)) + { + var library = MyColorsEngine.Default.AddLibrary(name); + Libraries.Add(library); + AddColorToLibrary(library); + } + NewGroupName = ""; + SaveMyColorMode = false; } + /// + /// Adds the selected color to library in Save my Colors. + /// + private void AddColorToLibrary(ColorLibrary obj) + { + FavoriteColor newcolor = new FavoriteColor(); + newcolor.ColorSpace = SelectedBrushStop.ColorSpace; + newcolor.Color = SelectedBrushStop.Color; + newcolor.Red = SelectedBrushStop.Red; + newcolor.Green = SelectedBrushStop.Green; + newcolor.Blue = SelectedBrushStop.Blue; + newcolor.Cyan = SelectedBrushStop.Cyan; + newcolor.Magenta = SelectedBrushStop.Magenta; + newcolor.Yellow = SelectedBrushStop.Yellow; + newcolor.Black = SelectedBrushStop.Black; + newcolor.L = SelectedBrushStop.L; + newcolor.A = SelectedBrushStop.A; + newcolor.B = SelectedBrushStop.B; + newcolor.Hue = SelectedBrushStop.Hue; + newcolor.Saturation = SelectedBrushStop.Saturation; + newcolor.Brightness = SelectedBrushStop.Brightness; + newcolor.RmlGuid = SelectedBrushStop.SegmentModel.Job.Rml.Guid; + newcolor.Name = String.Format("#{0:X2}{1:X2}{2:X2}", newcolor.Red, newcolor.Green, newcolor.Blue); + + obj.AddToLibrary(newcolor); + SaveMyColorMode = false; + } + + private void SelectColor(FavoriteColor favoriteColor) + { + SelectedColor = favoriteColor; + MyColorsMode = false; + + //test RML? + SelectedBrushStop.SetMyColor(favoriteColor); + RaisePropertyChanged(nameof(SelectedBrushStop)); + ColorTab tab = SelectedColorTab; + switch (SelectedBrushStop.ColorSpace) + { + case ColorSpaces.HSB: + SelectedColorTab = ColorTab.HSB; + SelectedBrushStop.OnBrushStopFieldValueChanged(); + break; + case ColorSpaces.Volume: + { + SelectedColorTab = ColorTab.Volume; + if(favoriteColor.RmlGuid != SelectedBrushStop.SegmentModel.Job.Rml.Guid) + NotificationProvider.ShowInfo("The color may be different from the selected."); + } + break; + case ColorSpaces.LAB: + SelectedColorTab = ColorTab.CIELab; + SelectedBrushStop.OnBrushStopFieldValueChanged(); + break; + case ColorSpaces.RGB: + SelectedColorTab = ColorTab.RGB; + SelectedBrushStop.OnBrushStopFieldValueChanged(); + break; + case ColorSpaces.Catalog: + SelectedColorTab = ColorTab.Catalog; + SelectedBrushStop.OnBrushStopFieldValueChanged(); + break; + } + } + + private void AddGroup() + { + AddGroupMode = !AddGroupMode; + } + + private void EditColorsLibrary(ColorLibrary library) + { + if (EditColorsGroupMode) + { + SelectedColorLibrary.EditColorsGroupMode = false; + EditColorsGroupMode = false; + } + else + { + EditColorsGroupMode = true; + SelectedColorLibrary = library; + SelectedColorLibrary.EditColorsGroupMode = true; + } + } + + private void DeleteColor(FavoriteColor favoriteColor) + { + if (favoriteColor != null && SelectedColorLibrary != null) + { + SelectedColorLibrary.RemoveFromLibrary(favoriteColor); + } + } + + private void DeleteGroup() + { + if (SelectedColorLibrary != null) + { + //message + Libraries.Remove(SelectedColorLibrary); + SelectedColorLibrary.Delete(); + } + } #endregion } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png new file mode 100644 index 000000000..afb4b72eb Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/add_group.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png new file mode 100644 index 000000000..a993805ee Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/close_mycolorsdlg.png differ diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.png b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.png new file mode 100644 index 000000000..3b4c00e79 Binary files /dev/null and b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/ColorSelection/delete_color.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 index 2033fac48..8a071f126 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs @@ -668,7 +668,7 @@ namespace Tango.PPC.Jobs.Models } /// - /// Sets the new color. + /// Sets the new color from MyColors. /// public void SetNewColor( BrushStopModel newBrushStop) { @@ -794,6 +794,33 @@ namespace Tango.PPC.Jobs.Models return color; } + public void SetMyColor(FavoriteColor favoriteColor) + { + Color = favoriteColor.Color; + BestMatchColor = favoriteColor.Color; + ColorSpace = favoriteColor.ColorSpace; + // _colorcatalogsitem = favoriteColor.ColorCatalogsItem; + + PreventPropertyUpdate = true; + + Cyan = favoriteColor.Cyan; + Magenta = favoriteColor.Magenta; + Yellow = favoriteColor.Yellow; + Black = favoriteColor.Black; + + Red = favoriteColor.Red; + Green = favoriteColor.Green; + Blue = favoriteColor.Blue; + L = favoriteColor.L; + A = favoriteColor.A; + B = favoriteColor.B; + BestMatchL = favoriteColor.L; + BestMatchA = favoriteColor.A; + BestMatchB = favoriteColor.B; + PreventPropertyUpdate = false; + LiquidVolumesOutOfRange = false; + } + #endregion #region changes diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs new file mode 100644 index 000000000..511a90e15 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ColorLibrary.cs @@ -0,0 +1,83 @@ +using LiteDB; +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.PPC.Jobs.MyColors; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Models +{ + public class ColorLibrary: ExtendedObject + { + private ObservableCollection _colorList; + public ObservableCollection ColorList + { + get { return _colorList; } + set { _colorList = value; } + } + + [BsonId] + public Int32 ID { get; set; } + + private string _name; + public string Name + { + get { return _name; } + set { _name = value; } + } + + private bool _editColorsGroupMode; + [BsonIgnore] + public bool EditColorsGroupMode + { + get { return _editColorsGroupMode; } + set { _editColorsGroupMode = value; RaisePropertyChangedAuto(); } + } + + + public ColorLibrary() + { + _colorList = new ObservableCollection(); + EditColorsGroupMode = false; + } + + public void Loading() + { + //loading form database + } + + public void AddToLibrary(FavoriteColor color) + { + ColorList.Add(color); + RaisePropertyChanged(nameof(ColorList)); + + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.UpdateLibrary(this); + }); + } + + public void RemoveFromLibrary(FavoriteColor color) + { + ColorList.Remove(color); + RaisePropertyChanged(nameof(ColorList)); + + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.UpdateLibrary(this); + }); + } + + public void Delete() + { + Task.Factory.StartNew(() => + { + MyColorsEngine.Default.Delete(this); + }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs new file mode 100644 index 000000000..43d41539e --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/FavoriteColor.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.BL.Enumerations; +using Tango.SharedUI; +using System.Windows; +using ColorMine.ColorSpaces; +using Tango.Core; +using LiteDB; + +namespace Tango.PPC.Jobs.Models +{ + public class FavoriteColor : ExtendedObject + { + + #region Properties + + [BsonId] + public Int32 ID { get; set; } + + private string _name; + + public string Name + { + get { return _name; } + set + { + _name = value; + RaisePropertyChangedAuto(); + } + } + + public String RmlGuid { get; set; } + + public ColorSpaces ColorSpace { get; set; } + + public Double Cyan { get; set; } + + public Double Magenta { get; set; } + + public Double Yellow { get; set; } + + public Double Black { get; set; } + + public Int32 Red { get; set; } + + public Int32 Green { get; set; } + + public Int32 Blue { get; set; } + + public Double L { get; set; } + + public Double A { get; set; } + + public Double B { get; set; } + + public double Hue { get; set; } + + public double Saturation { get; set; } + + public double Brightness { get; set; } + + public int BestMatchR { get; set; } + + public int BestMatchG { get; set; } + + public int BestMatchB { get; set; } + + [BsonIgnore] + public Color Color + { + get + { + return Color.FromRgb((byte)BestMatchR, (byte)BestMatchG, (byte)BestMatchB); + } + set + { + BestMatchR = value.R; + BestMatchG = value.G; + BestMatchB = value.B; + RaisePropertyChangedAuto(); + } + } + + [BsonIgnore] + public SolidColorBrush Brush + { + get { return new SolidColorBrush(Color); } + } + + #endregion + + public FavoriteColor() + { + Hue = Saturation = 0; + Brightness = 100; + L = 100; + A = B = 0; + + Red = Green = Blue = 255; + Cyan = Magenta = Yellow = Black = 0; + Color = Colors.White; + ColorSpace = ColorSpaces.Volume; + } + } +} 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 index 0106d82c4..bc6997120 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/JobModel.cs @@ -11,7 +11,7 @@ using Tango.SharedUI; namespace Tango.PPC.Jobs.Models { - public class JobModel : ViewModel + public class JobModel : ExtendedObject { private bool _preventChange; 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 index 3b4644a8d..b65d7e156 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentModel.cs @@ -18,7 +18,7 @@ using Tango.PPC.Jobs.UndoRedoCommands; namespace Tango.PPC.Jobs.Models { - public class SegmentModel : ViewModel + public class SegmentModel : ExtendedObject { private double _lastLength; private LinearGradientBrush _brush; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs new file mode 100644 index 000000000..27dabc2e7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/MyColors/MyColorsEngine.cs @@ -0,0 +1,76 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.MyColors +{ + public class MyColorsEngine : IDisposable + { + private LiteDatabase _db; + private ILiteCollection _collection; + + private static Lazy _default = new Lazy(() => new MyColorsEngine()); + + public static MyColorsEngine Default + { + get + { + return _default.Value; + } + } + + private MyColorsEngine() + { + Init(); + } + + private void Init() + { + String dbFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Color Library"); + Directory.CreateDirectory(dbFolder); + _db = new LiteDatabase($"Filename={Path.Combine(dbFolder, "color_library.db")}"); + _collection = _db.GetCollection("Libraries"); + } + + public void UpdateLibrary(ColorLibrary library) + { + _collection.Update(library); + } + + public ColorLibrary AddLibrary(String name) + { + ColorLibrary library = new ColorLibrary() { Name = name }; + _collection.Insert(library); + return library; + } + + public List GetAll() + { + return _collection.FindAll().ToList(); + } + + ~MyColorsEngine() + { + Dispose(); + } + + public void Dispose() + { + try + { + _db?.Dispose(); + } + catch { } + } + + public void Delete(ColorLibrary library) + { + _collection.Delete(library.ID); + } + } +} 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 a38818ffb..8d90aabb2 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 @@ -43,10 +43,14 @@ ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll + + ..\..\..\packages\LiteDB.5.0.4\lib\net45\LiteDB.dll + + ..\..\..\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll @@ -262,8 +266,11 @@ + + + @@ -624,6 +631,15 @@ + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config index 4cf1b4859..7631e246f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/packages.config @@ -4,4 +4,5 @@ + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs index 9b865c18b..3af921f7d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogRenderer.cs @@ -52,7 +52,7 @@ namespace Tango.PPC.Common.Controls private double groupMargin = 50; private bool selectedFromClick; private LightTouchScrollViewer _scrollViewer; - private BitmapSource _myColorBitmap; + // private BitmapSource _myColorBitmap; private double imageWidth = 24; private double imageHeight = 22; private Point _lastMouseClickPoint; @@ -100,7 +100,7 @@ namespace Tango.PPC.Common.Controls this.PreviewMouseUp += TwineCatalogRenderer_MouseLeftButtonUp; this.Loaded += TwineCatalogRenderer_Loaded; - _myColorBitmap = new BitmapImage(new Uri($"pack://application:,,,/Tango.PPC.JobsV2;component/Images/ColorSelection/Heart.png", UriKind.Absolute)); + // _myColorBitmap = new BitmapImage(new Uri($"pack://application:,,,/Tango.PPC.JobsV2;component/Images/ColorSelection/Heart.png", UriKind.Absolute)); } private void TwineCatalogRenderer_Loaded(object sender, RoutedEventArgs e) @@ -292,7 +292,7 @@ namespace Tango.PPC.Common.Controls DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); - drawingContext.DrawImage(_myColorBitmap, imageRect); + // drawingContext.DrawImage(_myColorBitmap, imageRect); drawingContext.DrawEllipse(new SolidColorBrush(item.Color), null, new Point(x + ellipseWidth / 2, y + ellipseHeight / 2), ellipseWidth / 2, ellipseHeight / 2); 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 bb0a694cf..780941f66 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -19,6 +19,7 @@ + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index bb1890e7f..432f2b58b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -58,10 +58,32 @@ - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index ae5ac91e3..58eb68e45 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -155,6 +155,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -488,7 +492,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index c2c6c0bc9..0a9ce1282 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -62,7 +62,8 @@ - + + -- cgit v1.3.1