From 20f49c625cd32b95154db138ed7eeebbadd04bf7 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Mon, 1 Nov 2021 14:53:16 +0200 Subject: Color selection and Job sequence package. Redesign list control, move Color Selection View to dialogs, implement save. --- .../Converters/ColorTabToVisibilityConverter.cs | 2 +- .../Dialogs/ColorSelectionView.xaml | 311 +++++++++++ .../Dialogs/ColorSelectionView.xaml.cs | 54 ++ .../Dialogs/ColorSelectionViewVM.cs | 340 ++++++++++++ .../Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml | 161 +++--- .../Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs | 41 +- .../Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml | 32 ++ .../Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs | 28 + .../Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs | 39 ++ .../Images/JobView/job_details.png | Bin 406 -> 489 bytes .../Tango.PPC.JobsV2/Models/BrushStopModel.cs | 207 +++---- .../Modules/Tango.PPC.JobsV2/Models/JobModel.cs | 32 +- .../Tango.PPC.JobsV2/Models/SegmentModel.cs | 142 ++--- .../ColorSelectionNavigationObject.cs | 20 - .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 27 +- .../Modules/Tango.PPC.JobsV2/ViewModelLocator.cs | 7 +- .../ViewModels/ColorSelectionToolViewVM.cs | 285 ---------- .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 616 ++++++++------------- .../Tango.PPC.JobsV2/ViewModels/JobsViewVM.cs | 5 +- .../Views/ColorSelectionToolView.xaml | 324 ----------- .../Views/ColorSelectionToolView.xaml.cs | 61 -- .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml | 89 +-- .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml.cs | 31 +- .../Modules/Tango.PPC.JobsV2/Views/MainView.xaml | 1 - .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 4 + .../PPC/Tango.PPC.Common/Resources/Styles.xaml | 8 +- 26 files changed, 1425 insertions(+), 1442 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs (limited to 'Software/Visual_Studio/PPC') 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 index 9189d6172..6f9a95ccf 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Converters/ColorTabToVisibilityConverter.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; -using static Tango.PPC.Jobs.ViewModels.ColorSelectionToolViewVM; +using static Tango.PPC.Jobs.Dialogs.ColorSelectionViewVM; namespace Tango.PPC.Jobs.Converters { 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 new file mode 100644 index 000000000..a095ff7aa --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + My Colors + + + + + + + + + + + + + + Job Palette + + + + + CANCEL + CONFIRM + + + + + + + + + + + + + + + + + + Color Selection Tool + + + + + + + + + HSB + CIELab + RGB + CMYK + Catalogs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs new file mode 100644 index 000000000..550390f44 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionView.xaml.cs @@ -0,0 +1,54 @@ +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.ViewModels; + +namespace Tango.PPC.Jobs.Dialogs +{ + /// + /// Interaction logic for ColorSelectionView.xaml + /// + public partial class ColorSelectionView : UserControl + { + private ColorSelectionViewVM _vm; + + public ColorSelectionView() + { + InitializeComponent(); + + Loaded += (_, __) => + { + _vm = DataContext as ColorSelectionViewVM; + }; + } + + + private void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + + } + + private void TouchNavigationLinks_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + { + if (_vm != null && _vm.SelectedBrushStop != null && true == _vm.SelectedBrushStop.IsLiquidVolumesOutOfRange) + { + var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem; + if (item != null) + { + e.Handled = true; + } + } + } + } +} 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 new file mode 100644 index 000000000..83128a374 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/ColorSelectionViewVM.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; +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; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class ColorSelectionViewVM : DialogViewVM + { + public enum ColorTab + { + [Description("HSB")] + HSB = 5, + [Description("CIELab")] + CIELab = 3, + [Description("RGB")] + RGB = 1, + [Description("CMYK")] + Volume = 0, + [Description("Catalog")] + Catalog = 2 + } + + public class DialogObject + { + public SegmentModel SelectedSegment { get; set; } + public BrushStopModel BrushStopForEdit { get; set; } + /// + /// True when first brush is open for editing + /// + public bool IsEditingMode { get; set; } + } + + + private ActionTimer _volumeConversionTimer; + private IColorConverter _converter; + + + #region Properties + + private bool _isEditMode; + + public bool IsEditMode + { + get { return _isEditMode; } + set + { + _isEditMode = value; + RaisePropertyChangedAuto(); + } + } + + private int _selectedColorTabIndex; + /// + /// Gets or sets the index of the selected category. + /// + public int SelectedColorTabIndex + { + get { return _selectedColorTabIndex; } + set + { + if(_selectedColorTabIndex != value) + { + _selectedColorTabIndex = value; + RaisePropertyChangedAuto(); + switch (_selectedColorTabIndex) + { + case 0: + { + SelectedColorTab = ColorTab.HSB; + break; + } + case 1: + { + SelectedColorTab = ColorTab.CIELab; + break; + } + case 2: + { + SelectedColorTab = ColorTab.RGB; + break; + } + case 3: + { + SelectedColorTab = ColorTab.Volume; + break; + } + case 4: + { + SelectedColorTab = ColorTab.Catalog; + break; + } + } + } + } + } + + private ColorTab _selectedColorTab; + /// + /// Gets or sets the selected category. + /// + /// + public ColorTab SelectedColorTab + { + get { + return _selectedColorTab; + } + set + { + 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(); + } + } + } + + private int _segmentIndex; + + public int SegmentIndex + { + get { return _segmentIndex; } + set + { + _segmentIndex = value; + RaisePropertyChangedAuto(); + } + } + + + private BrushStopModel _initialBrushStop; + /// + /// Gets or sets the initial brush stop. + /// + public BrushStopModel InitialBrushStop + { + get { return _initialBrushStop; } + set + { + _initialBrushStop = value; + RaisePropertyChangedAuto(); + } + } + + private BrushStopModel _selectedBrushStop; + /// + /// Gets or sets the edited brush stop. + /// + public BrushStopModel SelectedBrushStop + { + get { return _selectedBrushStop; } + set + { + _selectedBrushStop = value; + RaisePropertyChangedAuto(); + } + } + + public double MaxCyanValue + { + get + { + return GetMaxCMYKValueOrDefault(LiquidTypes.Cyan); + } + } + + public double MaxMagentaValue + { + get + { + return GetMaxCMYKValueOrDefault(LiquidTypes.Magenta); + } + } + + public double MaxYellowValue + { + get + { + return GetMaxCMYKValueOrDefault(LiquidTypes.Yellow); + } + } + + public double MaxBlackValue + { + get + { + return GetMaxCMYKValueOrDefault(LiquidTypes.Black); + } + } + + public DialogObject DialogEditObject { get; set; } + + #endregion + + public ColorSelectionViewVM() + { + SelectedColorTab = ColorTab.RGB; + _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); + _converter = new DefaultColorConverter(); + } + + public override void OnShow() + { + base.OnShow(); + + SegmentIndex = DialogEditObject.SelectedSegment.SegmentIndex; + IsEditMode = DialogEditObject.IsEditingMode; + if (DialogEditObject.IsEditingMode) + { + InitialBrushStop = DialogEditObject.BrushStopForEdit; + SelectedBrushStop = InitialBrushStop.Clone(); + SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; + + SelectedColorTab = (ColorTab)SelectedBrushStop.ColorSpace; + } + else + { + SelectedBrushStop = DialogEditObject.BrushStopForEdit; + SelectedColorTab = ColorTab.RGB; + } + UpdateVolumesMaxValues(); + } + + private void OnSelectedtabChanged() + { + switch (SelectedColorTab) + { + case ColorTab.HSB: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.ConvertColorToHSB(); + } + + return; + } + case ColorTab.RGB: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.ConvertColorToRGB(); + } + return; + } + case ColorTab.CIELab: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.ConvertColorToLAB(); + } + return; + } + case ColorTab.Volume: + { + if (SelectedBrushStop != null) + { + SelectedBrushStop.ConvertColorToVolume(); + } + return; + } + } + } + + #region Methods + + private double GetMaxCMYKValueOrDefault(LiquidTypes type) + { + if (SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null && SelectedBrushStop.SegmentModel.Job != null && SelectedBrushStop.SegmentModel.Job.Rml != null) + { + var liquidTypesRml = SelectedBrushStop.SegmentModel.Job.Rml.LiquidTypesRmls.FirstOrDefault(x => x.LiquidType.Type == type); + if (liquidTypesRml != null) + { + //var test = liquidTypesRml.GetMaxCalibrationValue(); + + return liquidTypesRml.GetMaxCalibrationValue(); + } + + } + return 100; + } + + private void UpdateVolumesMaxValues() + { + RaisePropertyChanged(nameof(MaxCyanValue)); + RaisePropertyChanged(nameof(MaxMagentaValue)); + RaisePropertyChanged(nameof(MaxYellowValue)); + RaisePropertyChanged(nameof(MaxBlackValue)); + } + + protected override void Accept() + { + base.Accept(); + } + + #endregion + + } +} 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 index 250e3959d..69bbbdb05 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationView.xaml @@ -9,7 +9,7 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" mc:Ignorable="d" - Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="662" Height="861" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}"> + Background="{StaticResource TangoPrimaryBackgroundBrush}" d:DesignHeight="861" d:DesignWidth="662" Width="750" Height="1200" d:DataContext="{d:DesignInstance Type=local:JobCreationViewVM, IsDesignTimeCreatable=False}"> @@ -20,96 +20,85 @@ - - CANCEL - OK - + + CANCEL + OK + + - - - Job Details - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + Job Details - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + Duplicate + + + 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 index f571cd519..66be7bd04 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/JobCreationViewVM.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; using Tango.BL.Enumerations; +using Tango.Core.Commands; using Tango.SharedUI; namespace Tango.PPC.Jobs.Dialogs @@ -67,17 +68,51 @@ namespace Tango.PPC.Jobs.Dialogs set { _selectedSpoolType = value; RaisePropertyChangedAuto(); } } - + + private double _whiteGap; + + public double WhiteGap + { + get { return _whiteGap; } + set { _whiteGap = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _showDuplicate; + + public bool ShowDuplicate + { + get { return _showDuplicate; } + set { _showDuplicate = value; + RaisePropertyChangedAuto(); + + } + } + + public bool IsDuplicate { get; set; } + public RelayCommand DuplicateCommand { get; set; } /// /// Initializes a new instance of the class. /// /// The supported job types. /// The supported color spaces - public JobCreationViewVM(List spoolTypes, List rmls) : base() + public JobCreationViewVM(List spoolTypes, List rmls, double whitegap, bool showDuplicate) : base() { JobName = "Unnamed"; SpoolTypes = spoolTypes; - Rmls = rmls.OrderBy(x => x.Name).ToList(); + Rmls = rmls.OrderBy(x => x.Name).ToList(); + DuplicateCommand = new RelayCommand(Duplicate); + IsDuplicate = false; + ShowDuplicate = showDuplicate; + WhiteGap = whitegap; + } + + private void Duplicate(object obj) + { + IsDuplicate = true; + Accept(); } protected override bool CanOK() diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml new file mode 100644 index 000000000..90c5b8b9f --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml @@ -0,0 +1,32 @@ + + + + + + + Copy Job Summary + + + + + + Repeat: + + Units + + + + + OK + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml.cs new file mode 100644 index 000000000..dff1ced26 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.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 RepeatJob.xaml + /// + public partial class RepeatJobView : UserControl + { + public RepeatJobView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs new file mode 100644 index 000000000..4cf5d8c95 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.PPC.Jobs.Dialogs +{ + public class RepeatJobViewVM : DialogViewVM + { + private int _repeats; + + public int Repeats + { + get { return _repeats; } + set { _repeats = value; + RaisePropertyChangedAuto(); + } + } + + private int _maxrepeations; + + public int MaxRepeations + { + get { + return _maxrepeations; } + set { _maxrepeations = value; + RaisePropertyChangedAuto(); + } + } + + + public RepeatJobViewVM() + { + Repeats = 1; + } + } +} 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 index 1ccee4475..fa5a1f81f 100644 Binary files a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Images/JobView/job_details.png 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/Models/BrushStopModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/BrushStopModel.cs index 78ce8f1a7..3447cec8e 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 @@ -13,11 +13,21 @@ using Tango.ColorConversion; using System.Reflection; using Tango.BL.Dispensing; using Tango.BL; +using Tango.Core.ExtensionMethods; namespace Tango.PPC.Jobs.Models { public class BrushStopModel : ViewModel { + public enum PositionStatus + { + First = 1, + FirstColor = 2, + Middle = 3, + SecondColor = 4, + Last = 5 + } + private ActionTimer _volumeConversionTimer; private IColorConverter _converter; public const double MAX_INK_UPTAKE = 400; @@ -45,7 +55,7 @@ namespace Tango.PPC.Jobs.Models { _cyan = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -69,7 +79,7 @@ namespace Tango.PPC.Jobs.Models { _magenta = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -93,7 +103,7 @@ namespace Tango.PPC.Jobs.Models { _yellow = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -116,7 +126,7 @@ namespace Tango.PPC.Jobs.Models { _black = value; RaisePropertyChangedAuto(); - OnCMYKChanged(); + OnVolumeChanged(); } } } @@ -306,29 +316,6 @@ namespace Tango.PPC.Jobs.Models } } - - 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; /// @@ -399,37 +386,14 @@ namespace Tango.PPC.Jobs.Models } } - 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; + private PositionStatus _position; - public bool IsSecondColorBrush + public PositionStatus Position { - get { return _isSecondColorBrush; } - set { _isSecondColorBrush = value; } + get { return _position; } + set { _position = value; } } - + protected ColorSpaces _colorspace; public virtual ColorSpaces ColorSpace @@ -514,24 +478,7 @@ namespace Tango.PPC.Jobs.Models 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(); - } - } + private bool _outOfGamutChecked; /// @@ -556,11 +503,6 @@ namespace Tango.PPC.Jobs.Models { _isOutOfGamut = value; RaisePropertyChangedAuto(); - - //if (SegmentModel != null) - //{ - // Segment.RaiseHasOutOfGamutBrushStop(); - //} } } } @@ -576,7 +518,8 @@ namespace Tango.PPC.Jobs.Models _b = 0; _red = _green = _blue = 255; _cyan = _magenta = _yellow = _black = 0; - IsMiddle = IsFirstColorBrush = IsSecondColorBrush = false; + StopIndex = 1; + Position = PositionStatus.FirstColor; SegmentModel = segmentModel; IsOutOfGamut = false; _volumeConversionTimer = new ActionTimer(TimeSpan.FromMilliseconds(50)); @@ -686,17 +629,33 @@ namespace Tango.PPC.Jobs.Models public BrushStopModel Clone() { - var cloned = (BrushStopModel)Activator.CreateInstance(typeof(BrushStopModel), SegmentModel); + var cloned = new BrushStopModel(SegmentModel); + cloned.StopIndex = StopIndex; cloned.PreventPropertyUpdate = true; - - 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; + cloned.Red = Red; + cloned.Green = Green; + cloned.Blue = Blue; + cloned.L = L; + cloned.A = A; + cloned.B = B; + cloned.Cyan = Cyan; + cloned.Magenta = Magenta; + cloned.Yellow = Yellow; + cloned.Black = Black; + cloned.Hue = Hue; + cloned.Saturation = Saturation; + cloned.Brightness = Brightness; + cloned.Color = Color; + + cloned.ColorCatalogsItem = ColorCatalogsItem; + cloned.ColorSpace = ColorSpace; + cloned.DisplayedColor = DisplayedColor; + cloned.OffsetMeters = OffsetMeters; + cloned.OffsetPercent = OffsetPercent; + cloned.Position = Position; + cloned.IsOutOfGamut = IsOutOfGamut; + cloned.OutOfGamutChecked = OutOfGamutChecked; + //this.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes); cloned.PreventPropertyUpdate = false; return cloned; } @@ -719,12 +678,12 @@ namespace Tango.PPC.Jobs.Models #region changes - private void OnCMYKChanged() + private void OnVolumeChanged() { if (PreventPropertyUpdate) return; - ColorSpace = ColorSpaces.CMYK; - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); + ColorSpace = ColorSpaces.Volume; + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); OnBrushStopFieldValueChanged(); } @@ -796,7 +755,7 @@ namespace Tango.PPC.Jobs.Models { Hsb hsb = null; - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -806,7 +765,7 @@ namespace Tango.PPC.Jobs.Models _red = output.SingleCoordinates.Red; _green = output.SingleCoordinates.Green; _blue = output.SingleCoordinates.Blue; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { @@ -845,7 +804,7 @@ namespace Tango.PPC.Jobs.Models { if (ColorSpace != ColorSpaces.RGB) { - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -855,7 +814,7 @@ namespace Tango.PPC.Jobs.Models _red = output.SingleCoordinates.Red; _green = output.SingleCoordinates.Green; _blue = output.SingleCoordinates.Blue; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { @@ -885,7 +844,7 @@ namespace Tango.PPC.Jobs.Models if (ColorSpace != ColorSpaces.LAB) { Lab lab = null; - if (ColorSpace == ColorSpaces.CMYK) + if (ColorSpace == ColorSpaces.Volume) { BrushStop stop = CreateBrushStop(ColorSpaces.Volume); try @@ -895,11 +854,11 @@ namespace Tango.PPC.Jobs.Models _l = output.SingleCoordinates.L; _a = output.SingleCoordinates.A; _b = output.SingleCoordinates.B; - IsOutOfGamut = _converter.IsOutOfGamut(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml); + IsOutOfGamut = output.OutOfGamut; } catch (Exception ex) { - LogManager.Log(ex, "An error occurred while trying to get volume => RGB from conversion engine."); + LogManager.Log(ex, "An error occurred while trying to convert volume to LAB."); } finally { @@ -929,9 +888,9 @@ namespace Tango.PPC.Jobs.Models } } - public void ConvertColorToCMYK() + public void ConvertColorToVolume() { - if (ColorSpace != ColorSpaces.CMYK) + if (ColorSpace != ColorSpaces.Volume) { ColorSpaces colorSpace = ColorSpace; if (ColorSpace == ColorSpaces.HSB) @@ -944,16 +903,16 @@ namespace Tango.PPC.Jobs.Models IsBusy = true; var output = _converter.Convert(stop, SegmentModel.Job.Machine.Configuration, SegmentModel.Job.Rml, false, false, false); - _cyan = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume; - _yellow = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume; - _magenta = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume; - _black = output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume; + _cyan = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Cyan).Volume) ; + _yellow = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Yellow).Volume); + _magenta = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Magenta).Volume); + _black = (output.SingleCoordinates.OutputLiquids.SingleOrDefault(x => x.LiquidType == PMR.ColorLab.LiquidType.Black).Volume); IsOutOfGamut = false; RaisePropertyChanged(nameof(Cyan)); RaisePropertyChanged(nameof(Yellow)); RaisePropertyChanged(nameof(Magenta)); RaisePropertyChanged(nameof(Black)); - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); } catch (Exception ex) { @@ -1010,11 +969,11 @@ namespace Tango.PPC.Jobs.Models } return 0.0; } - public bool IsCMYKLiquidVolumesOutOfRange + public bool IsLiquidVolumesOutOfRange { get { - if (ColorSpace == BL.Enumerations.ColorSpaces.CMYK) + if (ColorSpace == BL.Enumerations.ColorSpaces.Volume) { var sum = GetColorNLPerCm(Cyan, LiquidTypes.Cyan) + GetColorNLPerCm(Magenta, LiquidTypes.Magenta) + GetColorNLPerCm(Yellow, LiquidTypes.Yellow) + GetColorNLPerCm(Black, LiquidTypes.Black); var maxLiq = GetTotalMaximumLiquidNlPerCMLimit(); @@ -1036,23 +995,16 @@ namespace Tango.PPC.Jobs.Models try { ColorSpaces colorSpace = ColorSpace; - if(ColorSpace == ColorSpaces.HSB) - { - colorSpace = ColorSpaces.RGB; - } - if (ColorSpace == ColorSpaces.CMYK) - { - colorSpace = ColorSpaces.Volume; - } + BrushStop stop = CreateBrushStop(colorSpace); Configuration configuration = SegmentModel.Job.Machine.Configuration; Rml rml = SegmentModel.Job.Rml; - RaisePropertyChanged(nameof(IsCMYKLiquidVolumesOutOfRange)); - if ( ColorSpace == BL.Enumerations.ColorSpaces.CMYK) + RaisePropertyChanged(nameof(IsLiquidVolumesOutOfRange)); + if ( ColorSpace == BL.Enumerations.ColorSpaces.Volume) { - if(IsCMYKLiquidVolumesOutOfRange) + if(IsLiquidVolumesOutOfRange) { IsBusy = false; return; @@ -1079,14 +1031,27 @@ namespace Tango.PPC.Jobs.Models Rgb rgb = new Rgb(lab.ToRgb()); DisplayedColor = Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); //TODO ASK ROY - // DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); + //foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) + //{ + // var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + + // if (liquidVolume == null) + // { + // throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); + // } + // liquidVolume.Volume = outputLiquid.Volume; + //} } else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.RGB) { IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); - + } + else if (stop.BrushColorSpace == BL.Enumerations.ColorSpaces.HSB) + { + IsOutOfGamut = _converter.IsOutOfGamut(stop, configuration, rml); + DisplayedColor = Color.FromRgb((byte)output.SingleCoordinates.Red, (byte)output.SingleCoordinates.Green, (byte)output.SingleCoordinates.Blue); } } catch (Exception ex) 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 349b9049b..3bb6188d9 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 @@ -118,6 +118,7 @@ namespace Tango.PPC.Jobs.Models { _numberofunits = value; RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(LengthIncludingNumberOfUnits)); } } @@ -489,6 +490,11 @@ namespace Tango.PPC.Jobs.Models { RaisePropertyChanged(nameof(EffectiveSegments)); } + else if(e.PropertyName == nameof(SegmentModel.EnableInterSegment)) + { + OnLengthChanged(); + RaisePropertyChanged(nameof(EffectiveSegments)); + } else if(e.PropertyName == nameof(SegmentModel.IsSelected)) { if (_preventChange) return; @@ -532,6 +538,7 @@ namespace Tango.PPC.Jobs.Models public void CopySegments() { + SegmentsToCopy.Clear(); if (false == Segments.ToList().Any(x => x.IsSelected)) return; LogManager.Log("Copy selected segments."); @@ -552,14 +559,20 @@ namespace Tango.PPC.Jobs.Models } SegmentsToCopy.ForEach(x => x.RaiseSegmentBrushChanged()); - var selected = Segments.ToList().FindIndex(x => x.IsSelected); - if(selected != -1) + var selectedIndex = Segments.ToList().FindIndex(x => x.IsSelected); + if(selectedIndex == -1 || selectedIndex == (Segments.Count) - 1) { - Segments.ToList().InsertRange(selected, SegmentsToCopy); + foreach ( var newSegmentModel in SegmentsToCopy) + { + Segments.Add(newSegmentModel); + } } else { - Segments.ToList().AddRange(SegmentsToCopy); + foreach (var newSegmentModel in SegmentsToCopy) + { + Segments.Insert(selectedIndex++, newSegmentModel); + } } SegmentsToCopy.Clear(); } @@ -573,6 +586,17 @@ namespace Tango.PPC.Jobs.Models Segments.Where(i => i.IsSelected).ToList().ForEach(y => y.EnableInterSegment = true); } + public void SwapSegments(int index1, int index2) + { + if (index1 < 0 || index1 >= Segments.Count) + return; + if (index2 < 0 || index2 >= Segments.Count) + return; + var tmpIndex = Segments[index2].SegmentIndex; + Segments[index2].SegmentIndex = Segments[index1].SegmentIndex; + Segments[index1].SegmentIndex = tmpIndex; + } + #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 index c7edecd41..a03c56a46 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 @@ -24,9 +24,10 @@ namespace Tango.PPC.Jobs.Models private ActionTimer _brushStopCollectionChangedActionTimer; #region Properties - - protected String _name; + public string GUID { get; set; } + + protected String _name; /// /// Gets or sets the SegmentModel name. /// @@ -108,7 +109,6 @@ namespace Tango.PPC.Jobs.Models _enableintersegment = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(LengthWithInterSegment)); - Job.OnLengthChanged(); } } } @@ -178,54 +178,51 @@ namespace Tango.PPC.Jobs.Models } public bool IsOffsetChanged { get; set; } - - private double _leftOffset; - + public double LeftOffset { - get { return _leftOffset; } - set { _leftOffset = value; - RaisePropertyChangedAuto(); - if (FirstBrushStop != null) + get { return FirstBrushStop != null? FirstBrushStop.OffsetPercent : 0; } + set { + + if (FirstBrushStop != null && FirstBrushStop.OffsetPercent != value) { - FirstBrushStop.OffsetPercent = _leftOffset/2; + FirstBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } } - private double _middleOffset; - + public double MiddleOffset { - get { return _middleOffset; } - set { _middleOffset = value; - RaisePropertyChangedAuto(); - if (MiddleBrushStop != null) + get { return (MiddleBrushStop != null) ? MiddleBrushStop.OffsetPercent : 0; } + set { + + if (MiddleBrushStop != null && MiddleBrushStop.OffsetPercent != value) { - MiddleBrushStop.OffsetPercent = _middleOffset; - + MiddleBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } } - - private double _rightOffset; - + public double RightOffset { - get { return _rightOffset; } - set { _rightOffset = value; - RaisePropertyChangedAuto(); - if (SecondBrushStop != null) + get { return SecondBrushStop != null ? SecondBrushStop.OffsetPercent: 0; } + set { + + if (SecondBrushStop != null && SecondBrushStop.OffsetPercent != value) { - SecondBrushStop.OffsetPercent = _rightOffset; + SecondBrushStop.OffsetPercent = value; + RaisePropertyChangedAuto(); IsOffsetChanged = true; - RaiseSegmentBrushChanged(); + RaisePropertyChanged(nameof(SegmentBrush)); IsOffsetChanged = false; } } @@ -255,7 +252,7 @@ namespace Tango.PPC.Jobs.Models get { if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsSecondColorBrush).FirstOrDefault(); + return BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.SecondColor).FirstOrDefault(); return null; } @@ -268,11 +265,12 @@ namespace Tango.PPC.Jobs.Models { get { - if (BrushStops.Count == 1) - return BrushStops[0]; - if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsFirstColorBrush).FirstOrDefault(); - + if(BrushStops.Count > 0) + { + var brushStop = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.FirstColor).FirstOrDefault(); + return brushStop; + } + return null; } @@ -286,7 +284,7 @@ namespace Tango.PPC.Jobs.Models get { if (BrushStops.Count > 1) - return BrushStops.Where(x => x.IsMiddle).FirstOrDefault(); + return BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.Middle).FirstOrDefault(); return null; } @@ -321,14 +319,16 @@ namespace Tango.PPC.Jobs.Models public RelayCommand DeleteGapCommand { get; set; } #endregion - public SegmentModel(JobModel jobModel) + public SegmentModel(JobModel jobModel, string guid) { InitnewSegment(); Job = jobModel; + GUID = guid; } public SegmentModel() { + GUID = ""; InitnewSegment(); } @@ -356,14 +356,12 @@ namespace Tango.PPC.Jobs.Models if (_brush == null || _brush.GradientStops.Count != BrushStops.Count || IsOffsetChanged) { GradientStopCollection stops = new GradientStopCollection(); - - foreach (var stop in BrushStops.ToList().OrderBy(x => x.StopIndex).ToList()) { //TODO test if displayed is valid stop.IsValid Color color = stop.DisplayedColor; - stops.Add(new GradientStop(stop.IsTransparent ? Colors.Transparent : color, stop.OffsetPercent / 100d)); + stops.Add(new GradientStop( color, stop.OffsetPercent / 100d)); } LinearGradientBrush brush = new LinearGradientBrush(); @@ -381,7 +379,7 @@ namespace Tango.PPC.Jobs.Models { //TODO test if displayed is valid stop.IsValid Color color = BrushStops[i].DisplayedColor; - _brush.GradientStops[i].Color = BrushStops[i].IsTransparent ? Colors.Transparent : color; + _brush.GradientStops[i].Color = color; _brush.GradientStops[i].Offset = BrushStops[i].OffsetPercent / 100d; } @@ -391,17 +389,19 @@ namespace Tango.PPC.Jobs.Models 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)); - } - } + var cloned = new SegmentModel(Job, GUID);//(SegmentModel)Activator.CreateInstance(typeof(SegmentModel), this.Job); + + cloned.Name = Name; + cloned.LeftOffset = LeftOffset; + cloned.MiddleOffset = MiddleOffset; + cloned.RightOffset = RightOffset; + cloned.IsOffsetChanged = IsOffsetChanged; + cloned.Length = Length; + cloned.IsSelected = false; + cloned.IsInterSegment = IsInterSegment; + cloned.EnableInterSegment = EnableInterSegment; cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToSynchronizedObservableCollection(); - cloned.Job = Job; + cloned.SegmentIndex = SegmentIndex + 1; return cloned; @@ -427,30 +427,18 @@ namespace Tango.PPC.Jobs.Models BrushStopModel brushStop = firstBrush.Clone(); brushStop.StopIndex = 1; brushStop.OffsetPercent = 0; - brushStop.IsFirst = true; - brushStop.IsFirstColorBrush = false; - brushStop.IsMiddle = false; - brushStop.IsSecondColorBrush = false; - brushStop.IsLast = false; + brushStop.Position = BrushStopModel.PositionStatus.First; BrushStops.Add(brushStop); BrushStopModel colorbrushStop = firstBrush.Clone(); - colorbrushStop.IsFirstColorBrush = true; - colorbrushStop.IsFirst = false; - colorbrushStop.IsMiddle = false; - colorbrushStop.IsSecondColorBrush = false; - colorbrushStop.IsLast = false; + colorbrushStop.Position = BrushStopModel.PositionStatus.FirstColor; colorbrushStop.StopIndex = 2; colorbrushStop.OffsetPercent = 0; BrushStops.Add(colorbrushStop); BrushStopModel middleBrushStop = firstBrush.Clone(); middleBrushStop.StopIndex = 3; - middleBrushStop.IsMiddle = true; - middleBrushStop.IsFirst = false; - middleBrushStop.IsFirstColorBrush = false; - middleBrushStop.IsSecondColorBrush = false; - middleBrushStop.IsLast = false; + middleBrushStop.Position = BrushStopModel.PositionStatus.Middle; 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); @@ -465,22 +453,14 @@ namespace Tango.PPC.Jobs.Models BrushStopModel secondbrushStop = secondBrush.Clone(); secondbrushStop.StopIndex = 4; - secondbrushStop.IsSecondColorBrush = true; - secondbrushStop.IsFirst = false; - secondbrushStop.IsFirstColorBrush = false; - secondbrushStop.IsMiddle = false; - secondbrushStop.IsLast = false; + secondbrushStop.Position = BrushStopModel.PositionStatus.SecondColor; secondbrushStop.OffsetPercent = 100; BrushStops.Add(secondbrushStop); BrushStopModel lastSecondBrushStop = secondBrush.Clone(); lastSecondBrushStop.StopIndex = 5; lastSecondBrushStop.OffsetPercent = 100; - lastSecondBrushStop.IsLast = true; - lastSecondBrushStop.IsFirst = false; - lastSecondBrushStop.IsFirstColorBrush = false; - lastSecondBrushStop.IsMiddle = false; - lastSecondBrushStop.IsSecondColorBrush = false; + lastSecondBrushStop.Position = BrushStopModel.PositionStatus.Last; ; BrushStops.Add(lastSecondBrushStop); } @@ -488,18 +468,18 @@ namespace Tango.PPC.Jobs.Models { target.SetNewColor(source); target.IsOutOfGamut = source.IsOutOfGamut; - if (target.IsFirstColorBrush) + if (target.Position == BrushStopModel.PositionStatus.FirstColor) { - BrushStopModel first = BrushStops.Where(x => x.IsFirst).FirstOrDefault(); + BrushStopModel first = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.First).FirstOrDefault(); if(first != null) { first.SetNewColor(source); first.IsOutOfGamut = source.IsOutOfGamut; } } - else if(target.IsSecondColorBrush) + else if(target.Position == BrushStopModel.PositionStatus.SecondColor) { - BrushStopModel last = BrushStops.Where(x => x.IsLast).FirstOrDefault(); + BrushStopModel last = BrushStops.Where(x => x.Position == BrushStopModel.PositionStatus.Last).FirstOrDefault(); if(last != null) { last.SetNewColor(source); 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 deleted file mode 100644 index f8c1e81a0..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/NavigationObjects/ColorSelectionNavigationObject.cs +++ /dev/null @@ -1,20 +0,0 @@ -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 d816fa42e..deb0e5cc9 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 @@ -92,6 +92,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -124,6 +128,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -136,10 +144,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -202,6 +206,9 @@ BasicColorCorrectionView.xaml + + ColorSelectionView.xaml + ImportCsvJobView.xaml @@ -234,6 +241,10 @@ + + RepeatJobView.xaml + + SpoolChangeView.xaml @@ -245,7 +256,6 @@ - @@ -269,16 +279,13 @@ - + - - ColorSelectionToolView.xaml - JobProgressView.xaml @@ -593,7 +600,7 @@ - + \ No newline at end of file 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 4f357be2c..5298cf096 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModelLocator.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.DI; +using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.ViewModels; namespace Tango.PPC.Jobs @@ -21,7 +22,7 @@ namespace Tango.PPC.Jobs TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } /// @@ -94,11 +95,11 @@ namespace Tango.PPC.Jobs /// /// Gets the twine catalog view VM. /// - public static ColorSelectionToolViewVM ColorSelectionToolViewVM + public static ColorSelectionViewVM ColorSelectionToolViewVM { get { - return TangoIOC.Default.GetInstance(); + 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 deleted file mode 100644 index aeb42f98b..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/ColorSelectionToolViewVM.cs +++ /dev/null @@ -1,285 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Enumerations; -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, - CMYK, - Catalogs - } - - private ActionTimer _volumeConversionTimer; - private IColorConverter _converter; - - - #region Properties - private bool _confirmed; - - private bool _isEditMode; - - public bool IsEditMode - { - get { return _isEditMode; } - set { _isEditMode = value; - RaisePropertyChangedAuto(); - } - } - - 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 _initialBrushStop; - /// - /// Gets or sets the initial brush stop. - /// - public BrushStopModel InitialBrushStop - { - get { return _initialBrushStop; } - set { - _initialBrushStop = value; - RaisePropertyChangedAuto(); } - } - - private BrushStopModel _selectedBrushStop; - /// - /// Gets or sets the edited brush stop. - /// - public BrushStopModel SelectedBrushStop - { - get { return _selectedBrushStop; } - set - { - _selectedBrushStop = value; - RaisePropertyChangedAuto(); - } - } - - public double MaxCyanValue - { - get - { - return GetMaxCMYKValueOrDefault( LiquidTypes.Cyan); - } - } - - public double MaxMagentaValue - { - get - { - return GetMaxCMYKValueOrDefault(LiquidTypes.Magenta); - } - } - - public double MaxYellowValue - { - get - { - return GetMaxCMYKValueOrDefault(LiquidTypes.Yellow); - } - } - - public double MaxBlackValue - { - get - { - return GetMaxCMYKValueOrDefault(LiquidTypes.Black); - } - } - - #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(); - } - - #region Navigation - /// Confirms this instance. - /// - private void Confirm() - { - _confirmed = true; - - NavigationManager.NavigateBack(); - } - - public BrushStopModel GetNavigationResult() - { - if (_confirmed) - { - return SelectedBrushStop; - } - else - { - return null; - } - } - - public void OnNavigationObjectReceived(ColorSelectionNavigationObject obj) - { - SegmentIndex = obj.SelectedSegment.SegmentIndex; - IsEditMode = obj.IsEditingMode; - if (obj.IsEditingMode) - { - InitialBrushStop = obj.BrushStopForEdit; - // InitialBrushStop.ConvertColorToRGB(); - // InitialBrushStop.InitColor(); - SelectedBrushStop = InitialBrushStop.Clone(); - SelectedBrushStop.ColorSpace = InitialBrushStop.ColorSpace; - - if(SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.RGB) - SelectedColorTab = ColorTab.RGB; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.LAB) - SelectedColorTab = ColorTab.CIELab; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.CMYK) - SelectedColorTab = ColorTab.CMYK; - else if (SelectedBrushStop.ColorSpace == BL.Enumerations.ColorSpaces.Catalog) - SelectedColorTab = ColorTab.Catalogs; - else SelectedColorTab = ColorTab.HSB; - } - else - { - SelectedBrushStop = obj.BrushStopForEdit; - SelectedColorTab = ColorTab.RGB; - } - UpdateCMYKMaxValues(); - _confirmed = false; - } - - private void OnSelectedtabChanged() - { - switch (SelectedColorTab) - { - case ColorTab.HSB: - { - if (SelectedBrushStop != null) - { - SelectedBrushStop.ConvertColorToHSB(); - } - - return; - } - case ColorTab.RGB: - { - if (SelectedBrushStop != null) - { - SelectedBrushStop.ConvertColorToRGB(); - } - return; - } - case ColorTab.CIELab: - { - if (SelectedBrushStop != null) - { - SelectedBrushStop.ConvertColorToLAB(); - } - return; - } - case ColorTab.CMYK: - { - - if (SelectedBrushStop != null) - { - SelectedBrushStop.ConvertColorToCMYK(); - } - return; - } - } - } - - #endregion - - #region Methods - - private double GetMaxCMYKValueOrDefault(LiquidTypes type) - { - if (SelectedBrushStop != null && SelectedBrushStop.SegmentModel != null && SelectedBrushStop.SegmentModel.Job != null && SelectedBrushStop.SegmentModel.Job.Rml != null) - { - var liquidTypesRml = SelectedBrushStop.SegmentModel.Job.Rml.LiquidTypesRmls.FirstOrDefault(x => x.LiquidType.Type == type); - if (liquidTypesRml != null) - { - //var test = liquidTypesRml.GetMaxCalibrationValue(); - - return liquidTypesRml.GetMaxCalibrationValue(); - } - - } - return 100; - } - - private void UpdateCMYKMaxValues() - { - RaisePropertyChanged(nameof(MaxCyanValue)); - RaisePropertyChanged(nameof(MaxMagentaValue)); - RaisePropertyChanged(nameof(MaxYellowValue)); - RaisePropertyChanged(nameof(MaxBlackValue)); - } - #endregion - } -} 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 52c961876..990f210f4 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 @@ -48,11 +48,11 @@ namespace Tango.PPC.Jobs.ViewModels /// Represents the selected job view model. /// /// - public class JobViewVM : PPCViewModel, INavigationObjectReceiver + public class JobViewVM : PPCViewModel, INavigationObjectReceiver, INavigationBlocker { private ObservablesContext _db; private bool _can_navigate_back; - private Thread _check_gamut_thread; + //private Thread _check_gamut_thread; private Job _job_to_load; private JobNavigationIntent _job_to_load_intent; private static Dictionary> _jobs_fine_tune_items; @@ -435,7 +435,7 @@ namespace Tango.PPC.Jobs.ViewModels // (e.Draggable as FrameworkElement).DataContext as Segment, // (e.Droppable as FrameworkElement).DataContext as Segment); //}); - + AddColorCommand = new RelayCommand(AddColor); EditColorCommand = new RelayCommand(EditColor); @@ -453,8 +453,8 @@ namespace Tango.PPC.Jobs.ViewModels } }); - _check_gamut_thread = new Thread(CheckGamutThreadMethod); - _check_gamut_thread.IsBackground = true; + //_check_gamut_thread = new Thread(CheckGamutThreadMethod); + //_check_gamut_thread.IsBackground = true; StartSampleDyeCommand = new RelayCommand(StartSampleDye, CanStartJob); DyeCommand = new RelayCommand(StartJob, CanStartJob); @@ -479,8 +479,8 @@ namespace Tango.PPC.Jobs.ViewModels RepeateSegmentCommand = new RelayCommand(RepeateSegment); PasteCommand = new RelayCommand(Paste); CopyCommand = new RelayCommand(Copy); - UndoCommand = new RelayCommand(Undo); - RedoCommand = new RelayCommand(Redo); + UndoCommand = new RelayCommand(Undo,(x)=> { return false; }); + RedoCommand = new RelayCommand(Redo, (x) => { return false; }); IsFullMode = true; } @@ -498,10 +498,9 @@ namespace Tango.PPC.Jobs.ViewModels { if (!(_job_to_load == null || (_job_to_load != null && Job != null && _job_to_load.Guid == Job.Guid))) { - View.ScrollToTop(); + //View.ScrollToTop(); LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); - //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); IsFree = false; @@ -541,9 +540,7 @@ namespace Tango.PPC.Jobs.ViewModels .WithSegments() .WithBrushStops() .BuildAsync(); - - //Job.RmlChanged += OnRmlChanged; Job.NameChanged -= Job_NameChanged; Job.NameChanged += Job_NameChanged; @@ -568,15 +565,7 @@ namespace Tango.PPC.Jobs.ViewModels 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(); + ///NEW CODE Save to MODEL var jobModel = new JobModel(ColorSpaces) { @@ -594,7 +583,7 @@ namespace Tango.PPC.Jobs.ViewModels foreach( var segm in Job.Segments) { - SegmentModel segmentModel = new SegmentModel(jobModel) + SegmentModel segmentModel = new SegmentModel(jobModel, segm.Guid) { Name = segm.Name, Length = segm.Length, @@ -607,6 +596,7 @@ namespace Tango.PPC.Jobs.ViewModels { BrushStopModel brushStopModel = new BrushStopModel(segmentModel) { + SegmentModel = segmentModel, Cyan = brushStop.Cyan, Magenta = brushStop.Magenta, Yellow = brushStop.Yellow, @@ -618,14 +608,16 @@ namespace Tango.PPC.Jobs.ViewModels 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 + ColorCatalogsItem = brushStop.ColorCatalogsItem, + StopIndex = brushStop.StopIndex }; - AddBrushStop(segmentModel, brushStopModel); + segmentModel.BrushStops.Add(brushStopModel); + // AddBrushStop(segmentModel, brushStopModel); } + ArrangeBrushStopsPosition(segmentModel); jobModel.Segments.Add(segmentModel); } JobModel = jobModel; @@ -691,7 +683,7 @@ namespace Tango.PPC.Jobs.ViewModels base.OnBeforeNavigatedFrom(); //Save... } - + /// /// Saves the job. /// @@ -801,43 +793,37 @@ namespace Tango.PPC.Jobs.ViewModels try { LogManager.Log("Editing the job details."); - JobCreationViewVM vm = new JobCreationViewVM( - _spoolTypes.ToList(), - _rmls.ToList() - ); + JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(),_rmls.ToList(), JobModel.InterSegmentLength, true ); vm.JobName = JobModel.Name; vm.SelectedRML = JobModel.Rml; vm.SelectedSpoolType = JobModel.SpoolType; vm = await NotificationProvider.ShowDialog(vm); if (!vm.DialogResult) return; - Job.Name = vm.JobName; - JobModel.Name = vm.JobName; - bool updateVolumes = JobModel.Rml != vm.SelectedRML; - JobModel. Rml = vm.SelectedRML; - SelectedRML = vm.SelectedRML; - JobModel.Rml = vm.SelectedRML; - Job.SpoolType = vm.SelectedSpoolType; - JobModel.SpoolType = vm.SelectedSpoolType; + if(vm.IsDuplicate) + { + //Duplicate new job + /* + * int index = Jobs.Max(x => x.JobIndex); + + List clonedJobs = new List(); - if(updateVolumes) + foreach (var job in SelectedJobs) { - NotificationProvider.SetGlobalBusyMessage("Updating job liquid volumes..."); - foreach (var stop in JobModel.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) - { - try - { - stop.OnBrushStopFieldValueChanged(); - //TODO ASK ROY!!!!!! - //output.ApplyOnBrushStopVolumesOnly(stop); - } - catch (Exception ex) - { - LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.SegmentModel.SegmentIndex}, stop {stop.StopIndex}."); - } - } - NotificationProvider.ReleaseGlobalBusyMessage(); + var cloned = job.Clone(); + cloned.JobIndex = ++index; + _db.Jobs.Add(cloned); + clonedJobs.Add(cloned); } + + await _db.SaveChangesAsync(); + * */ + } + Job.Name = vm.JobName; + JobModel.Name = vm.JobName; + Job.SpoolType = vm.SelectedSpoolType; + JobModel.SpoolType = vm.SelectedSpoolType;//update length!!!! + SelectedRML = vm.SelectedRML; } catch (Exception ex) { @@ -845,9 +831,22 @@ namespace Tango.PPC.Jobs.ViewModels } } - private void RepeatUnits() + private async void RepeatUnits() { - //open dialog + var maxLength = Job.SpoolType.Length; + var maxRep = (maxLength == 0 ? 999 : (maxLength / JobModel.Length)); + + + var vm = await NotificationProvider.ShowDialog(new RepeatJobViewVM() + { + MaxRepeations = (int)maxRep, + Repeats = JobModel.NumberOfUnits + }); + + if (vm.DialogResult) + { + JobModel.NumberOfUnits = vm.Repeats; + } } #endregion @@ -865,7 +864,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (Job.Rml != rml || rml.Cct == null) { - bool updateVolumes = Job.Rml != rml; + bool updateRML = Job.Rml != rml; Job.Rml = await new RmlBuilder(_db) .Set(rml.Guid) @@ -875,32 +874,50 @@ namespace Tango.PPC.Jobs.ViewModels .WithLiquidFactors() .WithSpools() .BuildAsync(); - - //foreach (var segment in Job.Segments) - //{ - // SetSegmentLiquidVolumes(segment); - //} - + if(JobModel != null) + JobModel.Rml = Job.Rml; + GetLubricationLevel(); await SetSpoolTension(rml); - if (updateVolumes) + if (updateRML && JobModel != null) { - 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()) + NotificationProvider.SetGlobalBusyMessage("Updating IsOutOfGammut due to the change RML..."); + foreach (var stop in JobModel.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorSpace == BL.Enumerations.ColorSpaces.RGB || x.ColorSpace == BL.Enumerations.ColorSpaces.LAB).ToList()) { try { - var output = await _converter.ConvertAsync(stop, false, false); - output.ApplyOnBrushStopVolumesOnly(stop); + stop.OnBrushStopFieldValueChanged(); + //TODO ASK ROY!!!!!! + //output.ApplyOnBrushStopVolumesOnly(stop); } catch (Exception ex) { - LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.Segment.SegmentIndex}, stop {stop.StopIndex}."); + LogManager.Log(ex, $"Error updating stop volumes after changing thread on segment {stop.SegmentModel.SegmentIndex}, stop {stop.StopIndex}."); } } + DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); NotificationProvider.ReleaseGlobalBusyMessage(); } + //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(); + //} } } } @@ -1022,204 +1039,6 @@ namespace Tango.PPC.Jobs.ViewModels #region Brush Stops Management - //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; - // } - // } - // } - //} - - - /// - /// 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. /// @@ -1244,12 +1063,23 @@ namespace Tango.PPC.Jobs.ViewModels // } //} - private void ArrangeBrushStopsIndices(Segment segment) + private void ArrangeBrushStopsIndexes(SegmentModel segment) { for (int i = 0; i < segment.BrushStops.Count; i++) { segment.BrushStops[i].StopIndex = i + 1; } + ArrangeBrushStopsPosition(segment); + } + + private void ArrangeBrushStopsPosition(SegmentModel segment) + { + if(segment.BrushStops.Count == 1) + { + segment.BrushStops.FirstOrDefault().Position = BrushStopModel.PositionStatus.FirstColor; + } + else if (segment.BrushStops.Count > 1) + segment.BrushStops.ToList().ForEach(x => x.Position = (BrushStopModel.PositionStatus)x.StopIndex); } private bool ValidateBrushStops() @@ -1269,15 +1099,21 @@ namespace Tango.PPC.Jobs.ViewModels await NotificationProvider.ShowInfo("Color transitions are best visible with segment length of 5 meters and above."); } - var newBrushStop = await NavigationManager.NavigateForResult( - new ColorSelectionNavigationObject() + var vm = await NotificationProvider.ShowDialog(new ColorSelectionViewVM() + { + DialogEditObject = new ColorSelectionViewVM.DialogObject() { SelectedSegment = segment, BrushStopForEdit = new BrushStopModel(segment), - IsEditingMode = false - }, true); - - AddBrushStop(segment, newBrushStop); + IsEditingMode = false, + } + }); + + if (vm.DialogResult) + { + AddBrushStop(segment, vm.SelectedBrushStop); + DyeCommand.RaiseCanExecuteChanged(); + } // SetSegmentLiquidVolumes(segment); //RegisterJobBrushStopsEvents(); } @@ -1289,18 +1125,22 @@ namespace Tango.PPC.Jobs.ViewModels { SegmentModel segment = brushStop.SegmentModel; LogManager.Log($"Edit brush stop."); - - var newBrushStop = await NavigationManager.NavigateForResult( - new ColorSelectionNavigationObject() + + var vm = await NotificationProvider.ShowDialog(new ColorSelectionViewVM() + { + DialogEditObject = new ColorSelectionViewVM.DialogObject() { SelectedSegment = segment, BrushStopForEdit = brushStop, - IsEditingMode = true - }, true); + IsEditingMode = true, + } + }); - if(newBrushStop != null) + + if (vm.DialogResult) { - segment.SetNewColor(brushStop,newBrushStop); + segment.SetNewColor(brushStop, vm.SelectedBrushStop); + DyeCommand.RaiseCanExecuteChanged(); } } @@ -1310,29 +1150,23 @@ namespace Tango.PPC.Jobs.ViewModels public async void AddBrushStop(SegmentModel segment, BrushStopModel newBrushStop) { if (newBrushStop == null || segment == null) - return; - - JobModel job = segment.Job; - + return; + Segment s = new Segment(); //SolidColor - if(segment.BrushStops.Count == 0) + if (segment.BrushStops.Count == 0) { - newBrushStop.IsFirstColorBrush = true; + newBrushStop.Position = BrushStopModel.PositionStatus.FirstColor; segment.BrushStops.Add(newBrushStop); } - //Add SecondColor + //Add Second BrushStop else if(segment.BrushStops.Count == 1)// add gradient { BrushStopModel currentBrushStop = segment.BrushStops[0]; segment.CreateGradientBrushes(segment.BrushStops[0], newBrushStop); segment.RaiseSegmentBrushChanged(); } - else + else //Create new Segment and Add BrushStop { - if (segment.BrushStops.Count < 5) - { - return; - } await NotificationProvider.ShowInfo("Please note that gradient segment is now split into two gradients."); SegmentModel newSegmentModel = segment.Clone(); @@ -1347,12 +1181,14 @@ namespace Tango.PPC.Jobs.ViewModels segment.AddOrReplaceSecondBrush(newBrushStop); segment.UpdateMiddleColorBrush(); segment.RaiseSegmentBrushChanged(); + ArrangeBrushStopsIndexes(segment); + ArrangeBrushStopsIndexes(newSegmentModel); - if(job.Segments.Count == segment.SegmentIndex) - job.Segments.Add(newSegmentModel); + if (JobModel.Segments.Count == segment.SegmentIndex) + JobModel.Segments.Add(newSegmentModel); else { - job.Segments.Insert(segment.SegmentIndex, newSegmentModel); + JobModel.Segments.Insert(segment.SegmentIndex, newSegmentModel); } ArrangeSegmentsIndixes(); } @@ -1596,51 +1432,7 @@ namespace Tango.PPC.Jobs.ViewModels #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 @@ -1755,6 +1547,11 @@ namespace Tango.PPC.Jobs.ViewModels _job_to_load_intent = JobNavigationIntent.Default; } + public override void OnNavigatedTo(PPCViewModel fromVM) + { + base.OnNavigatedTo(fromVM); + } + /// /// Called before the navigation system navigates back from this object. /// Return false to abort the navigation. @@ -1762,40 +1559,17 @@ namespace Tango.PPC.Jobs.ViewModels /// public async override Task OnNavigateBackRequest() { - bool result = true; - - if (!IsFree) return false; - - if (!_can_navigate_back) + try { - 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; - } + await Save(); + return true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving job to database."); + await NotificationProvider.ShowError("Error saving the current job."); + return false; } - - return result; } public override void OnApplicationReady() @@ -1832,16 +1606,21 @@ namespace Tango.PPC.Jobs.ViewModels { if (false == JobModel.Segments.ToList().Any(x => x.IsSelected)) return; - var firstIndex = JobModel.Segments.ToList().FindIndex(i => i.IsSelected == true); - var lastIndex = JobModel.Segments.ToList().FindLastIndex(i => i.IsSelected == true); - if(firstIndex < lastIndex) - { - //TODO function! - //var copy = JobModel.Segments.ToList(); - //copy.Reverse(firstIndex, (lastIndex - firstIndex + 1)); - //JobModel.Segments = new SynchronizedObservableCollection(copy); - //ArrangeSegmentsIndixes(); + + for (int firstIndex = 0, lastIndex = JobModel.Segments.Count - 1; firstIndex < lastIndex; firstIndex++) + { + if (JobModel.Segments[firstIndex].IsSelected) + { + for (; lastIndex >= 0; lastIndex--) + { + if (JobModel.Segments[lastIndex].IsSelected) + { + JobModel.SwapSegments(firstIndex, lastIndex); + } + } + } } + ArrangeSegmentsIndixes(); } private async void DeleteSegment() @@ -1902,5 +1681,80 @@ namespace Tango.PPC.Jobs.ViewModels } #endregion + + private async Task Save() + { + if (JobModel == null) + return; + var colorSpaces = await _db.ColorSpaces.ToListAsync(); + + Job.ColorSpace = colorSpaces.FirstOrDefault(); + + var oldSegments = Job.Segments.ToList(); + + foreach (var segment in Job.Segments.ToList()) + { + foreach (var stop in segment.BrushStops.ToList()) + { + _db.BrushStops.Remove(stop); + } + + _db.Segments.Remove(segment); + } + + Job.Segments.Clear(); + + foreach (var segment in JobModel.Segments.OrderBy(x => x.SegmentIndex).ToList()) + { + var dbSegment = new Segment(); + dbSegment.Name = "Standard Segment"; + + dbSegment.Job = Job; + dbSegment.SegmentIndex = segment.SegmentIndex; + dbSegment.Length = segment.Length; + + _db.Segments.Add(dbSegment); + + foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) + { + var dbStop = new BrushStop(); + dbStop.Segment = dbSegment; + _db.BrushStops.Add(dbStop); + + dbStop.ColorSpace = colorSpaces.FirstOrDefault(x => x.Code == (int)stop.ColorSpace); + dbStop.Red = stop.Red; + dbStop.Green = stop.Green; + dbStop.Blue = stop.Blue; + dbStop.L = stop.L; + dbStop.A = stop.A; + dbStop.B = stop.B; + dbStop.Cyan = stop.Cyan; + dbStop.Magenta = stop.Magenta; + dbStop.Yellow = stop.Yellow; + dbStop.Black = stop.Black; + dbStop.BestMatchR = stop.DisplayedColor.R; + dbStop.BestMatchG = stop.DisplayedColor.G; + dbStop.BestMatchB = stop.DisplayedColor.B; + + dbStop.OffsetPercent = stop.OffsetPercent; + dbStop.StopIndex = stop.StopIndex; + dbStop.IsOutOfGamut = stop.IsOutOfGamut; + + + dbStop.SetVolume(LiquidTypes.Cyan, stop.Cyan); + dbStop.SetVolume(LiquidTypes.Magenta, stop.Magenta); + dbStop.SetVolume(LiquidTypes.Yellow, stop.Yellow); + dbStop.SetVolume(LiquidTypes.Black, stop.Black); + } + } + Job.LastUpdated = DateTime.UtcNow; + Job.IsSynchronized = false; + Job.JobStatus = BL.Enumerations.JobStatuses.Draft; + //_current_job_string = Job.ToJobFileWhenLoaded().ToString(); + RaiseMessage(new JobSavedMessage() { Job = Job }); + + await _db.SaveChangesAsync(); + + } } } 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 0a1ce7df7..1f7042b57 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 @@ -422,10 +422,7 @@ namespace Tango.PPC.Jobs.ViewModels { await Task.Delay(200); } - JobCreationViewVM vm = new JobCreationViewVM( - _spoolTypes.ToList(), - _rmls.ToList() - ); + JobCreationViewVM vm = new JobCreationViewVM( _spoolTypes.ToList(), _rmls.ToList(), 3, false ); string selectedRmlGuid = (Settings.DefaultRmlGuid != null && _rmls.Select(x => x.Guid).Contains(Settings.DefaultRmlGuid)) ? Settings.DefaultRmlGuid : _rmls.FirstOrDefault().Guid; string selectedSpoolTypeGuid = Settings.DefaultSpoolTypeGuid != null ? Settings.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; ; 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 deleted file mode 100644 index 9d48df2fb..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - My Colors - - - - - - - - - - - - - - Job Palette - - - - - - - - - - - - - - - - - - - - - - - - Color Selection Tool - - - - - - - - - HSB - CIELab - RGB - CMYK - Catalogs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index dea4c2d61..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Views/ColorSelectionToolView.xaml.cs +++ /dev/null @@ -1,61 +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.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) - { - - } - - private void TouchNavigationLinks_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) - { - if (_vm != null && _vm.SelectedBrushStop != null && true == _vm.SelectedBrushStop.IsCMYKLiquidVolumesOutOfRange) - { - var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem; - if (item != null) - { - e.Handled = true; - } - } - } - - - } -} 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 982c534b9..65a880f4e 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 @@ -145,7 +145,7 @@ - + @@ -241,7 +241,7 @@ - + @@ -269,7 +269,7 @@ - + @@ -406,10 +406,8 @@ - - - - + + @@ -419,24 +417,29 @@ - + - + - - - - - - + + + + + + + + + + + - - - + + + @@ -559,11 +562,14 @@ - + - + @@ -575,7 +581,7 @@ - + - - - + + + - + Repeat Job @@ -603,21 +609,28 @@ - - + + + + + + + + - + - - + + - - + + + @@ -642,14 +655,12 @@ % - - - - - + + + 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 77c30bb30..66c497e29 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 @@ -28,7 +28,7 @@ namespace Tango.PPC.Jobs.Views public partial class JobView : UserControl, INavigationView, IJobView { private JobViewVM _vm; - private bool _is_edit_docked; + public JobView() { @@ -47,10 +47,10 @@ namespace Tango.PPC.Jobs.Views } - private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) - { - _vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop); - } + //private void OnBrushStopFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + //{ + // _vm.OnBrushStopFieldValueChanged((sender as FrameworkElement).DataContext as BrushStop); + //} public void DisplaySampleDye() { @@ -116,18 +116,23 @@ namespace Tango.PPC.Jobs.Views // borderEditDock.Visibility = Visibility.Collapsed; //} - private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) - { - var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; + //private void OnLiquidVolumeFieldValueChanged(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + //{ + // var liquidVolume = (sender as FrameworkElement).DataContext as LiquidVolume; - if (liquidVolume != null) - { - _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); - } - } + // if (liquidVolume != null) + // { + // _vm.OnBrushStopFieldValueChanged(liquidVolume.BrushStop); + // } + //} public void ScrollToTop() { + if(listSegments.IsVisible && listSegments.Items.Count > 0) + { + listSegments.ScrollIntoView(listSegments.Items[0]); + + } //FloatEditing(); //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 index 77d2d200d..505ccc312 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,7 +17,6 @@ - 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 c33e90e76..bb0a694cf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -17,6 +17,10 @@ + + + + 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 593adc3f5..e7a6cd6c3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -49,16 +49,14 @@ - + - - + +