mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-24 23:01:10 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
c67577d463
commit
f74da248b3
3 files changed
+282
-45
No files matched your search
+154
@@ -0,0 +1,154 @@
|
||||
namespace OpenNest.Forms
|
||||
{
|
||||
partial class MachineConfigForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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<CutDirection>();
|
||||
|
||||
private readonly IDataProvider _provider;
|
||||
private readonly TreeView _tree;
|
||||
private readonly Panel _detailPanel;
|
||||
private readonly HashSet<Guid> _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();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in new issue
Block a user