diff --git a/ExportDXF/DrawingInfo.cs b/ExportDXF/DrawingInfo.cs index c05083f..bcfddc5 100644 --- a/ExportDXF/DrawingInfo.cs +++ b/ExportDXF/DrawingInfo.cs @@ -1,3 +1,4 @@ +using System.IO; using System.Text.RegularExpressions; namespace ExportDXF @@ -13,6 +14,35 @@ namespace ExportDXF public string Source { get; set; } + /// + /// The descriptive text after the equipment/drawing number (e.g. "Prox switch bracket for drive"). + /// + public string Description + { + get + { + if (string.IsNullOrEmpty(Source) || string.IsNullOrEmpty(EquipmentNo)) + return null; + + // Strip equipment number (and optional drawing number) from the source to get the description + var prefix = string.IsNullOrEmpty(DrawingNo) + ? EquipmentNo + : EquipmentNo + " " + DrawingNo; + + var desc = Source; + if (desc.StartsWith(prefix, System.StringComparison.OrdinalIgnoreCase)) + desc = desc.Substring(prefix.Length); + + // Remove file extension (e.g. ".SLDPRT") + var ext = Path.GetExtension(desc); + if (!string.IsNullOrEmpty(ext)) + desc = desc.Substring(0, desc.Length - ext.Length); + + desc = desc.Trim(); + return string.IsNullOrEmpty(desc) ? null : desc; + } + } + public override string ToString() { if (string.IsNullOrEmpty(DrawingNo)) diff --git a/ExportDXF/Forms/MainForm.cs b/ExportDXF/Forms/MainForm.cs index cf124a3..8c9c629 100644 --- a/ExportDXF/Forms/MainForm.cs +++ b/ExportDXF/Forms/MainForm.cs @@ -487,6 +487,9 @@ namespace ExportDXF.Forms equipmentBox.Text = drawingInfo.EquipmentNo; } + if (string.IsNullOrEmpty(titleBox.Text) && !string.IsNullOrEmpty(drawingInfo.Description)) + titleBox.Text = drawingInfo.Description; + // Load drawings for the selected equipment, then set drawing number await UpdateDrawingDropdownAsync();