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:
@@ -10,22 +10,54 @@ namespace ExportDXF.Forms
|
|||||||
public partial class DrawingSelectionForm : Form
|
public partial class DrawingSelectionForm : Form
|
||||||
{
|
{
|
||||||
private readonly ICutFabApiClient _apiClient;
|
private readonly ICutFabApiClient _apiClient;
|
||||||
|
private readonly ISolidWorksService _solidWorksService;
|
||||||
|
|
||||||
public int? SelectedDrawingId { get; private set; }
|
public int? SelectedDrawingId { get; private set; }
|
||||||
public string SelectedDrawingNumber { 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));
|
_apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||||
|
_solidWorksService = solidWorksService ?? throw new ArgumentNullException(nameof(solidWorksService));
|
||||||
|
_solidWorksService.ActiveDocumentChanged += (s, e) => DisplayActiveDrawing();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnLoad(EventArgs e)
|
protected override async void OnLoad(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
DisplayActiveDrawing();
|
||||||
await LoadEquipmentAsync();
|
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()
|
private async Task LoadEquipmentAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user