diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-02-16 19:15:31 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-02-16 19:15:31 +0200 |
| commit | 3681ab681f02bbb7cda89de4044fd69bc9d61ab8 (patch) | |
| tree | 837fb7c294755af6d4efd551e872b527d14fc2ff /Software/Visual_Studio/PPC/Modules | |
| parent | 00eaafb1c13f72dd489edb49a0aa7f6e4c79fdb2 (diff) | |
| download | Tango-3681ab681f02bbb7cda89de4044fd69bc9d61ab8.tar.gz Tango-3681ab681f02bbb7cda89de4044fd69bc9d61ab8.zip | |
PPC. Create Segments Groups.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
19 files changed, 820 insertions, 80 deletions
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}"> <Border BorderBrush="{StaticResource TangoMidAccentBrush}" Margin="-24" CornerRadius="40" BorderThickness="2" Background="{StaticResource TangoPrimaryBackgroundBrush}"> @@ -21,7 +21,7 @@ <touch:TouchIconButton DockPanel.Dock="Right" VerticalAlignment="Center" Height="28" Command="{Binding CloseCommand}" Icon="CloseCircleOutline" RippleBrush="{StaticResource TangoRippleDarkBrush}" Foreground="{StaticResource TangoDarkForegroundBrush}" HorizontalAlignment="Right" /> </DockPanel> - <TextBlock Grid.Row="1" Height="26" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" FontWeight="SemiBold" HorizontalAlignment="Center"> Repeat All</TextBlock> + <TextBlock Grid.Row="1" Height="26" FontSize="{StaticResource TangoMessageBoxButtonFontSize}" FontWeight="SemiBold" HorizontalAlignment="Center" Text="{Binding HeaderName}"></TextBlock> <StackPanel Margin="0 20 0 0" Grid.Row="2" Width="302" VerticalAlignment="Center" HorizontalAlignment="Center"> <touch:TouchNumericUpDownConrol Margin="0 0 0 0" Width="Auto" Value="{Binding Repeats, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" BorderThickness="0" MaxValue="{Binding MaxRepeations, Mode=OneWay}" MinValue="1" Style="{StaticResource TouchNumericMiddleUpDownControl}"/> 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<ISegmentModel> _groupingSegments; + /// <summary> + /// Gets or sets the display segments. + /// </summary> + public ObservableCollection<ISegmentModel> 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<ColorSpace> list) { ColorSpacesList = list; - Segments = new SynchronizedObservableCollection<SegmentModel>(); + _segments = new SynchronizedObservableCollection<SegmentModel>(); + _groupingSegments = new ObservableCollection<ISegmentModel>(); SegmentsToCopy = new List<SegmentModel>(); 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<SegmentsGroupModel> + Dictionary<int, SegmentsGroupModel> groupIDToSegmentsGroup = new Dictionary<int, SegmentsGroupModel>(); + 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)); } - + /// <summary> /// Handles the PropertyChanged event of all job segments. /// </summary> @@ -513,6 +566,7 @@ namespace Tango.PPC.Jobs.Models RaisePropertyChanged(nameof(HasSelectedItems)); } } + /// <summary> /// Called when the <see cref="Length"/> 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; /// <summary> /// 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<SegmentModel> 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; + /// <summary> + /// Gets or sets the length. + /// </summary> + 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<SegmentModel> selectedSegments) + { + Segments = selectedSegments.ToObservableCollection(); + Repeats = 1; + } + + public SegmentsGroupModel() + { + Segments = new ObservableCollection<SegmentModel>(); + 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 @@ <DependentUpon>SpoolChangeView.xaml</DependentUpon> </Compile> <Compile Include="Dialogs\SpoolChangeViewVM.cs" /> + <Compile Include="Helpers\GroupSegmentTemplateSelector.cs" /> <Compile Include="JobsV2Module.cs" /> <Compile Include="JobsModuleSettings.cs" /> <Compile Include="Messages\JobSelectedMessage.cs" /> @@ -268,8 +269,10 @@ <Compile Include="Models\BrushStopModel.cs" /> <Compile Include="Models\ColorLibrary.cs" /> <Compile Include="Models\FavoriteColor.cs" /> + <Compile Include="Models\ISegmentModel.cs" /> <Compile Include="Models\JobModel.cs" /> <Compile Include="Models\SegmentModel.cs" /> + <Compile Include="Models\SegmentsGroupModel.cs" /> <Compile Include="MyColors\MyColorsEngine.cs" /> <Compile Include="NavigationObjects\JobNavigationObject.cs" /> <Compile Include="NavigationObjects\JobSummeryNavigationObject.cs" /> @@ -296,14 +299,17 @@ <Compile Include="UndoRedoCommands\ChangeLengthCommand.cs" /> <Compile Include="UndoRedoCommands\ChangeOffsetCommand.cs" /> <Compile Include="UndoRedoCommands\CopySegmentCommand.cs" /> + <Compile Include="UndoRedoCommands\DeleteSegmentsGroupCommand.cs" /> <Compile Include="UndoRedoCommands\DuplicateSegmentCommand.cs" /> <Compile Include="UndoRedoCommands\EditBrushStopColorCommand.cs" /> <Compile Include="UndoRedoCommands\IUndoRedoCommand.cs" /> <Compile Include="UndoRedoCommands\PasteSegmentsCommand.cs" /> <Compile Include="UndoRedoCommands\RemoveSegmentCommand.cs" /> <Compile Include="UndoRedoCommands\RemoveSegmentsCommand.cs" /> + <Compile Include="UndoRedoCommands\RepeatCommand.cs" /> <Compile Include="UndoRedoCommands\ReverseCommand.cs" /> <Compile Include="UndoRedoCommands\UndoRedoManager.cs" /> + <Compile Include="UndoRedoCommands\UnGroupSegmentsCommand.cs" /> <Compile Include="ViewContracts\IJobsView.cs" /> <Compile Include="ViewContracts\IJobView.cs" /> <Compile Include="ViewModelLocator.cs" /> @@ -643,7 +649,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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<SegmentModel> _selectedSegments; + + public RepeatCommand(JobModel job) + { + _jobModel = job; + + _selectedSegments = new List<SegmentModel>(); + 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. /// </summary> public RelayCommand<Int32> AddNewSegmentCommand { get; set; } - - /// <summary> - /// Gets or sets the undo last color command. - /// </summary> - public RelayCommand<SegmentModel> UndoLastColorCommand { get; set; } - - + /// <summary> /// Gets or sets the remove segment command. /// </summary> @@ -268,18 +262,12 @@ namespace Tango.PPC.Jobs.ViewModels /// Gets or sets the replace brush stop command. /// </summary> public RelayCommand<BrushStop> ReplaceBrushStopCommand { get; set; } - - /// <summary> - /// Gets or sets the twine catalog field tap command. - /// </summary> - //public RelayCommand<BrushStop> OpenCatalogCommand { get; set; } - + /// <summary> /// Gets or sets the dye command. /// </summary> public RelayCommand DyeCommand { get; set; } - - + /// <summary> /// Gets or sets the export embroidery command. /// </summary> @@ -291,26 +279,22 @@ namespace Tango.PPC.Jobs.ViewModels public RelayCommand JobModeSwitchCommand { get; set; } + public RelayCommand<SegmentsGroupModel> UngroupSegmentsCommand { get; set; } + public RelayCommand<SegmentsGroupModel> 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<Int32>(AddNewSegment); - UndoLastColorCommand = new RelayCommand<SegmentModel>(UndoLastColor); RemoveSegmentCommand = new RelayCommand<SegmentModel>(RemoveSegment); DuplicateSegmentCommand = new RelayCommand<SegmentModel>(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<SegmentsGroupModel>(DeleteSegmentsGroup); RepeateSegmentCommand = new RelayCommand(RepeateSegments); + UngroupSegmentsCommand = new RelayCommand<SegmentsGroupModel>(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<string, SegmentsGroupModel> guidToGroup = new Dictionary<string, SegmentsGroupModel>(); 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<RepeatJobViewVM>(new RepeatJobViewVM() + + var vm = await NotificationProvider.ShowDialog<RepeatJobViewVM>(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."); } } - - /// <summary> - /// Undoes the last color. - /// </summary> - 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<RepeatJobViewVM>(new RepeatJobViewVM($"Edit \"Group {group.GroupID}\" Repeat", group.Repeats) + { + MaxRepeations = (int)maxRep + }); + if (vm.DialogResult) + { + JobModel.NumberOfUnits = vm.Repeats; + } } /// <summary> @@ -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."); + } + } /// <summary> /// Duplicates the segment. /// </summary> @@ -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<int, SegmentsGroup> groupIDToSegmentsGroupGuid = new Dictionary<int, SegmentsGroup>(); + 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 @@ </UniformGrid> </DataTemplate> - <DataTemplate x:Key="Segment_Template" DataType="{x:Type entities:Segment}"> + <DataTemplate x:Key="Segment_Template" DataType="{x:Type model:SegmentModel}"> <Grid Height="380" Margin="57 15 57 0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> @@ -401,7 +403,152 @@ </Grid> </DataTemplate> - <DataTemplate x:Key="CollapsedSegment_Template" DataType="{x:Type entities:Segment}"> + <DataTemplate x:Key="GroupSegment_Template" DataType="{x:Type model:SegmentsGroupModel}"> + <Grid Height="380" Margin="57 15 57 0"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="1*" /> + </Grid.RowDefinitions> + + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Height="60"> + <touch:TouchButton Background="Transparent" Foreground="{StaticResource TangoPrimaryAccentBrush}" EnableDropShadow="False" Command="{Binding ElementName=view,Path=DataContext.UngroupSegmentsCommand}" CommandParameter="{Binding}"> + <TextBlock FontSize="{StaticResource TangoButtonFontSize}" TextDecorations="Underline" Text="Ungroup" /> + </touch:TouchButton> + <touch:TouchButton Margin="20 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ElementName=view,Path=DataContext.DeleteSegmentsGroupCommand}" CommandParameter="{Binding}"> + <Border Height="24" Width="24" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/delete_segment.png"/> + </Border> + </touch:TouchButton> + <!--<touch:TouchButton Margin="20 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ElementName=view,Path=DataContext.DuplicateSegmentCommand}" CommandParameter="{Binding}"> + <Border Height="24" Width="24" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/duplicate.png"/> + </Border> + </touch:TouchButton>--> + </StackPanel> + <StackPanel Grid.Row="0" DockPanel.Dock="Left"> + <StackPanel Margin="0 0 0 0" Orientation="Horizontal" > + <TextBlock FontSize="{StaticResource TangoTitleFontSize}"> + <Run>Group </Run> + <Run Text="{Binding GroupID, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + <Run Text="{Binding DisplayIndexes, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + </TextBlock> + <touch:TouchButton Background="Transparent" Width="Auto" EnableDropShadow="False"> + <TextBlock Margin="10 0 0 0" Foreground="{StaticResource TangoPrimaryAccentBrush}" TextDecorations="Underline"> + <Run>x</Run> + <Run Text="{Binding Repeats, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + </TextBlock> + </touch:TouchButton> + </StackPanel> + <StackPanel Margin="0 0 0 0" Orientation="Horizontal"> + <controls:FastTextBlock VerticalAlignment="Bottom" DockPanel.Dock="Left" Text="Length (m):" FontSize="18"></controls:FastTextBlock> + <touch:TouchNumericTextBox Margin="20 0 0 0" Width="92" DockPanel.Dock="Right" Value="{Binding Length, UpdateSourceTrigger=LostFocus}" StringFormat="0.0" AutoCalculateJogStep="False" HasDecimalPoint="True" Minimum="1" Maximum="100000" KeyboardContainer="{Binding ElementName=Container}" FontSize="18" ValueChangedEnd="Length_ValueChanged" TextGotFocus="Length_BeforeChangeValue"/> + </StackPanel> + </StackPanel> + </DockPanel> + + <Border Grid.Row="1" x:Name="brush_border" Height="90" Margin="0 20 0 0" CornerRadius="20" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}"> + <Border.Clip> + <RectangleGeometry RadiusX="25" RadiusY="25"> + <RectangleGeometry.Rect> + <MultiBinding Converter="{StaticResource WidthHeightToRectConverter}"> + <Binding ElementName="brush_border" Path="ActualWidth" /> + <Binding ElementName="brush_border" Path="ActualHeight" /> + </MultiBinding> + </RectangleGeometry.Rect> + </RectangleGeometry> + </Border.Clip> + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <ItemsControl ClipToBounds="False" ItemsSource="{Binding Segments}" > + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" ClipToBounds="False"></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Grid> + <Grid.Width> + <MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}"> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="DataContext.Length"></Binding> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding> + <Binding Path="LengthWithInterSegment"></Binding> + </MultiBinding> + </Grid.Width> + <Rectangle Fill="{Binding SegmentBrush}"></Rectangle> + </Grid> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + + <Border Height="40" Width="151" Opacity="1" Background="#32787880" HorizontalAlignment="Center" CornerRadius="8" VerticalAlignment="Center"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoComboBoxItemFontSize}"> Grouped</TextBlock> + </Border> + </Grid> + + </Border> + <Grid Grid.Row="2" x:Name="add_new_segment_gap" HorizontalAlignment="Stretch" Margin="0 30 0 0" > + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Rectangle Stroke="{StaticResource TangoDividerBrush}" StrokeThickness="1" VerticalAlignment="Top" /> + + <Border x:Name="gapBorder" Margin="0 0 0 0" Height="24" ClipToBounds="False" CornerRadius="10" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityConverter}}"> + <Border.Clip> + <RectangleGeometry RadiusX="10" RadiusY="10"> + <RectangleGeometry.Rect> + <MultiBinding Converter="{StaticResource WidthHeightToRectConverter}"> + <Binding ElementName="gapBorder" Path="ActualWidth" /> + <Binding ElementName="gapBorder" Path="ActualHeight" /> + </MultiBinding> + </RectangleGeometry.Rect> + </RectangleGeometry> + </Border.Clip> + <Grid> + <TextBlock FontSize="{StaticResource TangoDefaultFontSize}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"> + <Run Text="{Binding InterSegmentLength, Mode=OneWay}"></Run> + <Run Text="m Gap"></Run> + </TextBlock> + <Rectangle Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="1" StrokeDashArray="5 5 5 5" RadiusX="12" RadiusY="12" /> + </Grid> + </Border> + + <DockPanel Margin="0 20 0 0" Grid.Row="1"> + <!--<Grid DockPanel.Dock="Right" Visibility="{Binding IsLast, Converter={StaticResource BooleanToVisibilityInverseConverter}}">--> + <Grid DockPanel.Dock="Right" Visibility="Collapsed"> + <touch:TouchButton x:Name="deletegap" DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding DeleteGapCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock Margin="10 2 0 0" FontSize="{StaticResource TangoButtonFontSize}" VerticalAlignment="Center">Delete Gap</TextBlock> + </touch:TouchButton> + <touch:TouchButton x:Name="addGap" DockPanel.Dock="Right" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding AddGapCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityInverseConverter}}"> + <StackPanel Orientation="Horizontal"> + <Border Height="35" Width="35" BorderThickness="0" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/add_gap.png"/> + </Border> + <TextBlock Margin="10 2 0 0" FontSize="{StaticResource TangoButtonFontSize}" VerticalAlignment="Center">Add Gap</TextBlock> + </StackPanel> + </touch:TouchButton> + </Grid> + <touch:TouchButton DockPanel.Dock="Left" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding DataContext.AddNewSegmentCommand, ElementName=listSegments}" CommandParameter="{Binding SegmentIndex}" EnableDropShadow="False" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" BorderThickness="0"> + <StackPanel Orientation="Horizontal"> + <Border Height="35" Width="35" BorderThickness="0" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/AddNewSegment.png"/> + </Border> + <TextBlock Margin="10 2 0 0" FontSize="{StaticResource TangoButtonFontSize}" VerticalAlignment="Center">Add New Segments</TextBlock> + </StackPanel> + </touch:TouchButton> + </DockPanel> + + <Rectangle Margin="0 10 0 0" Grid.Row="2" Stroke="{StaticResource TangoDividerBrush}" StrokeThickness="1" VerticalAlignment="Bottom"/> + </Grid> + + <Rectangle Margin="0 10 0 0" Grid.Row="2" Stroke="{StaticResource TangoDividerBrush}" StrokeThickness="1" VerticalAlignment="Bottom"/> + </Grid> + </DataTemplate> + + <DataTemplate x:Key="CollapsedSegment_Template" DataType="{x:Type model:SegmentModel}"> <Grid Height="180" Margin="57 15 57 0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> @@ -463,6 +610,125 @@ </Grid> </DataTemplate> + <DataTemplate x:Key="CollapsedGroupSegment_Template" DataType="{x:Type model:SegmentsGroupModel}"> + <Grid Height="180" Margin="57 15 57 0"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <DockPanel> + <Rectangle DockPanel.Dock="Top" Stroke="{StaticResource TangoDividerBrush}" StrokeThickness="1" VerticalAlignment="Top" Margin="0 0 0 10"/> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Height="40"> + <touch:TouchButton Background="Transparent" Foreground="{StaticResource TangoPrimaryAccentBrush}" EnableDropShadow="False" Command="{Binding ElementName=view,Path=DataContext.UngroupSegmentsCommand}" CommandParameter="{Binding}"> + <TextBlock FontSize="{StaticResource TangoButtonFontSize}" TextDecorations="Underline" Text="Ungroup" /> + </touch:TouchButton> + <touch:TouchButton Margin="10 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ElementName=view,Path=DataContext.DeleteSegmentsGroupCommand}" CommandParameter="{Binding}"> + <Border Height="24" Width="24" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/delete_segment.png"/> + </Border> + </touch:TouchButton> + <!--<touch:TouchButton Margin="20 0 0 0" VerticalAlignment="Center" EnableDropShadow="False" Background="Transparent" BorderThickness="0" Command="{Binding ElementName=view,Path=DataContext.DuplicateSegmentCommand}" CommandParameter="{Binding}"> + <Border Height="24" Width="24" BorderThickness="0" BorderBrush="{StaticResource TangoKeyboardKeyDarkBrush}" Background="Transparent" HorizontalAlignment="Left"> + <Image Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/duplicate.png"/> + </Border> + </touch:TouchButton>--> + </StackPanel> + <StackPanel DockPanel.Dock="Left"> + <StackPanel Margin="0 10 0 0" Orientation="Horizontal" > + <TextBlock FontSize="{StaticResource TangoTitleFontSize}"> + <Run>Group </Run> + <Run Text="{Binding GroupID, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + <Run Text="{Binding DisplayIndexes, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + </TextBlock> + <touch:TouchButton Margin="10 0 0 0" Background="Transparent" Width="Auto" EnableDropShadow="False"> + <TextBlock Foreground="{StaticResource TangoPrimaryAccentBrush}" TextDecorations="Underline"> + <Run>x</Run> + <Run Text="{Binding Repeats, Mode=OneWay,IsAsync=True,FallbackValue='0000'}"></Run> + </TextBlock> + </touch:TouchButton> + </StackPanel> + </StackPanel> + </DockPanel> + + <StackPanel Grid.Row="1" Orientation="Vertical"> + <Border Height="50" x:Name="brush_border" Margin="0 10 0 0" CornerRadius="25" Background="{StaticResource TangoPrimaryBackgroundBrush}" BorderThickness="1" BorderBrush="{StaticResource TangoGrayBrush}" ClipToBounds="False"> + <Border.Clip> + <RectangleGeometry RadiusX="25" RadiusY="25"> + <RectangleGeometry.Rect> + <MultiBinding Converter="{StaticResource WidthHeightToRectConverter}"> + <Binding ElementName="brush_border" Path="ActualWidth" /> + <Binding ElementName="brush_border" Path="ActualHeight" /> + </MultiBinding> + </RectangleGeometry.Rect> + </RectangleGeometry> + </Border.Clip> + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <ItemsControl ClipToBounds="False" ItemsSource="{Binding Segments}" > + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal" ClipToBounds="False"></StackPanel> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <Grid> + <Grid.Width> + <MultiBinding Converter="{StaticResource SegmentLengthToWidthConverter}"> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="DataContext.Length"></Binding> + <Binding RelativeSource="{RelativeSource AncestorType=ItemsControl}" Path="ActualWidth"></Binding> + <Binding Path="LengthWithInterSegment"></Binding> + </MultiBinding> + </Grid.Width> + <Rectangle Fill="{Binding SegmentBrush}"></Rectangle> + </Grid> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + + <Border Height="28" Width="150" BorderThickness="0" BorderBrush="Transparent" Opacity="20" Background="#32787880" HorizontalAlignment="Center" CornerRadius="8" VerticalAlignment="Center"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="{StaticResource TangoComboBoxItemFontSize}"> Grouped</TextBlock> + </Border> + + </Grid> + + </Border> + <Border x:Name="gapBorder" Margin="0 20 0 0" Height="24" ClipToBounds="False" CornerRadius="10" Visibility="{Binding EnableInterSegment, Converter={StaticResource BooleanToVisibilityConverter}}"> + <Border.Clip> + <RectangleGeometry RadiusX="10" RadiusY="10"> + <RectangleGeometry.Rect> + <MultiBinding Converter="{StaticResource WidthHeightToRectConverter}"> + <Binding ElementName="gapBorder" Path="ActualWidth" /> + <Binding ElementName="gapBorder" Path="ActualHeight" /> + </MultiBinding> + </RectangleGeometry.Rect> + </RectangleGeometry> + </Border.Clip> + <Grid> + <TextBlock FontSize="{StaticResource TangoDefaultFontSize}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"> + <Run Text="5m"></Run> + <Run Text=" Gap"></Run> + </TextBlock> + <Rectangle Stroke="{StaticResource TangoGrayBrush}" StrokeThickness="1" StrokeDashArray="5 5 5 5" RadiusX="12" RadiusY="12" /> + </Grid> + </Border> + + </StackPanel> + + <Canvas Grid.Row="1" x:Name="select_canvas_segment" Width="24" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="-50 -35 0 0" > + <touch:TouchCheckBox Height="22" Width="24" Margin="20 -20 0 0" Style="{StaticResource TouchRoundCheckBox}" Canvas.Left="0" Canvas.Top="0" x:Name="selectItem" Foreground="{StaticResource TangoKeyboardKeyDarkTextBrush}" Background="Transparent" IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center"/> + </Canvas> + + </Grid> + </DataTemplate> + + <helpers:GroupSegmentTemplateSelector x:Key="GroupSegmentTemplateSelector" + GroupSegmentsTemplate="{StaticResource GroupSegment_Template}" + SegmentTemplate="{StaticResource Segment_Template}"/> + <helpers:GroupSegmentTemplateSelector x:Key="CollapsedGroupSegmentTemplateSelector" + GroupSegmentsTemplate="{StaticResource CollapsedGroupSegment_Template}" + SegmentTemplate="{StaticResource CollapsedSegment_Template}"/> + </UserControl.Resources> <Grid Background="{StaticResource TangoMidBackgroundBrush}" SnapsToDevicePixels="False"> @@ -537,7 +803,7 @@ <DropShadowEffect Opacity="0.5" ShadowDepth="6" Color="Silver" BlurRadius="10" Direction="270"/> </Border.Effect> <UniformGrid Columns="6" Rows="1" DockPanel.Dock="Left" HorizontalAlignment="Stretch" > - <touch:TouchButton Style="{StaticResource CollapsedPanelButton}" EnableDropShadow="False" Command="{Binding RepeateSegmentCommand}" IsEnabled="False"> + <touch:TouchButton Style="{StaticResource CollapsedPanelButton}" EnableDropShadow="False" Command="{Binding RepeateSegmentCommand}" IsEnabled="{Binding JobModel.HasSelectedItems, Converter={StaticResource BooleanToVisibilityConverter}}"> <StackPanel Orientation="Vertical" VerticalAlignment="Center" > <Image Width="20" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant" Source="../Images/JobView/repeat.png"/> <TextBlock FontWeight="Medium" Margin="0 0 0 0" VerticalAlignment="Center" FontSize="{StaticResource TangoSmallFontSizeBar}" Foreground="{StaticResource TangoMidAccentBrush}">Repeat</TextBlock> @@ -626,12 +892,12 @@ <!--Border x:Name="borderDockFloat" Height="10" Margin="0 0 0 0" BorderBrush="Transparent" > <DockPanel x:Name="dockEdit" LastChildFill="False" Height="10" Width="50" HorizontalAlignment="Right" RenderTransformOrigin="0.58,2.08"/> </Border> --> - <ListBox x:Name="listSegments" Margin="10 0 10 60" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource Segment_Template}" Style="{StaticResource SegmentsListBox}" + <ListBox x:Name="listSegments" Margin="10 0 10 60" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplateSelector="{StaticResource GroupSegmentTemplateSelector}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityConverter}}" /> - <ListBox x:Name="collapsedListSegments" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplate="{StaticResource CollapsedSegment_Template}" Style="{StaticResource SegmentsListBox}" + <ListBox x:Name="collapsedListSegments" ItemsSource="{Binding SegmentsCollectionView}" ItemTemplateSelector ="{StaticResource CollapsedGroupSegmentTemplateSelector}" Style="{StaticResource SegmentsListBox}" ScrollViewer.VerticalScrollBarVisibility="Visible" Visibility="{Binding IsFullMode, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Margin=" 0 0 0 40"/> |
