清理ColorPicker,进度条。修复UI问题

This commit is contained in:
2026-02-23 16:49:34 +08:00
parent 1d939d52ed
commit 18174b404c
29 changed files with 1028 additions and 576 deletions

View File

@@ -231,5 +231,51 @@ namespace ShrlAlgoToolkit.RevitCore.Extensions
options.SetFailuresPreprocessor(failuresPreprocessor);
ts.SetFailureHandlingOptions(options);
}
/// <summary>
/// 封装普通事务
/// </summary>
public static void InvokeInTransaction(this Document doc, Action action, string transactionName = "DefaultTransaction")
{
using (Transaction t = new Transaction(doc, transactionName))
{
t.Start();
try
{
action();
t.Commit();
}
catch (Exception)
{
if (t.GetStatus() == TransactionStatus.Started)
t.RollBack();
throw; // 将异常向上抛出
}
}
}
/// <summary>
/// 封装事务组 (TransactionGroup)
/// </summary>
public static void InvokeInTransactionGroup(this Document doc, Action action, string groupName = "DefaultGroup", bool assimilate = true)
{
using (TransactionGroup tg = new TransactionGroup(doc, groupName))
{
tg.Start();
try
{
action();
if (assimilate)
tg.Assimilate(); // 融合所有子事务
else
tg.Commit();
}
catch (Exception)
{
if (tg.GetStatus() == TransactionStatus.Started)
tg.RollBack();
throw;
}
}
}
}
}