refactor(ui): share the BOM file picker between the BOM import forms

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-29 12:06:38 -05:00
1 parent fd3ee24082
commit 8cd9d5173b
3 files changed
+30 -20

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
using System.Windows.Forms;
namespace OpenNest.Forms
{
/// <summary>The BOM workbook picker shared by the BOM import forms.</summary>
internal static class BomFileDialog
{
/// <summary>Asks for a BOM file; null when the operator cancels.</summary>
public static string Show(IWin32Window owner)
{
using var dialog = new OpenFileDialog
{
Title = "Select BOM File",
Filter = "Excel Files|*.xlsx|All Files|*.*",
FilterIndex = 1,
};
return dialog.ShowDialog(owner) == DialogResult.OK ? dialog.FileName : null;
}
}
}
+5 -11
View File
@@ -46,23 +46,17 @@ namespace OpenNest.Forms
private void BrowseBom_Click(object sender, EventArgs e)
{
using var dlg = new OpenFileDialog
{
Title = "Select BOM File",
Filter = "Excel Files|*.xlsx|All Files|*.*",
FilterIndex = 1,
};
if (dlg.ShowDialog(this) != DialogResult.OK)
var fileName = BomFileDialog.Show(this);
if (fileName == null)
return;
txtBomFile.Text = dlg.FileName;
txtBomFile.Text = fileName;
if (string.IsNullOrWhiteSpace(txtDxfFolder.Text))
txtDxfFolder.Text = Path.GetDirectoryName(dlg.FileName);
txtDxfFolder.Text = Path.GetDirectoryName(fileName);
if (string.IsNullOrWhiteSpace(txtJobName.Text))
txtJobName.Text = BomImportRows.JobName(dlg.FileName);
txtJobName.Text = BomImportRows.JobName(fileName);
}
private void BrowseDxf_Click(object sender, EventArgs e)
+5 -9
View File
@@ -274,18 +274,14 @@ namespace OpenNest.Forms
private void BrowseBomButton_Click(object sender, EventArgs e)
{
using var dialog = new OpenFileDialog
{
Title = "Select BOM File",
Filter = "Excel Files|*.xlsx|All Files|*.*",
};
if (dialog.ShowDialog(this) != DialogResult.OK)
var fileName = BomFileDialog.Show(this);
if (fileName == null)
return;
bomBox.Text = dialog.FileName;
bomBox.Text = fileName;
if (string.IsNullOrWhiteSpace(folderBox.Text))
folderBox.Text = Path.GetDirectoryName(dialog.FileName);
nameBox.Text = BomImportRows.JobName(dialog.FileName);
folderBox.Text = Path.GetDirectoryName(fileName);
nameBox.Text = BomImportRows.JobName(fileName);
}
private void BrowseFolderButton_Click(object sender, EventArgs e)