Moved ViewFlipDeciders to separate namespace.
This commit is contained in:
@@ -100,7 +100,9 @@
|
|||||||
<Compile Include="ItemExtractors\ItemExtractor.cs" />
|
<Compile Include="ItemExtractors\ItemExtractor.cs" />
|
||||||
<Compile Include="Forms\ViewFlipDeciderComboboxItem.cs" />
|
<Compile Include="Forms\ViewFlipDeciderComboboxItem.cs" />
|
||||||
<Compile Include="Item.cs" />
|
<Compile Include="Item.cs" />
|
||||||
<Compile Include="IViewFlipDecider.cs" />
|
<Compile Include="ViewFlipDeciders\AskViewFlipDecider.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\AutoViewFlipDecider.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\IViewFlipDecider.cs" />
|
||||||
<Compile Include="Helper.cs" />
|
<Compile Include="Helper.cs" />
|
||||||
<Compile Include="Forms\MainForm.cs">
|
<Compile Include="Forms\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@@ -112,6 +114,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SolidWorksExtensions.cs" />
|
<Compile Include="SolidWorksExtensions.cs" />
|
||||||
<Compile Include="Units.cs" />
|
<Compile Include="Units.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\PreferUpViewFlipDecider.cs" />
|
||||||
<Compile Include="ViewHelper.cs" />
|
<Compile Include="ViewHelper.cs" />
|
||||||
<EmbeddedResource Include="Forms\MainForm.resx">
|
<EmbeddedResource Include="Forms\MainForm.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace ExportDXF.Forms
|
using ExportDXF.ViewFlipDeciders;
|
||||||
|
|
||||||
|
namespace ExportDXF.Forms
|
||||||
{
|
{
|
||||||
public class ViewFlipDeciderComboboxItem
|
public class ViewFlipDeciderComboboxItem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
24
ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs
Normal file
24
ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs
Normal file
29
ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs
Normal file
9
ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace ExportDXF.ViewFlipDeciders
|
||||||
|
{
|
||||||
|
public interface IViewFlipDecider
|
||||||
|
{
|
||||||
|
bool ShouldFlip(SolidWorks.Interop.sldworks.View view);
|
||||||
|
|
||||||
|
string Name { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs
Normal file
26
ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user