diff --git a/OpenNest/Forms/LeadInToolWindow.cs b/OpenNest/Forms/LeadInToolWindow.cs
new file mode 100644
index 0000000..a179006
--- /dev/null
+++ b/OpenNest/Forms/LeadInToolWindow.cs
@@ -0,0 +1,110 @@
+using OpenNest.CNC.CuttingStrategy;
+using OpenNest.Controls;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace OpenNest.Forms
+{
+ public class LeadInToolWindow : Form
+ {
+ private readonly CuttingPanel cuttingPanel;
+
+ public CuttingPanel CuttingPanel => cuttingPanel;
+
+ public event EventHandler ParametersChanged
+ {
+ add => cuttingPanel.ParametersChanged += value;
+ remove => cuttingPanel.ParametersChanged -= value;
+ }
+
+ public event EventHandler AutoAssignClicked
+ {
+ add => cuttingPanel.AutoAssignClicked += value;
+ remove => cuttingPanel.AutoAssignClicked -= value;
+ }
+
+ public LeadInToolWindow()
+ {
+ Text = "Lead-In Properties";
+ FormBorderStyle = FormBorderStyle.SizableToolWindow;
+ ShowInTaskbar = false;
+ StartPosition = FormStartPosition.Manual;
+ MinimumSize = new Size(300, 400);
+ Size = new Size(400, 580);
+
+ cuttingPanel = new CuttingPanel
+ {
+ Dock = DockStyle.Fill,
+ ShowAutoAssign = true
+ };
+ Controls.Add(cuttingPanel);
+
+ RestorePosition();
+ }
+
+ public CuttingParameters BuildParameters() => cuttingPanel.BuildParameters();
+
+ public void LoadFromParameters(CuttingParameters p) => cuttingPanel.LoadFromParameters(p);
+
+ public ContourType? ActiveContourType
+ {
+ get => cuttingPanel.ActiveContourType;
+ set => cuttingPanel.ActiveContourType = value;
+ }
+
+ protected override void OnFormClosing(FormClosingEventArgs e)
+ {
+ if (e.CloseReason == CloseReason.UserClosing)
+ {
+ e.Cancel = true;
+ Hide();
+ }
+
+ SavePosition();
+ base.OnFormClosing(e);
+ }
+
+ protected override void OnMove(EventArgs e)
+ {
+ base.OnMove(e);
+ if (WindowState == FormWindowState.Normal)
+ SavePosition();
+ }
+
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ if (WindowState == FormWindowState.Normal)
+ SavePosition();
+ }
+
+ private void SavePosition()
+ {
+ if (WindowState != FormWindowState.Normal)
+ return;
+
+ Properties.Settings.Default.LeadInToolWindowLocation = Location;
+ Properties.Settings.Default.LeadInToolWindowSize = Size;
+ Properties.Settings.Default.Save();
+ }
+
+ private void RestorePosition()
+ {
+ var savedLocation = Properties.Settings.Default.LeadInToolWindowLocation;
+ var savedSize = Properties.Settings.Default.LeadInToolWindowSize;
+
+ if (savedSize.Width > 0 && savedSize.Height > 0)
+ Size = savedSize;
+
+ if (savedLocation.X != 0 || savedLocation.Y != 0)
+ {
+ var screen = Screen.FromPoint(savedLocation);
+ if (screen.WorkingArea.Contains(savedLocation))
+ Location = savedLocation;
+ else
+ CenterToParent();
+ }
+ }
+ }
+}
diff --git a/OpenNest/Properties/Settings.Designer.cs b/OpenNest/Properties/Settings.Designer.cs
index 7e44f3c..52b42c5 100644
--- a/OpenNest/Properties/Settings.Designer.cs
+++ b/OpenNest/Properties/Settings.Designer.cs
@@ -238,5 +238,29 @@ namespace OpenNest.Properties {
this["CuttingParametersJson"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0, 0")]
+ public global::System.Drawing.Point LeadInToolWindowLocation {
+ get {
+ return ((global::System.Drawing.Point)(this["LeadInToolWindowLocation"]));
+ }
+ set {
+ this["LeadInToolWindowLocation"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0, 0")]
+ public global::System.Drawing.Size LeadInToolWindowSize {
+ get {
+ return ((global::System.Drawing.Size)(this["LeadInToolWindowSize"]));
+ }
+ set {
+ this["LeadInToolWindowSize"] = value;
+ }
+ }
}
}
diff --git a/OpenNest/Properties/Settings.settings b/OpenNest/Properties/Settings.settings
index cc3fd9b..5ec56b9 100644
--- a/OpenNest/Properties/Settings.settings
+++ b/OpenNest/Properties/Settings.settings
@@ -56,5 +56,11 @@
+
+ 0, 0
+
+
+ 0, 0
+
\ No newline at end of file