aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Embroidery
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-14 12:04:41 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-14 12:04:41 +0200
commit1ebb6a67c93969f3d3822893d4e191d14f8fd3e3 (patch)
tree235f1d8bc8ca127d4ae2f4ee45ec0e527e1b9844 /Software/Visual_Studio/Embroidery
parent37b740c1d128d694b9dcbc3669808435b5d88fec (diff)
downloadTango-1ebb6a67c93969f3d3822893d4e191d14f8fd3e3.tar.gz
Tango-1ebb6a67c93969f3d3822893d4e191d14f8fd3e3.zip
Fixed some issues with primary keys on db.
Implemented embroidery import Fit To Scale. Implemented assignment of user last login on machine studio login.
Diffstat (limited to 'Software/Visual_Studio/Embroidery')
-rw-r--r--Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs33
-rw-r--r--Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs6
2 files changed, 36 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs
index 1ed1e5b18..6b86c68cb 100644
--- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs
+++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryFileEditor.xaml.cs
@@ -101,6 +101,7 @@ namespace Tango.EmbroideryUI
EmbroideryFile = output.EmbroideryFile;
DrawFile();
+ ScaleToFit();
}
protected virtual void OnPathsChanged()
@@ -253,5 +254,37 @@ namespace Tango.EmbroideryUI
}
#endregion
+
+ #region Public Methods
+
+ public void ScaleToFit()
+ {
+ double minX = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Left).Min();
+ double minY = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Top).Min();
+ double maxX = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Right).Max();
+ double maxY = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Bottom).Max();
+
+ Rect embRect = new Rect(minX, minY, maxX - minX, maxY - minY);
+ Rect editorRect = new Rect(0, 0, ActualWidth, ActualHeight);
+
+ double embRectArea = embRect.Width * embRect.Height;
+ double editorRectArea = editorRect.Width * editorRect.Height;
+
+ double factor = (editorRect.Width / embRect.Width) / 2d;
+
+ if (embRect.Height > embRect.Width)
+ {
+ factor = (editorRect.Height / embRect.Height) / 2d;
+ }
+
+ ScaleFactor = factor;
+
+ minY = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Top).Min();
+ minX = Paths.Select(x => x.Path.GetFlattenedPathGeometry().Bounds.Left).Min();
+
+ list.Margin = new Thickness(minX / 2, -minY / 2, 0, 0);
+ }
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs
index 5999845bf..33f14cd27 100644
--- a/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs
+++ b/Software/Visual_Studio/Embroidery/Tango.EmbroideryUI/EmbroideryPath.cs
@@ -11,7 +11,7 @@ namespace Tango.EmbroideryUI
{
public class EmbroideryPath : Shape
{
- private PathGeometry _path;
+ public PathGeometry Path { get; private set; }
public Brush Brush
{
@@ -72,14 +72,14 @@ namespace Tango.EmbroideryUI
public EmbroideryPath(PathGeometry path)
{
- _path = path;
+ Path = path;
}
protected override Geometry DefiningGeometry
{
get
{
- return _path;
+ return Path;
}
}
}