From 1ebb6a67c93969f3d3822893d4e191d14f8fd3e3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 14 Mar 2018 12:04:41 +0200 Subject: Fixed some issues with primary keys on db. Implemented embroidery import Fit To Scale. Implemented assignment of user last login on machine studio login. --- .../EmbroideryFileEditor.xaml.cs | 33 ++++++++++++++++++++++ .../Tango.EmbroideryUI/EmbroideryPath.cs | 6 ++-- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/Embroidery') 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; } } } -- cgit v1.3.1