aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-05 12:34:58 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-05 12:34:58 +0200
commit628819a1787290f84c22ecc7cb747f649fd54468 (patch)
treeabc7aa70a02818bc0549e36f82564d278ec247c6 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer
parent4a9f241ed8230586242621795f76aa0add9f6008 (diff)
downloadTango-628819a1787290f84c22ecc7cb747f649fd54468.tar.gz
Tango-628819a1787290f84c22ecc7cb747f649fd54468.zip
Added dynamic factoring for embroidery import thread length.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/EmbroideryImportViewVM.cs43
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs21
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml29
3 files changed, 80 insertions, 13 deletions
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 530893535..eaffab9e5 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,17 +27,50 @@ namespace Tango.MachineStudio.Developer.ViewModels
public ObservableCollection<EmbroideryPath> Paths { get; set; }
- private int _stitchLength;
+ public List<IEmbroideryMaterial> EmbroideryMaterials { get; set; }
- public int StitchLength
+ private IEmbroideryMaterial _selectedEmbroideryMaterial;
+ public IEmbroideryMaterial SelectedEmbroideryMaterial
{
- get { return _stitchLength; }
- set { _stitchLength = value; RaisePropertyChangedAuto(); }
+ get { return _selectedEmbroideryMaterial; }
+ set { _selectedEmbroideryMaterial = value; RaisePropertyChangedAuto(); }
+ }
+
+ private IEmbroideryMaterial _selectedStabilizer;
+ public IEmbroideryMaterial SelectedStabilizer
+ {
+ get { return _selectedStabilizer; }
+ set { _selectedStabilizer = value; RaisePropertyChangedAuto(); }
+ }
+
+ private double _embroideryMaterialThickness;
+ public double EmbroideryMaterialThickness
+ {
+ get { return _embroideryMaterialThickness; }
+ set { _embroideryMaterialThickness = value; RaisePropertyChangedAuto(); }
+ }
+
+ private double _stabilizerThickness;
+ public double StabilizerThickness
+ {
+ get { return _stabilizerThickness; }
+ set { _stabilizerThickness = value; RaisePropertyChangedAuto(); }
+ }
+
+ private bool _hasStabilizer;
+ public bool HasStabilizer
+ {
+ get { return _hasStabilizer; }
+ set { _hasStabilizer = value; RaisePropertyChangedAuto(); }
}
public EmbroideryImportViewVM() : base()
{
- StitchLength = 6;
+ EmbroideryMaterials = EmbroideryMaterialsHelper.GetAvailableEmbroideryMaterials();
+ SelectedEmbroideryMaterial = EmbroideryMaterials.FirstOrDefault();
+ SelectedStabilizer = EmbroideryMaterials.FirstOrDefault();
+ EmbroideryMaterialThickness = 1;
+ StabilizerThickness = 1;
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 218733819..566dc7a16 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.StitchLength, vm.EmbroideryFile, dlg.FileName, view.EmbroideryImageBytes);
+ AddJobFromEmbroideryFile(jobName, vm, dlg.FileName, view.EmbroideryImageBytes);
}
},
() =>
@@ -1649,7 +1649,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
}
- private async void AddJobFromEmbroideryFile(String jobName, List<EmbroideryPath> paths, int stitchLength, EmbroideryFile embroideryFile, String fileName, byte[] imageBytes)
+ private async void AddJobFromEmbroideryFile(String jobName, EmbroideryImportViewVM vm, String fileName, byte[] imageBytes)
{
LogManager.Log(String.Format("Adding new job from embroidery file {0}...", jobName));
@@ -1668,12 +1668,23 @@ namespace Tango.MachineStudio.Developer.ViewModels
job.EmbroideryJpeg = imageBytes;
job.HasEmbroideryFile = true;
- foreach (var path in paths.Skip(1))
+ foreach (var path in vm.Paths.Skip(1))
{
Segment segment = new Segment();
- segment.Length = (path.Length / 1000d) * 2d;
+
+ double baseLength = path.Length / 1000d;
+ double embThicknessLength = (vm.EmbroideryMaterialThickness * path.StitchCount) / 1000d;
+ double stabilizerThicknessLength = (vm.StabilizerThickness * path.StitchCount) / 1000d;
+ double totalLength = (baseLength + embThicknessLength) * vm.SelectedEmbroideryMaterial.Coefficient;
+
+ if (vm.HasStabilizer)
+ {
+ totalLength += (stabilizerThicknessLength * vm.SelectedStabilizer.Coefficient);
+ }
+
+ segment.Length = totalLength;
segment.Name = "Embroidery Segment";
- segment.SegmentIndex = paths.IndexOf(path) + 2;
+ segment.SegmentIndex = vm.Paths.IndexOf(path) + 2;
if (path.Brush is SolidColorBrush)
{
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml
index 17a5a5b8c..42d0bb106 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/EmbroideryImportView.xaml
@@ -45,10 +45,33 @@
<Grid Grid.Column="1" Grid.Row="1">
<StackPanel>
<TextBlock Margin="5">Region Brush</TextBlock>
- <brushPicker:BrushPicker Margin="0 10 0 0" Background="White" BorderThickness="0" Brush="{Binding ElementName=editor,Path=SelectedPath.Brush,Mode=TwoWay}" />
+ <Border Margin="5" BorderThickness="1" BorderBrush="Silver">
+ <brushPicker:BrushPicker Background="White" BorderThickness="0" Brush="{Binding ElementName=editor,Path=SelectedPath.Brush,Mode=TwoWay}" />
+ </Border>
- <TextBlock Text="Stitch Length" Margin="5"></TextBlock>
- <mahApps:NumericUpDown Margin="5" Minimum="1" Maximum="20" StringFormat="# mm" Value="{Binding StitchLength}" HasDecimals="False" HorizontalContentAlignment="Center" />
+ <Border BorderThickness="1" BorderBrush="Silver" Padding="5 0 5 5" Margin="5">
+ <Border.Resources>
+ <Style TargetType="TextBlock">
+ <Setter Property="Margin" Value="0 10 0 5"></Setter>
+ </Style>
+ </Border.Resources>
+ <StackPanel>
+ <TextBlock Text="Material"></TextBlock>
+ <ComboBox ItemsSource="{Binding EmbroideryMaterials}" SelectedItem="{Binding SelectedEmbroideryMaterial}" DisplayMemberPath="Name" Margin="5 0"></ComboBox>
+
+ <TextBlock Text="Material Thickness"></TextBlock>
+ <mahApps:NumericUpDown Minimum="0" Maximum="100" StringFormat="# mm" Value="{Binding EmbroideryMaterialThickness}" HasDecimals="False" HorizontalContentAlignment="Center" />
+
+ <Grid Margin="0 20 0 5">
+ <TextBlock Text="Stabilizer" Margin="0" HorizontalAlignment="Left"></TextBlock>
+ <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding HasStabilizer}"></ToggleButton>
+ </Grid>
+ <ComboBox IsEnabled="{Binding HasStabilizer}" ItemsSource="{Binding EmbroideryMaterials}" SelectedItem="{Binding SelectedStabilizer}" DisplayMemberPath="Name" Margin="5 0"></ComboBox>
+
+ <TextBlock Text="Stabilizer Thickness"></TextBlock>
+ <mahApps:NumericUpDown IsEnabled="{Binding HasStabilizer}" Minimum="1" Maximum="100" StringFormat="# mm" Value="{Binding StabilizerThickness}" HasDecimals="False" HorizontalContentAlignment="Center" />
+ </StackPanel>
+ </Border>
</StackPanel>
<Rectangle HorizontalAlignment="Left" Stroke="Silver" />