fix: 二钻涨缩系数记忆在写回钻带后立即落盘

原实现 Save 在'涨缩完成'MessageBox(模态阻塞)之后才执行,配置滞后到用户点掉弹窗。改为写回钻带后立即 Save,失败信息并入完成提示,避免两个连续模态框。
This commit is contained in:
2026-06-14 13:43:59 +08:00
parent fe3df98297
commit e27636dd93

View File

@@ -221,24 +221,27 @@ namespace DrillTools
using var writer = new StreamWriter(filePath, false, Encoding.GetEncoding(936)); using var writer = new StreamWriter(filePath, false, Encoding.GetEncoding(936));
writer.Write(scaledContent); writer.Write(scaledContent);
System.Windows.MessageBox.Show( // 系数记忆:紧跟钻带写回立即落盘,不滞后到完成提示之后。
$"涨缩完成,原文件已备份为:\n{Path.GetFileName(filePath)}.bak", // 属辅助功能,失败不回滚已完成的涨缩,失败原因随完成提示一并告知。
"涨缩完成", string? memoryWarning = null;
MessageBoxButton.OK,
MessageBoxImage.Information);
// 系数记忆:将本次模式与原始输入连同源文件名写入 ini供下次载入。
// 属辅助功能,失败不回滚已完成的涨缩,单独提示。
try try
{ {
ScalingProfileStore.Save(result.Mode, result.InputX, result.InputY, Path.GetFileName(filePath)); ScalingProfileStore.Save(result.Mode, result.InputX, result.InputY, Path.GetFileName(filePath));
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Windows.MessageBox.Show( memoryWarning = $"\n系数记忆保存失败{ex.Message}";
$"系数记忆保存失败:\n{ex.Message}\n本次涨缩已完成不影响结果。",
"系数记忆", MessageBoxButton.OK, MessageBoxImage.Warning);
} }
string completionMessage = $"涨缩完成,原文件已备份为:\n{Path.GetFileName(filePath)}.bak";
if (memoryWarning != null)
completionMessage += memoryWarning;
System.Windows.MessageBox.Show(
completionMessage,
"涨缩完成",
MessageBoxButton.OK,
MessageBoxImage.Information);
} }
catch (Exception ex) catch (Exception ex)
{ {