From f74da248b38e26926c3b5f8640eeede47bcc9a81 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Mon, 12 Oct 2026 08:34:05 -0400 Subject: [PATCH] refactor(ui): split MachineConfigForm into a Designer-backed partial class The form's static chrome (tree/detail split, Save/Export/Import bar) was built entirely in the regular constructor, so Visual Studio's WinForms designer had no InitializeComponent() to read and showed a blank/broken surface. Move that static layout into MachineConfigForm.Designer.cs and add a private parameterless constructor for the designer to instantiate, following the same pattern already used by EditNestForm. The dynamic, data-driven detail panel content stays in the regular constructor/methods. Co-Authored-By: Claude Sonnet 5 --- OpenNest/Forms/MachineConfigForm.Designer.cs | 154 +++++++++++++++++++ OpenNest/Forms/MachineConfigForm.cs | 53 +------ OpenNest/Forms/MachineConfigForm.resx | 120 +++++++++++++++ 3 files changed, 282 insertions(+), 45 deletions(-) create mode 100644 OpenNest/Forms/MachineConfigForm.Designer.cs create mode 100644 OpenNest/Forms/MachineConfigForm.resx diff --git a/OpenNest/Forms/MachineConfigForm.Designer.cs b/OpenNest/Forms/MachineConfigForm.Designer.cs new file mode 100644 index 00000000..f3beb632 --- /dev/null +++ b/OpenNest/Forms/MachineConfigForm.Designer.cs @@ -0,0 +1,154 @@ +namespace OpenNest.Forms +{ + partial class MachineConfigForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + splitContainer = new System.Windows.Forms.SplitContainer(); + _tree = new System.Windows.Forms.TreeView(); + _detailPanel = new System.Windows.Forms.Panel(); + bottomPanel = new System.Windows.Forms.FlowLayoutPanel(); + _saveButton = new System.Windows.Forms.Button(); + exportButton = new System.Windows.Forms.Button(); + importButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit(); + splitContainer.Panel1.SuspendLayout(); + splitContainer.Panel2.SuspendLayout(); + splitContainer.SuspendLayout(); + bottomPanel.SuspendLayout(); + SuspendLayout(); + // + // splitContainer + // + splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + splitContainer.Location = new System.Drawing.Point(0, 0); + splitContainer.Name = "splitContainer"; + // + // splitContainer.Panel1 + // + splitContainer.Panel1.Controls.Add(_tree); + // + // splitContainer.Panel2 + // + splitContainer.Panel2.Controls.Add(_detailPanel); + splitContainer.Size = new System.Drawing.Size(1194, 562); + splitContainer.SplitterDistance = 500; + splitContainer.TabIndex = 0; + // + // _tree + // + _tree.Dock = System.Windows.Forms.DockStyle.Fill; + _tree.HideSelection = false; + _tree.Location = new System.Drawing.Point(0, 0); + _tree.Name = "_tree"; + _tree.Size = new System.Drawing.Size(256, 562); + _tree.TabIndex = 0; + // + // _detailPanel + // + _detailPanel.AutoScroll = true; + _detailPanel.Dock = System.Windows.Forms.DockStyle.Fill; + _detailPanel.Location = new System.Drawing.Point(0, 0); + _detailPanel.Name = "_detailPanel"; + _detailPanel.Size = new System.Drawing.Size(934, 562); + _detailPanel.TabIndex = 0; + // + // bottomPanel + // + bottomPanel.AutoSize = true; + bottomPanel.Controls.Add(_saveButton); + bottomPanel.Controls.Add(exportButton); + bottomPanel.Controls.Add(importButton); + bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom; + bottomPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; + bottomPanel.Location = new System.Drawing.Point(0, 562); + bottomPanel.Name = "bottomPanel"; + bottomPanel.Padding = new System.Windows.Forms.Padding(4); + bottomPanel.Size = new System.Drawing.Size(1194, 39); + bottomPanel.TabIndex = 1; + // + // _saveButton + // + _saveButton.AutoSize = true; + _saveButton.Location = new System.Drawing.Point(1108, 7); + _saveButton.Name = "_saveButton"; + _saveButton.Size = new System.Drawing.Size(75, 25); + _saveButton.TabIndex = 0; + _saveButton.Text = "Save"; + _saveButton.Click += Save_Click; + // + // exportButton + // + exportButton.AutoSize = true; + exportButton.Location = new System.Drawing.Point(1027, 7); + exportButton.Name = "exportButton"; + exportButton.Size = new System.Drawing.Size(75, 25); + exportButton.TabIndex = 1; + exportButton.Text = "Export..."; + exportButton.Click += Export_Click; + // + // importButton + // + importButton.AutoSize = true; + importButton.Location = new System.Drawing.Point(946, 7); + importButton.Name = "importButton"; + importButton.Size = new System.Drawing.Size(75, 25); + importButton.TabIndex = 2; + importButton.Text = "Import..."; + importButton.Click += Import_Click; + // + // MachineConfigForm + // + ClientSize = new System.Drawing.Size(1194, 601); + Controls.Add(splitContainer); + Controls.Add(bottomPanel); + MinimumSize = new System.Drawing.Size(1010, 440); + Name = "MachineConfigForm"; + StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + Text = "Machine Configuration"; + splitContainer.Panel1.ResumeLayout(false); + splitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splitContainer).EndInit(); + splitContainer.ResumeLayout(false); + bottomPanel.ResumeLayout(false); + bottomPanel.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer; + private System.Windows.Forms.TreeView _tree; + private System.Windows.Forms.Panel _detailPanel; + private System.Windows.Forms.FlowLayoutPanel bottomPanel; + private System.Windows.Forms.Button _saveButton; + private System.Windows.Forms.Button exportButton; + private System.Windows.Forms.Button importButton; + } +} diff --git a/OpenNest/Forms/MachineConfigForm.cs b/OpenNest/Forms/MachineConfigForm.cs index 8fc0cc18..6b2981af 100644 --- a/OpenNest/Forms/MachineConfigForm.cs +++ b/OpenNest/Forms/MachineConfigForm.cs @@ -11,7 +11,7 @@ using OpenNest.Shapes; namespace OpenNest.Forms { - public class MachineConfigForm : Form + public partial class MachineConfigForm : Form { private static readonly string[] LeadInTypes = { @@ -30,60 +30,23 @@ namespace OpenNest.Forms private static readonly string[] CutOffDirectionOptions = Enum.GetNames(); private readonly IDataProvider _provider; - private readonly TreeView _tree; - private readonly Panel _detailPanel; private readonly HashSet _pendingDeletes = new(); - private readonly Button _saveButton; private MachineConfig _currentMachine; private TreeNode _currentMachineNode; private bool _dirty; - public MachineConfigForm(IDataProvider provider) + private MachineConfigForm() { - _provider = provider; - - Text = "Machine Configuration"; - Size = new Size(1210, 640); - StartPosition = FormStartPosition.CenterParent; - MinimumSize = new Size(1010, 440); - - var splitContainer = new SplitContainer - { - Dock = DockStyle.Fill, - SplitterDistance = 500, - FixedPanel = FixedPanel.Panel1, - }; - - _tree = new TreeView { Dock = DockStyle.Fill, HideSelection = false }; + InitializeComponent(); _tree.AfterSelect += Tree_AfterSelect; _tree.MouseDown += Tree_MouseDown; + } - splitContainer.Panel1.Controls.Add(_tree); - - _detailPanel = new Panel { Dock = DockStyle.Fill, AutoScroll = true }; - splitContainer.Panel2.Controls.Add(_detailPanel); - - var bottomPanel = new FlowLayoutPanel - { - Dock = DockStyle.Bottom, - AutoSize = true, - FlowDirection = FlowDirection.RightToLeft, - Padding = new Padding(4), - }; - - _saveButton = new Button { Text = "Save", AutoSize = true }; - _saveButton.Click += Save_Click; - var importButton = new Button { Text = "Import...", AutoSize = true }; - importButton.Click += Import_Click; - var exportButton = new Button { Text = "Export...", AutoSize = true }; - exportButton.Click += Export_Click; - - bottomPanel.Controls.AddRange(new Control[] { _saveButton, exportButton, importButton }); - - Controls.Add(splitContainer); - Controls.Add(bottomPanel); - + public MachineConfigForm(IDataProvider provider) + : this() + { + _provider = provider; LoadTree(); } diff --git a/OpenNest/Forms/MachineConfigForm.resx b/OpenNest/Forms/MachineConfigForm.resx new file mode 100644 index 00000000..4edf53f8 --- /dev/null +++ b/OpenNest/Forms/MachineConfigForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file