From 136a571aea7cb4269a45138df92492efb17178f3 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 4 Nov 2025 09:58:48 -0500 Subject: [PATCH] feat(ui): display active SolidWorks drawing in DrawingSelectionForm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add real-time display of the currently active SolidWorks document: - Show active drawing name with visual status indicators - Display different states: drawing (green), non-drawing (orange), none (gray), error (red) - Subscribe to ActiveDocumentChanged events for live updates - Inject ISolidWorksService dependency for document access This helps users verify they're working with the correct drawing before export. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ExportDXF/Forms/DrawingSelectionForm.cs | 34 ++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ExportDXF/Forms/DrawingSelectionForm.cs b/ExportDXF/Forms/DrawingSelectionForm.cs index 7d766f0..11549d9 100644 --- a/ExportDXF/Forms/DrawingSelectionForm.cs +++ b/ExportDXF/Forms/DrawingSelectionForm.cs @@ -10,22 +10,54 @@ namespace ExportDXF.Forms public partial class DrawingSelectionForm : Form { private readonly ICutFabApiClient _apiClient; + private readonly ISolidWorksService _solidWorksService; public int? SelectedDrawingId { get; private set; } public string SelectedDrawingNumber { get; private set; } - public DrawingSelectionForm(ICutFabApiClient apiClient) + public DrawingSelectionForm(ICutFabApiClient apiClient, ISolidWorksService solidWorksService) { _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient)); + _solidWorksService = solidWorksService ?? throw new ArgumentNullException(nameof(solidWorksService)); + _solidWorksService.ActiveDocumentChanged += (s, e) => DisplayActiveDrawing(); InitializeComponent(); } protected override async void OnLoad(EventArgs e) { base.OnLoad(e); + DisplayActiveDrawing(); await LoadEquipmentAsync(); } + private void DisplayActiveDrawing() + { + try + { + var activeDoc = _solidWorksService.GetActiveDocument(); + if (activeDoc != null && activeDoc.DocumentType == Models.DocumentType.Drawing) + { + currentDrawingLabel.Text = $"Active Drawing: {activeDoc.Title}"; + currentDrawingLabel.ForeColor = Color.Green; + } + else if (activeDoc != null) + { + currentDrawingLabel.Text = $"Active Document: {activeDoc.Title} (Not a Drawing)"; + currentDrawingLabel.ForeColor = Color.Orange; + } + else + { + currentDrawingLabel.Text = "No active SolidWorks document"; + currentDrawingLabel.ForeColor = Color.Gray; + } + } + catch (Exception ex) + { + currentDrawingLabel.Text = $"Error getting active document: {ex.Message}"; + currentDrawingLabel.ForeColor = Color.Red; + } + } + private async Task LoadEquipmentAsync() { try