feat: 新增 ParamDrawingPanel UI 组件
This commit is contained in:
parent
467db9c31d
commit
8d0dde58b5
@ -532,6 +532,50 @@ namespace CadParamPluging.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------- 新增:提示用户保存参数文档 ---------
|
||||||
|
using (var saveDialog = new SaveFileDialog())
|
||||||
|
{
|
||||||
|
saveDialog.Filter = "文本文件 (*.txt)|*.txt";
|
||||||
|
string docName = System.IO.Path.GetFileNameWithoutExtension(doc.Name);
|
||||||
|
saveDialog.FileName = $"{docName}_生成参数.txt";
|
||||||
|
|
||||||
|
if (saveDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sb = new System.Text.StringBuilder();
|
||||||
|
sb.AppendLine("========== CAD图纸生成参数 ==========");
|
||||||
|
sb.AppendLine($"生成时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||||
|
sb.AppendLine($"关联图纸: {docName}");
|
||||||
|
sb.AppendLine("------------------------------------");
|
||||||
|
|
||||||
|
// 从 catalog 中获取中文名称映射
|
||||||
|
var catalogForSave = ParamCatalogStore.Load();
|
||||||
|
|
||||||
|
// 这里的 bag 已经在上面收集完成
|
||||||
|
foreach (var item in bag.Items)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(item.Value))
|
||||||
|
{
|
||||||
|
var def = catalogForSave?.FindByKey(item.Key);
|
||||||
|
string label = def != null ? def.Label : item.Key;
|
||||||
|
sb.AppendLine($"{label}: {item.Value}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.AppendLine("====================================");
|
||||||
|
|
||||||
|
System.IO.File.WriteAllText(saveDialog.FileName, sb.ToString(), System.Text.Encoding.UTF8);
|
||||||
|
AppendLog($"参数文档已保存至: {saveDialog.FileName}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AppendLog($"保存参数文档失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ---------------------------------------------
|
||||||
|
|
||||||
AppendLog("图纸生成完成。");
|
AppendLog("图纸生成完成。");
|
||||||
}
|
}
|
||||||
catch (BusinessException bex)
|
catch (BusinessException bex)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user