mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-03 12:09:25 -05:00
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:
1 parent
fd3ee24082
commit
8cd9d5173b
3 files changed
+30
-20
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user