From 3681ab681f02bbb7cda89de4044fd69bc9d61ab8 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 16 Feb 2022 19:15:31 +0200 Subject: PPC. Create Segments Groups. --- .../Dialogs/ColorSelectionView.xaml.cs | 19 +- .../Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml | 4 +- .../Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs | 15 +- .../Helpers/GroupSegmentTemplateSelector.cs | 31 +++ .../Tango.PPC.JobsV2/Models/ISegmentModel.cs | 19 ++ .../Modules/Tango.PPC.JobsV2/Models/JobModel.cs | 70 +++++- .../Tango.PPC.JobsV2/Models/SegmentModel.cs | 22 +- .../Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs | 129 ++++++++++ .../Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj | 8 +- .../UndoRedoCommands/AddBrushStopCommand.cs | 1 + .../UndoRedoCommands/DeleteSegmentsGroupCommand.cs | 48 ++++ .../UndoRedoCommands/DuplicateSegmentCommand.cs | 2 + .../UndoRedoCommands/PasteSegmentsCommand.cs | 2 + .../UndoRedoCommands/RemoveSegmentCommand.cs | 2 + .../UndoRedoCommands/RemoveSegmentsCommand.cs | 2 + .../UndoRedoCommands/RepeatCommand.cs | 54 ++++ .../UndoRedoCommands/UnGroupSegmentsCommand.cs | 31 +++ .../Tango.PPC.JobsV2/ViewModels/JobViewVM.cs | 165 ++++++++---- .../Modules/Tango.PPC.JobsV2/Views/JobView.xaml | 276 ++++++++++++++++++++- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Visual_Studio/Tango.BL/Builders/JobBuilder.cs | 2 +- .../Visual_Studio/Tango.BL/DTO/SegmentDTOBase.cs | 8 + .../Visual_Studio/Tango.BL/DTO/SegmentsGroupDTO.cs | 14 ++ .../Tango.BL/DTO/SegmentsGroupDTOBase.cs | 41 +++ .../Visual_Studio/Tango.BL/Entities/SegmentBase.cs | 69 ++++++ .../Tango.BL/Entities/SegmentsGroup.cs | 16 ++ .../Tango.BL/Entities/SegmentsGroupBase.cs | 152 ++++++++++++ .../Visual_Studio/Tango.BL/ObservablesContext.cs | 8 + .../ObservablesEntitiesAdapterExtension.cs | 38 +++ .../ObservablesStaticCollectionsExtension.cs | 38 +++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 6 +- .../Tango.DAL.Remote/DB/RemoteADO.Context.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.Designer.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 72 +++++- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 182 +++++++------- .../Visual_Studio/Tango.DAL.Remote/DB/SEGMENT.cs | 2 + .../Tango.DAL.Remote/DB/SEGMENTS_GROUPS.cs | 32 +++ .../Tango.DAL.Remote/Tango.DAL.Remote.csproj | 5 +- 38 files changed, 1414 insertions(+), 176 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Helpers/GroupSegmentTemplateSelector.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ISegmentModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DeleteSegmentsGroupCommand.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RepeatCommand.cs create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UnGroupSegmentsCommand.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTO.cs create mode 100644 Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTOBase.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/SegmentsGroup.cs create mode 100644 Software/Visual_Studio/Tango.BL/Entities/SegmentsGroupBase.cs create mode 100644 Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENTS_GROUPS.cs (limited to 'Software/Visual_Studio') 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 index 60a3f5039..4f18dc853 100644 --- 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 @@ -41,15 +41,16 @@ namespace Tango.PPC.Jobs.Dialogs 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; - } - } - else if (_vm != null) + // 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; + // } + // } + // else + if (_vm != null) { var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem; if (item != null && item.DataContext is TextBlock ) 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 index bf242e98b..6f011bf4e 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobView.xaml @@ -6,7 +6,7 @@ xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.Jobs.Dialogs" mc:Ignorable="d" - Background="Transparent" d:DesignHeight="630" d:DesignWidth="560" MinWidth="380" Height="250" + Background="Transparent" d:DesignHeight="250" d:DesignWidth="380" Width="380" Height="250" d:DataContext="{d:DesignInstance Type=local:RepeatJobViewVM, IsDesignTimeCreatable=False}"> @@ -21,7 +21,7 @@ - Repeat All + 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 index 4cf5d8c95..44c396798 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Dialogs/RepeatJobViewVM.cs @@ -9,6 +9,16 @@ namespace Tango.PPC.Jobs.Dialogs { public class RepeatJobViewVM : DialogViewVM { + private string _headerName; + + public string HeaderName + { + get { return _headerName; } + set { _headerName = value; + RaisePropertyChangedAuto(); + } + } + private int _repeats; public int Repeats @@ -31,9 +41,10 @@ namespace Tango.PPC.Jobs.Dialogs } - public RepeatJobViewVM() + public RepeatJobViewVM(string name, int repeats) { - Repeats = 1; + HeaderName = name; + Repeats = repeats; } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Helpers/GroupSegmentTemplateSelector.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Helpers/GroupSegmentTemplateSelector.cs new file mode 100644 index 000000000..e28b920d8 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Helpers/GroupSegmentTemplateSelector.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using Tango.PPC.Jobs.Models; + +namespace Tango.PPC.Jobs.Helpers +{ + public class GroupSegmentTemplateSelector : DataTemplateSelector + { + public DataTemplate GroupSegmentsTemplate { get; set; } + + public DataTemplate SegmentTemplate { get; set; } + + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + var selectedTemplate = this.SegmentTemplate; + + var segmentModel = item as ISegmentModel; + if (segmentModel != null && segmentModel.IsGroupSegment) + { + selectedTemplate = this.GroupSegmentsTemplate; + } + + return selectedTemplate; + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ISegmentModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ISegmentModel.cs new file mode 100644 index 000000000..9bed7e849 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/ISegmentModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Jobs.Models +{ + public interface ISegmentModel + { + String Name { get; set; } + double Length { get; set; } + bool IsGroupSegment { get; } + bool IsSelected { get; set; } + bool IsLast { get; set; } + Int32 SegmentIndex { get; set; } + double InterSegmentLength { get; } + } +} 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 bc6997120..3379149f6 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 @@ -333,7 +333,7 @@ namespace Tango.PPC.Jobs.Models { _segments = value; RaisePropertyChangedAuto(); - //OnSegmentsChanged(value); + OnSegmentsChanged(); } } } @@ -368,6 +368,25 @@ namespace Tango.PPC.Jobs.Models } } + protected ObservableCollection _groupingSegments; + /// + /// Gets or sets the display segments. + /// + public ObservableCollection GroupingSegments + { + get + { + return _groupingSegments; + } + set + { + if (_groupingSegments != value) + { + _groupingSegments = value; + RaisePropertyChangedAuto(); + } + } + } private bool _selectAllSegments; public bool SelectAllSegments @@ -405,24 +424,59 @@ namespace Tango.PPC.Jobs.Models } } - - + public int LastNewGroupID { get; set; } + #endregion public JobModel(List list) { ColorSpacesList = list; - Segments = new SynchronizedObservableCollection(); + _segments = new SynchronizedObservableCollection(); + _groupingSegments = new ObservableCollection(); SegmentsToCopy = new List(); Segments.CollectionChanged -= Segments_CollectionChanged; Segments.CollectionChanged += Segments_CollectionChanged; SelectAllSegments = false; NumberOfUnits = 1; + LastNewGroupID = 1; } #region modifications + private void OnSegmentsChanged() + { + LoadGroupingSegments(); + } + + public void LoadGroupingSegments() + { + GroupingSegments.Clear(); + var groupedList = Segments.Where(x => x.GroupID >0).Select(grp => grp.SegmentsGroupModel).Distinct().ToList();//List + Dictionary groupIDToSegmentsGroup = new Dictionary(); + foreach (var group in groupedList) + { + var groupID = group.GroupID; + groupIDToSegmentsGroup[groupID] = group; + }; + foreach (var segment in Segments) + { + if (!segment.IsGroupSegment) + { + GroupingSegments.Add(segment); + } + else + { + SegmentsGroupModel segmentsGroup; + if (groupIDToSegmentsGroup.TryGetValue(segment.GroupID, out segmentsGroup)) + { + GroupingSegments.Add(segmentsGroup); + groupIDToSegmentsGroup.Remove(segment.GroupID); + } + } + } + RaisePropertyChanged(nameof(GroupingSegments)); + } public static SegmentModel CreateInterSegment(double length) { SegmentModel segment = new SegmentModel() @@ -444,8 +498,6 @@ namespace Tango.PPC.Jobs.Models SegmentModel segment = new SegmentModel(); segment.Name = "Standard Segment"; segment.SegmentIndex = segmentIndex + 1; - - segment.Length = length; segment.Job = this; @@ -454,11 +506,12 @@ namespace Tango.PPC.Jobs.Models if(segmentIndex < Segments.Count) { Segments.Insert(segmentIndex,segment); - } else Segments.Add(segment); + LoadGroupingSegments(); + return segment; } @@ -479,7 +532,7 @@ namespace Tango.PPC.Jobs.Models OnLengthChanged(); RaisePropertyChanged(nameof(EffectiveSegments)); } - + /// /// Handles the PropertyChanged event of all job segments. /// @@ -513,6 +566,7 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(HasSelectedItems)); } } + /// /// Called when the property has been changed 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 b65d7e156..0773abf19 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 : ExtendedObject + public class SegmentModel : ExtendedObject, ISegmentModel { private double _lastLength; private LinearGradientBrush _brush; @@ -28,6 +28,13 @@ namespace Tango.PPC.Jobs.Models public string GUID { get; set; } + public int GroupID { + get + { + return SegmentsGroupModel == null ? -1 : SegmentsGroupModel.GroupID; + } + } + protected String _name; /// /// Gets or sets the SegmentModel name. @@ -68,6 +75,15 @@ namespace Tango.PPC.Jobs.Models } } } + + public bool IsGroupSegment + { + get + { + return SegmentsGroupModel != null; + } + } + public void LengthBeforeChange(double value) { _lastLength = Length; @@ -418,6 +434,8 @@ namespace Tango.PPC.Jobs.Models } } + public SegmentsGroupModel SegmentsGroupModel { get; set; } + #endregion #region command @@ -514,7 +532,7 @@ namespace Tango.PPC.Jobs.Models cloned.BrushStops = BrushStops.Select(x => x.Clone()).ToSynchronizedObservableCollection(); cloned.SegmentIndex = SegmentIndex + 1; - + cloned.SegmentsGroupModel = SegmentsGroupModel; return cloned; } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs new file mode 100644 index 000000000..0c3863f78 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Models/SegmentsGroupModel.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.PPC.Jobs.Models +{ + public class SegmentsGroupModel : ExtendedObject, ISegmentModel + { + #region Properties + + public ObservableCollection Segments { get; set; } + + public int GroupID{ get; set; } + + private int _repeats; + + public int Repeats + { + get { return _repeats; } + set { _repeats = value; + RaisePropertyChangedAuto(); + } + } + + private string _name; + public string Name + { + get { return _name; } + set { _name = value; + RaisePropertyChangedAuto(); + } + } + protected Double _length; + /// + /// Gets or sets the length. + /// + public Double Length + { + get + { + return Segments.Count == 0 ? 0 : Segments.ToList().Sum(x=>x.Length); + } + set + { + if (_length != value) + { + _length = value; + RaisePropertyChangedAuto(); + } + } + } + + public bool IsGroupSegment + { + get + { + return true; + } + } + + private bool _isSelected; + + public bool IsSelected + { + get { return _isSelected; } + set + { + _isSelected = value; + Segments.ToList().ForEach(x => x.IsSelected = value); + RaisePropertyChangedAuto(); + } + } + + public bool IsLast { get; set; } + public Int32 SegmentIndex { + get { + return Segments.Count == 0 ? 0 : Segments.ToList().OrderBy(x => x.SegmentIndex).Select(x => x.SegmentIndex).FirstOrDefault(); + } + set { } + } + public int FirstSegmentIndex { + get + { + return Segments.Count == 0 ? 0: Segments.ToList().Min(x => x.SegmentIndex); + } + } + + public int LastSegmentIndex { + get + { + return Segments.Count == 0 ? 0 : Segments.ToList().Max(x => x.SegmentIndex); + } + } + + public string DisplayIndexes + { + get + { + return String.Format($"(#{FirstSegmentIndex} - {LastSegmentIndex})"); + } + } + + public double InterSegmentLength + { + get + { + return Segments.Count == 0 ? 0 : Segments.ToList().Select(x => x.InterSegmentLength).FirstOrDefault(); + } + } + + #endregion + + public SegmentsGroupModel(List selectedSegments) + { + Segments = selectedSegments.ToObservableCollection(); + Repeats = 1; + } + + public SegmentsGroupModel() + { + Segments = new ObservableCollection(); + Repeats = 1; + } + } +} 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 8d90aabb2..861273ccf 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 @@ -261,6 +261,7 @@ SpoolChangeView.xaml + @@ -268,8 +269,10 @@ + + @@ -296,14 +299,17 @@ + + + @@ -643,7 +649,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs index 35d1629e0..4fb36e379 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/AddBrushStopCommand.cs @@ -61,6 +61,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands { _jobModel.Segments.Insert(_segment.SegmentIndex, _createdNewSegment); } + _jobModel.LoadGroupingSegments(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DeleteSegmentsGroupCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DeleteSegmentsGroupCommand.cs new file mode 100644 index 000000000..83536825b --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DeleteSegmentsGroupCommand.cs @@ -0,0 +1,48 @@ +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.UndoRedoCommands +{ + public class DeleteSegmentsGroupCommand : IUndoRedoCommand + { + private JobModel _jobModel; + private SegmentsGroupModel _segmentsGroup; + + public DeleteSegmentsGroupCommand(JobModel job, SegmentsGroupModel segmentsGroup) + { + _jobModel = job; + _segmentsGroup = segmentsGroup; + } + + public void Execute() + { + foreach (var obj in _segmentsGroup.Segments) + { + _jobModel.Segments.Remove(obj); + } + _jobModel.GroupingSegments.Remove(_segmentsGroup); + _jobModel.LoadGroupingSegments(); + } + + public void UnExecute() + { + int firstIndex = _segmentsGroup.FirstSegmentIndex; + foreach (var obj in _segmentsGroup.Segments) + { + if (_jobModel.Segments.Count < firstIndex) + _jobModel.Segments.Add(obj); + else + { + _jobModel.Segments.Insert((firstIndex-1), obj); + firstIndex++; + } + } + _jobModel.LoadGroupingSegments(); + } + + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DuplicateSegmentCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DuplicateSegmentCommand.cs index 24a82d2a4..cd8d46763 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DuplicateSegmentCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/DuplicateSegmentCommand.cs @@ -28,11 +28,13 @@ namespace Tango.PPC.Jobs.UndoRedoCommands { _jobModel.Segments.Insert(_copySegment.SegmentIndex-1, _copySegment); } + _jobModel.LoadGroupingSegments(); } public void UnExecute() { _jobModel.Segments.Remove(_copySegment); + _jobModel.LoadGroupingSegments(); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/PasteSegmentsCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/PasteSegmentsCommand.cs index 4d9915449..73bcf3f22 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/PasteSegmentsCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/PasteSegmentsCommand.cs @@ -45,6 +45,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands _jobModel.Segments.Insert(selctedIndex, newSegmentModel); } } + _jobModel.LoadGroupingSegments(); _jobModel.SegmentsToCopy.Clear(); } @@ -54,6 +55,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands { _jobModel.Segments.Remove(segment); } + _jobModel.LoadGroupingSegments(); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentCommand.cs index 90ef92924..677ffc8dc 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentCommand.cs @@ -23,6 +23,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands public void Execute() { _jobModel.Segments.Remove(_removedSegment); + _jobModel.LoadGroupingSegments(); } public void UnExecute() @@ -33,6 +34,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands { _jobModel.Segments.Insert(_index, _removedSegment); } + _jobModel.LoadGroupingSegments(); } } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentsCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentsCommand.cs index db44f176c..0ac2a9fc6 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentsCommand.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RemoveSegmentsCommand.cs @@ -24,6 +24,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands { _jobModel.Segments.Remove(obj.Value); } + _jobModel.LoadGroupingSegments(); } public void UnExecute() @@ -37,6 +38,7 @@ namespace Tango.PPC.Jobs.UndoRedoCommands _jobModel.Segments.Insert(obj.Key, obj.Value); } } + _jobModel.LoadGroupingSegments(); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RepeatCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RepeatCommand.cs new file mode 100644 index 000000000..6ad0f95cc --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/RepeatCommand.cs @@ -0,0 +1,54 @@ +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.UndoRedoCommands +{ + public class RepeatCommand : IUndoRedoCommand + { + private JobModel _jobModel; + private List _selectedSegments; + + public RepeatCommand(JobModel job) + { + _jobModel = job; + + _selectedSegments = new List(); + for (int index = 0; index < _jobModel.Segments.Count; index++) + { + var segment = _jobModel.Segments[index]; + if (segment.IsSelected && false == segment.IsGroupSegment) + { + _selectedSegments.Add(segment); + } + else if (_selectedSegments.Count > 0) + { + break; + } + } + } + + public void Execute() + { + if (_selectedSegments.Count == 0) + return; + _jobModel.LastNewGroupID++; + SegmentsGroupModel group = new SegmentsGroupModel(_selectedSegments) { GroupID = _jobModel.LastNewGroupID }; + _selectedSegments.ForEach(x => { x.SegmentsGroupModel = group; x.IsSelected = false; }); + + _jobModel.LoadGroupingSegments(); + } + + public void UnExecute() + { + if (_selectedSegments.Count == 0) + return; + _selectedSegments.ForEach(x => { x.SegmentsGroupModel = null; }); + _jobModel.LastNewGroupID--; + _jobModel.LoadGroupingSegments(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UnGroupSegmentsCommand.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UnGroupSegmentsCommand.cs new file mode 100644 index 000000000..b42dda221 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/UndoRedoCommands/UnGroupSegmentsCommand.cs @@ -0,0 +1,31 @@ +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.UndoRedoCommands +{ + public class UnGroupSegmentsCommand : IUndoRedoCommand + { + private JobModel _jobModel; + private SegmentsGroupModel _segmentsGroupModel; + public UnGroupSegmentsCommand(JobModel jobModel, SegmentsGroupModel segmentsGroup) + { + _jobModel = jobModel; + _segmentsGroupModel = segmentsGroup; + } + public void Execute() + { + _segmentsGroupModel.Segments.ToList().ForEach(x => x.SegmentsGroupModel = null); + _jobModel.LoadGroupingSegments(); + } + + public void UnExecute() + { + _segmentsGroupModel.Segments.ToList().ForEach(x => x.SegmentsGroupModel = _segmentsGroupModel); + _jobModel.LoadGroupingSegments(); + } + } +} 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 d00cf14fd..0ffc65fc0 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 @@ -237,13 +237,7 @@ namespace Tango.PPC.Jobs.ViewModels /// Gets or sets the add solid segment command. /// public RelayCommand AddNewSegmentCommand { get; set; } - - /// - /// Gets or sets the undo last color command. - /// - public RelayCommand UndoLastColorCommand { get; set; } - - + /// /// Gets or sets the remove segment command. /// @@ -268,18 +262,12 @@ namespace Tango.PPC.Jobs.ViewModels /// Gets or sets the replace brush stop command. /// public RelayCommand ReplaceBrushStopCommand { get; set; } - - /// - /// Gets or sets the twine catalog field tap command. - /// - //public RelayCommand OpenCatalogCommand { get; set; } - + /// /// Gets or sets the dye command. /// public RelayCommand DyeCommand { get; set; } - - + /// /// Gets or sets the export embroidery command. /// @@ -291,26 +279,22 @@ namespace Tango.PPC.Jobs.ViewModels public RelayCommand JobModeSwitchCommand { get; set; } + public RelayCommand UngroupSegmentsCommand { get; set; } + public RelayCommand DeleteSegmentsGroupCommand { get; set; } + #endregion #region collapsed mode commands public RelayCommand InsertWhiteGapCommand { get; set; } - public RelayCommand ReverseCommand { get; set; } - public RelayCommand DeleteSegmentCommand { get; set; } - public RelayCommand RepeateSegmentCommand { get; set; } - public RelayCommand PasteCommand { get; set; } - public RelayCommand CopyCommand { get; set; } - public RelayCommand UndoCommand { get; set; } - public RelayCommand RedoCommand { get; set; } - + #endregion #region Constructors @@ -351,7 +335,6 @@ namespace Tango.PPC.Jobs.ViewModels //Initialize Commands AddNewSegmentCommand = new RelayCommand(AddNewSegment); - UndoLastColorCommand = new RelayCommand(UndoLastColor); RemoveSegmentCommand = new RelayCommand(RemoveSegment); DuplicateSegmentCommand = new RelayCommand(DuplicateSegment); @@ -368,7 +351,9 @@ namespace Tango.PPC.Jobs.ViewModels InsertWhiteGapCommand = new RelayCommand(InsertWhiteGap); ReverseCommand = new RelayCommand(Reverse); DeleteSegmentCommand = new RelayCommand(DeleteSegments); + DeleteSegmentsGroupCommand = new RelayCommand(DeleteSegmentsGroup); RepeateSegmentCommand = new RelayCommand(RepeateSegments); + UngroupSegmentsCommand = new RelayCommand(UngroupSegments); PasteCommand = new RelayCommand(Paste); CopyCommand = new RelayCommand(Copy); UndoCommand = new RelayCommand(Undo);//(x) => { return UndoRedoManager.Instance.IsEnableUndoOperation(); } @@ -479,16 +464,16 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log($"Job editing state = '{Job.JobEditingState}'."); - if (Job.JobEditingState == BL.Enumerations.EditingStates.SampleDye && Job.JobSampleDyeStatus == BL.Enumerations.SampleDyeStatuses.PendingApproval) - { - LogManager.Log("Directing view to display sample dye region."); - View.DisplaySampleDye(); - } - else if (Job.JobEditingState == BL.Enumerations.EditingStates.FineTuning && Job.JobFineTuningStatus == BL.Enumerations.FineTuningStatuses.PendingApproval) - { - LogManager.Log("Directing view to display fine tuning region."); - View.DisplayFineTuning(); - } + //if (Job.JobEditingState == BL.Enumerations.EditingStates.SampleDye && Job.JobSampleDyeStatus == BL.Enumerations.SampleDyeStatuses.PendingApproval) + //{ + // LogManager.Log("Directing view to display sample dye region."); + // View.DisplaySampleDye(); + //} + //else if (Job.JobEditingState == BL.Enumerations.EditingStates.FineTuning && Job.JobFineTuningStatus == BL.Enumerations.FineTuningStatuses.PendingApproval) + //{ + // LogManager.Log("Directing view to display fine tuning region."); + // View.DisplayFineTuning(); + //} IsFullMode = true; DyeCommand.RaiseCanExecuteChanged(); @@ -522,7 +507,7 @@ namespace Tango.PPC.Jobs.ViewModels User = Job.User, Machine = Job.Machine }; - + Dictionary guidToGroup = new Dictionary(); foreach (var segm in Job.Segments) { if (Job.Version == 1 && segm.BrushStops.Count > 1) @@ -565,6 +550,22 @@ namespace Tango.PPC.Jobs.ViewModels IsInterSegment = segm.IsInterSegment, Job = jobModel, }; + if(segm.SegmentsGroupGuid != null) + { + SegmentsGroupModel segmentsGroupModel; + if(guidToGroup.TryGetValue(segm.SegmentsGroupGuid, out segmentsGroupModel)) + { + segmentsGroupModel.Segments.Add(segmentModel); + segmentModel.SegmentsGroupModel = segmentsGroupModel; + } + else + { + segmentsGroupModel = new SegmentsGroupModel() { GroupID = segm.SegmentsGroup.GroupIndex, Repeats = segm.SegmentsGroup.Repeats }; + guidToGroup[segm.SegmentsGroupGuid] = segmentsGroupModel; + segmentsGroupModel.Segments.Add(segmentModel); + segmentModel.SegmentsGroupModel = segmentsGroupModel; + } + } foreach (var brushStop in segm.BrushStops) { BrushStopModel brushStopModel = new BrushStopModel(brushStop, segmentModel, Job.Version); @@ -575,14 +576,16 @@ namespace Tango.PPC.Jobs.ViewModels jobModel.Segments.Add(segmentModel); } } + jobModel.InterSegmentLength = Job.EnableInterSegment ? Job.InterSegmentLength : 0; jobModel.Segments.Last().IsLast = true; + jobModel.LoadGroupingSegments(); JobModel = jobModel; - SegmentsCollectionView = CollectionViewSource.GetDefaultView(JobModel.Segments); + //create grouping + SegmentsCollectionView = CollectionViewSource.GetDefaultView(JobModel.GroupingSegments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(SegmentModel.SegmentIndex), ListSortDirection.Ascending)); UndoRedoManager.Instance.ClearAll(); - } private void Job_NameChanged(object sender, string e) @@ -701,12 +704,10 @@ namespace Tango.PPC.Jobs.ViewModels { var maxLength = Job.SpoolType.Length; var maxRep = (maxLength == 0 ? 999 : (maxLength / JobModel.Length)); - - - var vm = await NotificationProvider.ShowDialog(new RepeatJobViewVM() + + var vm = await NotificationProvider.ShowDialog(new RepeatJobViewVM("Repeat All", JobModel.NumberOfUnits) { - MaxRepeations = (int)maxRep, - Repeats = JobModel.NumberOfUnits + MaxRepeations = (int)maxRep }); if (vm.DialogResult) @@ -805,13 +806,21 @@ namespace Tango.PPC.Jobs.ViewModels NotificationProvider.ShowError("An error occurred while trying to add a new segment."); } } - - /// - /// Undoes the last color. - /// - private void UndoLastColor(SegmentModel segment) + + private async void RepeatSegmentsGroup( SegmentsGroupModel group) { + var maxLength = 999; + var maxRep = (maxLength == 0 ? 999 : (maxLength / JobModel.Length)); + + var vm = await NotificationProvider.ShowDialog(new RepeatJobViewVM($"Edit \"Group {group.GroupID}\" Repeat", group.Repeats) + { + MaxRepeations = (int)maxRep + }); + if (vm.DialogResult) + { + JobModel.NumberOfUnits = vm.Repeats; + } } /// @@ -843,7 +852,32 @@ namespace Tango.PPC.Jobs.ViewModels } } + private async void DeleteSegmentsGroup(SegmentsGroupModel segmentsGroup) + { + if (JobModel.GroupingSegments.Count > 1) + { + try + { + if (await NotificationProvider.ShowQuestion("Are you sure you want to remove the selected group of segments?")) + { + + UndoRedoManager.Instance.InsertAndExecuteCommand(new DeleteSegmentsGroupCommand(JobModel, segmentsGroup)); + ArrangeSegmentsIndixes(); + DyeCommand.RaiseCanExecuteChanged(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not remove group of segments."); + await NotificationProvider.ShowError("An error occurred while trying to delete group of segments."); + } + } + else + { + await NotificationProvider.ShowInfo("A job must contain at least one color segment."); + } + } /// /// Duplicates the segment. /// @@ -1186,7 +1220,14 @@ namespace Tango.PPC.Jobs.ViewModels private void RepeateSegments() { + if ( (JobModel.Segments.ToList().Where(x => x.IsSelected).Count()) < 2) + return; + UndoRedoManager.Instance.InsertAndExecuteCommand(new RepeatCommand(JobModel)); + } + private void UngroupSegments(SegmentsGroupModel segmentsGroup) + { + UndoRedoManager.Instance.InsertAndExecuteCommand(new UnGroupSegmentsCommand(JobModel, segmentsGroup)); } private void Paste() @@ -1240,12 +1281,17 @@ namespace Tango.PPC.Jobs.ViewModels { _db.BrushStops.Remove(x); }); - + if(segment.SegmentsGroupGuid != null) + { + _db.SegmentsGroups.Remove(segment.SegmentsGroup); + } _db.Segments.Remove(segment); } - + Job.Segments.Clear(); - + + Dictionary groupIDToSegmentsGroupGuid = new Dictionary(); + foreach (var segment in JobModel.Segments.OrderBy(x => x.SegmentIndex).ToList()) { var dbSegment = new Segment(); @@ -1255,7 +1301,24 @@ namespace Tango.PPC.Jobs.ViewModels dbSegment.Job = Job; dbSegment.SegmentIndex = segment.SegmentIndex; dbSegment.Length = segment.Length; - + if(segment.IsGroupSegment) + { + SegmentsGroup dbSegmentsGroup; + if (false == groupIDToSegmentsGroupGuid.TryGetValue(segment.SegmentsGroupModel.GroupID, out dbSegmentsGroup)) + { + dbSegmentsGroup = new SegmentsGroup(); + dbSegmentsGroup.Guid = System.Guid.NewGuid().ToString(); + dbSegmentsGroup.Repeats = segment.SegmentsGroupModel.Repeats; + dbSegmentsGroup.GroupIndex = segment.SegmentsGroupModel.GroupID; + _db.SegmentsGroups.Add(dbSegmentsGroup); + dbSegment.SegmentsGroup = dbSegmentsGroup; + groupIDToSegmentsGroupGuid[segment.SegmentsGroupModel.GroupID] = dbSegmentsGroup; + } + else + { + dbSegment.SegmentsGroup = dbSegmentsGroup; + } + } _db.Segments.Add(dbSegment); foreach (var stop in segment.BrushStops.OrderBy(x => x.StopIndex).ToList()) 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 2e3884479..2f3646f9f 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 @@ -4,6 +4,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="clr-namespace:Tango.PPC.Jobs.ViewModels" + xmlns:model="clr-namespace:Tango.PPC.Jobs.Models" + xmlns:helpers="clr-namespace:Tango.PPC.Jobs.Helpers" xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:keyboard="clr-namespace:Tango.Touch.Keyboard;assembly=Tango.Touch" @@ -196,7 +198,7 @@ - + @@ -401,7 +403,152 @@ - + + + + + + + + + + + + + + + + + + + + + + + + Group + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Grouped + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Delete Gap + + + + + + + Add Gap + + + + + + + + + Add New Segments + + + + + + + + + + + + @@ -463,6 +610,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + Group + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Grouped + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -537,7 +803,7 @@ - + Repeat @@ -626,12 +892,12 @@ - - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs index 2897604a0..0f1a868a4 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/JobBuilder.cs @@ -31,7 +31,7 @@ namespace Tango.BL.Builders { return AddStep(1, () => { - Context.Segments.Where(x => x.JobGuid == Entity.Guid).OrderBy(x => x.SegmentIndex).ToList(); + Context.Segments.Where(x => x.JobGuid == Entity.Guid).Include(x => x.SegmentsGroup).OrderBy(x => x.SegmentIndex).ToList(); }); } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SegmentDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/SegmentDTOBase.cs index fba251a63..170b28539 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SegmentDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SegmentDTOBase.cs @@ -53,5 +53,13 @@ namespace Tango.BL.DTO get; set; } + /// + /// segments group guid + /// + public String SegmentsGroupGuid + { + get; set; + } + } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTO.cs new file mode 100644 index 000000000..3e1c3d339 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTO.cs @@ -0,0 +1,14 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BL.DTO +{ + public class SegmentsGroupDTO : SegmentsGroupDTOBase + { + + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTOBase.cs new file mode 100644 index 000000000..adbf8a2a0 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/DTO/SegmentsGroupDTOBase.cs @@ -0,0 +1,41 @@ + +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.BL.DTO +{ + public abstract class SegmentsGroupDTOBase : ObservableEntityDTO + { + + /// + /// group index + /// + public Int32 GroupIndex + { + get; set; + } + + /// + /// repeats + /// + public Int32 Repeats + { + get; set; + } + + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/SegmentBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SegmentBase.cs index f98239bf3..0ded51862 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SegmentBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SegmentBase.cs @@ -37,6 +37,8 @@ namespace Tango.BL.Entities public event EventHandler JobChanged; + public event EventHandler SegmentsGroupChanged; + protected String _name; /// @@ -144,6 +146,32 @@ namespace Tango.BL.Entities } } + protected String _segmentsgroupguid; + + /// + /// Gets or sets the segmentbase segments group guid. + /// + + [Column("SEGMENTS_GROUP_GUID")] + [ForeignKey("SegmentsGroup")] + + public String SegmentsGroupGuid + { + get + { + return _segmentsgroupguid; + } + + set + { + if (_segmentsgroupguid != value) + { + _segmentsgroupguid = value; + + } + } + } + protected SynchronizedObservableCollection _brushstops; /// @@ -201,6 +229,38 @@ namespace Tango.BL.Entities } } + protected SegmentsGroup _segmentsgroup; + + /// + /// Gets or sets the segmentbase segments groups. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual SegmentsGroup SegmentsGroup + { + get + { + return _segmentsgroup; + } + + set + { + if (_segmentsgroup != value) + { + _segmentsgroup = value; + + if (SegmentsGroup != null) + { + SegmentsGroupGuid = SegmentsGroup.Guid; + } + + OnSegmentsGroupChanged(value); + + } + } + } + /// /// Called when the Name has changed. /// @@ -246,6 +306,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Job)); } + /// + /// Called when the SegmentsGroup has changed. + /// + protected virtual void OnSegmentsGroupChanged(SegmentsGroup segmentsgroup) + { + SegmentsGroupChanged?.Invoke(this, segmentsgroup); + RaisePropertyChanged(nameof(SegmentsGroup)); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroup.cs b/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroup.cs new file mode 100644 index 000000000..9da3d36ed --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroup.cs @@ -0,0 +1,16 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +namespace Tango.BL.Entities +{ + public class SegmentsGroup: SegmentsGroupBase + { + } +} \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroupBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroupBase.cs new file mode 100644 index 000000000..4879643f2 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Entities/SegmentsGroupBase.cs @@ -0,0 +1,152 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Tango Observables Generator +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. Do not modify! +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Xml.Serialization; +using Newtonsoft.Json; +using System.Linq; +using Tango.DAL.Remote.DB; +using Tango.Core; +using System.ComponentModel; +using Tango.Core.CustomAttributes; + +namespace Tango.BL.Entities +{ + [Table("SEGMENTS_GROUPS")] + public abstract class SegmentsGroupBase : ObservableEntity + { + + public event EventHandler GroupIndexChanged; + + public event EventHandler RepeatsChanged; + + public event EventHandler> SegmentsChanged; + + protected Int32 _groupindex; + + /// + /// Gets or sets the segmentsgroupbase group index. + /// + + [Column("GROUP_INDEX")] + + public Int32 GroupIndex + { + get + { + return _groupindex; + } + + set + { + if (_groupindex != value) + { + _groupindex = value; + + OnGroupIndexChanged(value); + + } + } + } + + protected Int32 _repeats; + + /// + /// Gets or sets the segmentsgroupbase repeats. + /// + + [Column("REPEATS")] + + public Int32 Repeats + { + get + { + return _repeats; + } + + set + { + if (_repeats != value) + { + _repeats = value; + + OnRepeatsChanged(value); + + } + } + } + + protected SynchronizedObservableCollection _segments; + + /// + /// Gets or sets the segmentsgroupbase segments. + /// + + public virtual SynchronizedObservableCollection Segments + { + get + { + return _segments; + } + + set + { + if (_segments != value) + { + _segments = value; + + OnSegmentsChanged(value); + + } + } + } + + /// + /// Called when the GroupIndex has changed. + /// + protected virtual void OnGroupIndexChanged(Int32 groupindex) + { + GroupIndexChanged?.Invoke(this, groupindex); + RaisePropertyChanged(nameof(GroupIndex)); + } + + /// + /// Called when the Repeats has changed. + /// + protected virtual void OnRepeatsChanged(Int32 repeats) + { + RepeatsChanged?.Invoke(this, repeats); + RaisePropertyChanged(nameof(Repeats)); + } + + /// + /// Called when the Segments has changed. + /// + protected virtual void OnSegmentsChanged(SynchronizedObservableCollection segments) + { + SegmentsChanged?.Invoke(this, segments); + RaisePropertyChanged(nameof(Segments)); + } + + /// + /// Initializes a new instance of the class. + /// + public SegmentsGroupBase() : base() + { + + Segments = new SynchronizedObservableCollection(); + + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs index a799d7860..7cd312f16 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesContext.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesContext.cs @@ -750,6 +750,14 @@ namespace Tango.BL get; set; } + /// + /// Gets or sets the SegmentsGroups. + /// + public DbSet SegmentsGroups + { + get; set; + } + /// /// Gets or sets the Sites. /// diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs index c15da9c18..f3e7a2a2b 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapterExtension.cs @@ -3293,6 +3293,42 @@ namespace Tango.BL } + private ObservableCollection _segmentsgroups; + /// + /// Gets or sets the SegmentsGroups. + /// + public ObservableCollection SegmentsGroups + { + get + { + return _segmentsgroups; + } + + set + { + _segmentsgroups = value; RaisePropertyChanged(nameof(SegmentsGroups)); + } + + } + + private ICollectionView _segmentsgroupsViewSource; + /// + /// Gets or sets the SegmentsGroups View Source. + /// + public ICollectionView SegmentsGroupsViewSource + { + get + { + return _segmentsgroupsViewSource; + } + + set + { + _segmentsgroupsViewSource = value; RaisePropertyChanged(nameof(SegmentsGroupsViewSource)); + } + + } + private ObservableCollection _sites; /// /// Gets or sets the Sites. @@ -4129,6 +4165,8 @@ namespace Tango.BL SegmentsViewSource = CreateCollectionView(Segments); + SegmentsGroupsViewSource = CreateCollectionView(SegmentsGroups); + SitesViewSource = CreateCollectionView(Sites); SitesCatalogsViewSource = CreateCollectionView(SitesCatalogs); diff --git a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs index 8cf9ef0f2..dc43b9b2b 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesStaticCollectionsExtension.cs @@ -3293,6 +3293,42 @@ namespace Tango.BL } + private ObservableCollection _segmentsgroups; + /// + /// Gets or sets the SegmentsGroups. + /// + public ObservableCollection SegmentsGroups + { + get + { + return _segmentsgroups; + } + + set + { + _segmentsgroups = value; RaisePropertyChanged(nameof(SegmentsGroups)); + } + + } + + private ICollectionView _segmentsgroupsViewSource; + /// + /// Gets or sets the SegmentsGroups View Source. + /// + public ICollectionView SegmentsGroupsViewSource + { + get + { + return _segmentsgroupsViewSource; + } + + set + { + _segmentsgroupsViewSource = value; RaisePropertyChanged(nameof(SegmentsGroupsViewSource)); + } + + } + private ObservableCollection _sites; /// /// Gets or sets the Sites. @@ -4129,6 +4165,8 @@ namespace Tango.BL SegmentsViewSource = CreateCollectionView(Segments); + SegmentsGroupsViewSource = CreateCollectionView(SegmentsGroups); + SitesViewSource = CreateCollectionView(Sites); SitesCatalogsViewSource = CreateCollectionView(SitesCatalogs); diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index baefab542..2500c3370 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -301,6 +301,8 @@ + + @@ -468,6 +470,8 @@ + + @@ -771,7 +775,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs index 0b51ddbda..181893358 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Context.cs @@ -116,6 +116,7 @@ namespace Tango.DAL.Remote.DB public virtual DbSet ROLES_PERMISSIONS { get; set; } public virtual DbSet RUBBING_RESULTS { get; set; } public virtual DbSet SEGMENTS { get; set; } + public virtual DbSet SEGMENTS_GROUPS { get; set; } public virtual DbSet SITES { get; set; } public virtual DbSet SITES_CATALOGS { get; set; } public virtual DbSet SITES_RMLS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs index d26e67908..b9a889afd 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'C:\DATA\Development\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. +// T4 code generation is enabled for model 'C:\TFS\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 8e4a49e8f..973d3f8b5 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1287,6 +1287,17 @@ + + + + + + + + + + + @@ -2904,6 +2915,18 @@ + + + + + + + + + + + + @@ -3209,6 +3232,7 @@ + @@ -3624,6 +3648,10 @@ + + + + @@ -3849,6 +3877,7 @@ + @@ -4231,6 +4260,10 @@ + + + + @@ -4360,7 +4393,7 @@ - + @@ -6049,8 +6082,21 @@ + + + + + + + + + + + + + @@ -7515,6 +7561,18 @@ + + + + + + + + + + + + @@ -9105,6 +9163,7 @@ + @@ -9115,6 +9174,17 @@ + + + + + + + + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index cc936cddc..af6feda16 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,97 +5,98 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -182,6 +183,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENT.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENT.cs index 206092a13..e2fdfa732 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENT.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENT.cs @@ -27,9 +27,11 @@ namespace Tango.DAL.Remote.DB public string JOB_GUID { get; set; } public double LENGTH { get; set; } public int SEGMENT_INDEX { get; set; } + public string SEGMENTS_GROUP_GUID { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection BRUSH_STOPS { get; set; } public virtual JOB JOB { get; set; } + public virtual SEGMENTS_GROUPS SEGMENTS_GROUPS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENTS_GROUPS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENTS_GROUPS.cs new file mode 100644 index 000000000..9da1ce490 --- /dev/null +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SEGMENTS_GROUPS.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.DAL.Remote.DB +{ + using System; + using System.Collections.Generic; + + public partial class SEGMENTS_GROUPS + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public SEGMENTS_GROUPS() + { + this.SEGMENTS = new HashSet(); + } + + public int ID { get; set; } + public string GUID { get; set; } + public System.DateTime LAST_UPDATED { get; set; } + public int GROUP_INDEX { get; set; } + public int REPEATS { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SEGMENTS { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj index 8a7ccc017..1a15767d6 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj +++ b/Software/Visual_Studio/Tango.DAL.Remote/Tango.DAL.Remote.csproj @@ -315,6 +315,9 @@ RemoteADO.tt + + RemoteADO.tt + RemoteADO.tt @@ -458,7 +461,7 @@ - + \ No newline at end of file -- cgit v1.3.1