From cbfb9190c5f186af38314cf8478b7988e507e47b Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Mon, 3 Nov 2025 06:46:43 -0500 Subject: [PATCH] refactor: update application startup flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified Program.cs to display DrawingSelectionForm at startup before launching MainForm. The selected drawing ID and number are now passed to MainForm constructor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ExportDXF/Program.cs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/ExportDXF/Program.cs b/ExportDXF/Program.cs index b178bcf..016e985 100644 --- a/ExportDXF/Program.cs +++ b/ExportDXF/Program.cs @@ -20,9 +20,20 @@ namespace ExportDXF // Simple DI setup - could use a DI container like Microsoft.Extensions.DependencyInjection var container = new ServiceContainer(); - var mainForm = container.Resolve(); + // Show drawing selection dialog first + var drawingSelectionForm = container.ResolveDrawingSelection(); + var result = drawingSelectionForm.ShowDialog(); - Application.Run(mainForm); + if (result == DialogResult.OK && drawingSelectionForm.SelectedDrawingId.HasValue) + { + // User selected a drawing, proceed to main form + var mainForm = container.Resolve( + drawingSelectionForm.SelectedDrawingId.Value, + drawingSelectionForm.SelectedDrawingNumber); + + Application.Run(mainForm); + } + // If user cancelled, just exit } } @@ -32,7 +43,21 @@ namespace ExportDXF /// public class ServiceContainer { - public MainForm Resolve() where T : MainForm + private readonly string _baseUrl; + private readonly CutFabApiClient _apiClient; + + public ServiceContainer() + { + _baseUrl = ConfigurationManager.AppSettings["CutFab.ApiBaseUrl"] ?? "http://localhost:7027"; + _apiClient = new CutFabApiClient(_baseUrl); + } + + public DrawingSelectionForm ResolveDrawingSelection() + { + return new DrawingSelectionForm(_apiClient); + } + + public MainForm Resolve(int selectedDrawingId, string selectedDrawingNumber) where T : MainForm { // Create the dependency tree var solidWorksService = new SolidWorksService(); @@ -40,17 +65,15 @@ namespace ExportDXF var bomExtractor = new BomExtractor(); var partExporter = new PartExporter(); var drawingExporter = new DrawingExporter(); - var baseUrl = ConfigurationManager.AppSettings["CutFab.ApiBaseUrl"] ?? "http://localhost:7027"; - var apiClient = new CutFabApiClient(baseUrl); var exportService = new DxfExportService( solidWorksService, bomExtractor, partExporter, drawingExporter, - apiClient); + _apiClient); - return new MainForm(solidWorksService, exportService, apiClient); + return new MainForm(solidWorksService, exportService, _apiClient, selectedDrawingId, selectedDrawingNumber); } } }