feat(ui): display active SolidWorks drawing in DrawingSelectionForm

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 <noreply@anthropic.com>
This commit is contained in:
2025-11-04 09:58:48 -05:00
parent 8b1c2b5b1b
commit 136a571aea

View File

@@ -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