From 8e2cbf02b6c819e92ee4eec2a673586438edfa93 Mon Sep 17 00:00:00 2001 From: Roy Date: Mon, 5 Mar 2018 09:12:59 +0200 Subject: Some work on embroidery import/export. --- .../Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs | 1 + .../Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs | 8 +++++++- .../Images/seamless-grid.jpg | Bin 0 -> 12022 bytes .../Tango.MachineStudio.Developer.csproj | 3 +++ .../ViewModels/EmbroideryImportViewVM.cs | 9 +++++++++ .../ViewModels/MainViewVM.cs | 6 +++--- .../Views/EmbroideryDisplayView.xaml | 10 ++++++++-- .../Views/EmbroideryImportView.xaml | 16 ++++++++++++++-- .../Views/EmbroideryImportView.xaml.cs | 2 +- .../Views/MachineJobSelectionView.xaml | 4 ++-- .../Tango.BL/ObservablesEntitiesAdapter.cs | 2 +- 11 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/seamless-grid.jpg (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs index 9d7475aea..1ed1e5b18 100644 --- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs @@ -215,6 +215,7 @@ namespace Tango.EmbroideryUI { path.PathFigure.Segments.Add(new LineSegment(new Point(_currentPoint.X, _currentPoint.Y), true)); path.Length += Math.Abs(GetDistance(_lastStitch.XX, _lastStitch.YY, stitch.XX, stitch.YY)); + path.StitchCount++; } _mode = StitchFlag.Normal; break; diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs index 385266228..5999845bf 100644 --- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs +++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs @@ -37,7 +37,13 @@ namespace Tango.EmbroideryUI public static readonly DependencyProperty PathFigureProperty = DependencyProperty.Register("PathFigure", typeof(PathFigure), typeof(EmbroideryPath), new PropertyMetadata(null)); - + public int StitchCount + { + get { return (int)GetValue(StitchCountProperty); } + set { SetValue(StitchCountProperty, value); } + } + public static readonly DependencyProperty StitchCountProperty = + DependencyProperty.Register("StitchCount", typeof(int), typeof(EmbroideryPath), new PropertyMetadata(0)); private void OnBrushChanged() { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/seamless-grid.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/seamless-grid.jpg new file mode 100644 index 000000000..59bb9c370 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Images/seamless-grid.jpg differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 378fb443b..0e64872f7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -353,5 +353,8 @@ + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs index a0f4314dc..530893535 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs @@ -27,8 +27,17 @@ namespace Tango.MachineStudio.Developer.ViewModels public ObservableCollection Paths { get; set; } + private int _stitchLength; + + public int StitchLength + { + get { return _stitchLength; } + set { _stitchLength = value; RaisePropertyChangedAuto(); } + } + public EmbroideryImportViewVM() : base() { + StitchLength = 6; ImportCommand = new RelayCommand(Import); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 76fe33a87..aef928486 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1639,7 +1639,7 @@ namespace Tango.MachineStudio.Developer.ViewModels if (jobName != null) { - AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.EmbroideryFile, dlg.FileName, view.EmbroideryImageBytes); + AddJobFromEmbroideryFile(jobName, vm.Paths.ToList(), vm.StitchLength, vm.EmbroideryFile, dlg.FileName, view.EmbroideryImageBytes); } }, () => @@ -1649,7 +1649,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } } - private async void AddJobFromEmbroideryFile(String jobName, List paths, EmbroideryFile embroideryFile, String fileName, byte[] imageBytes) + private async void AddJobFromEmbroideryFile(String jobName, List paths, int stitchLength, EmbroideryFile embroideryFile, String fileName, byte[] imageBytes) { LogManager.Log(String.Format("Adding new job from embroidery file {0}...", jobName)); @@ -1671,7 +1671,7 @@ namespace Tango.MachineStudio.Developer.ViewModels foreach (var path in paths.Skip(1)) { Segment segment = new Segment(); - segment.Length = path.Length / 1000d; + segment.Length = ((double)path.StitchCount * (double)stitchLength) / 1000d; segment.Name = "Embroidery Segment"; segment.SegmentIndex = paths.IndexOf(path) + 2; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml index a753453f9..22414b4b2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryDisplayView.xaml @@ -9,7 +9,7 @@ xmlns:converters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - Width="600" Height="350" Background="White" d:DataContext="{d:DesignInstance Type=vm:EmbroideryDisplayViewVM, IsDesignTimeCreatable=False}"> + Width="1280" Height="720" Background="White" d:DataContext="{d:DesignInstance Type=vm:EmbroideryDisplayViewVM, IsDesignTimeCreatable=False}"> @@ -33,12 +33,18 @@ + + + + + + - diff --git a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapter.cs b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapter.cs index 8e898ac18..770931309 100644 --- a/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapter.cs +++ b/Software/Visual_Studio/Tango.BL/ObservablesEntitiesAdapter.cs @@ -158,7 +158,7 @@ namespace Tango.BL foreach (var machine in Machines) { machine.MachinesConfigurations = machine.MachinesConfigurations.OrderByDescending(x => x.Configuration.CreationDate).Take(30).ToObservableCollection(); - machine.Jobs = machine.Jobs.OrderByDescending(x => x.CreationDate).ToObservableCollection(); + //machine.Jobs = machine.Jobs.OrderByDescending(x => x.CreationDate).ToObservableCollection(); //No need to load jobs. } MachinesConfigurations = Context.MachinesConfigurations.ToObservableCollection(); -- cgit v1.3.1