diff --git a/ExportDXF/ExportDXF.csproj b/ExportDXF/ExportDXF.csproj index 1a45667..aa925a2 100644 --- a/ExportDXF/ExportDXF.csproj +++ b/ExportDXF/ExportDXF.csproj @@ -100,7 +100,9 @@ - + + + Form @@ -112,6 +114,7 @@ + MainForm.cs diff --git a/ExportDXF/Forms/ViewFlipDeciderComboboxItem.cs b/ExportDXF/Forms/ViewFlipDeciderComboboxItem.cs index fc4b4ee..37a11b2 100644 --- a/ExportDXF/Forms/ViewFlipDeciderComboboxItem.cs +++ b/ExportDXF/Forms/ViewFlipDeciderComboboxItem.cs @@ -1,4 +1,6 @@ -namespace ExportDXF.Forms +using ExportDXF.ViewFlipDeciders; + +namespace ExportDXF.Forms { public class ViewFlipDeciderComboboxItem { diff --git a/ExportDXF/IViewFlipDecider.cs b/ExportDXF/IViewFlipDecider.cs deleted file mode 100644 index 54da119..0000000 --- a/ExportDXF/IViewFlipDecider.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Linq; -using System.Windows.Forms; - -namespace ExportDXF -{ - public interface IViewFlipDecider - { - bool ShouldFlip(SolidWorks.Interop.sldworks.View view); - - string Name { get; } - } - - public class AutoViewFlipDecider : IViewFlipDecider - { - public string Name => "Automatic"; - - public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) - { - var orientation = ViewHelper.GetOrientation(view); - var bounds = ViewHelper.GetBounds(view); - var bends = ViewHelper.GetBends(view); - - var up = bends.Where(b => b.Direction == BendDirection.Up).ToList(); - var down = bends.Where(b => b.Direction == BendDirection.Down).ToList(); - - if (down.Count == 0) - return false; - - if (up.Count == 0) - return true; - - var bend = ViewHelper.GetBendClosestToBounds(bounds, bends); - - return bend.Direction == BendDirection.Down; - } - } - - public class AskViewFlipDecider : IViewFlipDecider - { - public string Name => "Ask to flip"; - - public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) - { - var bends = ViewHelper.GetBends(view); - - if (bends.Count == 0) - return false; - - return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; - } - - public override string ToString() - { - return Name; - } - } - - public class PreferUpViewFlipDecider : IViewFlipDecider - { - public string Name => "Prefer up bends, ask if up/down"; - - public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) - { - var bends = ViewHelper.GetBends(view); - var up = bends.Where(b => b.Direction == BendDirection.Up).ToList(); - var down = bends.Where(b => b.Direction == BendDirection.Down).ToList(); - - if (up.Count > 0 && down.Count > 0) - { - return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; - } - else - { - return down.Count > 0; - } - } - } -} \ No newline at end of file diff --git a/ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs b/ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs new file mode 100644 index 0000000..4d9e135 --- /dev/null +++ b/ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs @@ -0,0 +1,24 @@ +using System.Windows.Forms; + +namespace ExportDXF.ViewFlipDeciders +{ + public class AskViewFlipDecider : IViewFlipDecider + { + public string Name => "Ask to flip"; + + public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) + { + var bends = ViewHelper.GetBends(view); + + if (bends.Count == 0) + return false; + + return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; + } + + public override string ToString() + { + return Name; + } + } +} \ No newline at end of file diff --git a/ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs b/ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs new file mode 100644 index 0000000..6d094e2 --- /dev/null +++ b/ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs @@ -0,0 +1,29 @@ +using System.Linq; + +namespace ExportDXF.ViewFlipDeciders +{ + public class AutoViewFlipDecider : IViewFlipDecider + { + public string Name => "Automatic"; + + public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) + { + var orientation = ViewHelper.GetOrientation(view); + var bounds = ViewHelper.GetBounds(view); + var bends = ViewHelper.GetBends(view); + + var up = bends.Where(b => b.Direction == BendDirection.Up).ToList(); + var down = bends.Where(b => b.Direction == BendDirection.Down).ToList(); + + if (down.Count == 0) + return false; + + if (up.Count == 0) + return true; + + var bend = ViewHelper.GetBendClosestToBounds(bounds, bends); + + return bend.Direction == BendDirection.Down; + } + } +} \ No newline at end of file diff --git a/ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs b/ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs new file mode 100644 index 0000000..aa70aea --- /dev/null +++ b/ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs @@ -0,0 +1,9 @@ +namespace ExportDXF.ViewFlipDeciders +{ + public interface IViewFlipDecider + { + bool ShouldFlip(SolidWorks.Interop.sldworks.View view); + + string Name { get; } + } +} \ No newline at end of file diff --git a/ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs b/ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs new file mode 100644 index 0000000..340107e --- /dev/null +++ b/ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs @@ -0,0 +1,26 @@ +using System.Linq; +using System.Windows.Forms; + +namespace ExportDXF.ViewFlipDeciders +{ + public class PreferUpViewFlipDecider : IViewFlipDecider + { + public string Name => "Prefer up bends, ask if up/down"; + + public bool ShouldFlip(SolidWorks.Interop.sldworks.View view) + { + var bends = ViewHelper.GetBends(view); + var up = bends.Where(b => b.Direction == BendDirection.Up).ToList(); + var down = bends.Where(b => b.Direction == BendDirection.Down).ToList(); + + if (up.Count > 0 && down.Count > 0) + { + return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; + } + else + { + return down.Count > 0; + } + } + } +} \ No newline at end of file