refactor: update application startup flow

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 <noreply@anthropic.com>
This commit is contained in:
2025-11-03 06:46:43 -05:00
parent 9b1fbd9fad
commit cbfb9190c5

View File

@@ -20,10 +20,21 @@ namespace ExportDXF
// Simple DI setup - could use a DI container like Microsoft.Extensions.DependencyInjection // Simple DI setup - could use a DI container like Microsoft.Extensions.DependencyInjection
var container = new ServiceContainer(); var container = new ServiceContainer();
var mainForm = container.Resolve<MainForm>(); // Show drawing selection dialog first
var drawingSelectionForm = container.ResolveDrawingSelection();
var result = drawingSelectionForm.ShowDialog();
if (result == DialogResult.OK && drawingSelectionForm.SelectedDrawingId.HasValue)
{
// User selected a drawing, proceed to main form
var mainForm = container.Resolve<MainForm>(
drawingSelectionForm.SelectedDrawingId.Value,
drawingSelectionForm.SelectedDrawingNumber);
Application.Run(mainForm); Application.Run(mainForm);
} }
// If user cancelled, just exit
}
} }
/// <summary> /// <summary>
@@ -32,7 +43,21 @@ namespace ExportDXF
/// </summary> /// </summary>
public class ServiceContainer public class ServiceContainer
{ {
public MainForm Resolve<T>() 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<T>(int selectedDrawingId, string selectedDrawingNumber) where T : MainForm
{ {
// Create the dependency tree // Create the dependency tree
var solidWorksService = new SolidWorksService(); var solidWorksService = new SolidWorksService();
@@ -40,17 +65,15 @@ namespace ExportDXF
var bomExtractor = new BomExtractor(); var bomExtractor = new BomExtractor();
var partExporter = new PartExporter(); var partExporter = new PartExporter();
var drawingExporter = new DrawingExporter(); var drawingExporter = new DrawingExporter();
var baseUrl = ConfigurationManager.AppSettings["CutFab.ApiBaseUrl"] ?? "http://localhost:7027";
var apiClient = new CutFabApiClient(baseUrl);
var exportService = new DxfExportService( var exportService = new DxfExportService(
solidWorksService, solidWorksService,
bomExtractor, bomExtractor,
partExporter, partExporter,
drawingExporter, drawingExporter,
apiClient); _apiClient);
return new MainForm(solidWorksService, exportService, apiClient); return new MainForm(solidWorksService, exportService, _apiClient, selectedDrawingId, selectedDrawingNumber);
} }
} }
} }