清理ColorPicker,进度条。修复UI问题
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using Melskin.Controls;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
using ShrlAlgoToolkit.RevitAddins.Common.Controls;
|
||||
using TaskDialog = Autodesk.Revit.UI.TaskDialog;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvFamily;
|
||||
|
||||
using ShrlAlgo.Addin.Test;
|
||||
|
||||
using ShrlAlgoToolkit;
|
||||
using ShrlAlgoToolkit.RevitAddins;
|
||||
using ShrlAlgoToolkit.RevitAddins.Common.Controls;
|
||||
using ShrlAlgoToolkit.RevitAddins.RvFamily;
|
||||
|
||||
using TaskDialog = Autodesk.Revit.UI.TaskDialog;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.General;
|
||||
|
||||
@@ -26,8 +34,27 @@ public class UpgradeFamilyCmd : ExternalCommand
|
||||
fileNames = GetSelectedFileNames();
|
||||
if (fileNames.Count > 0)
|
||||
{
|
||||
var progressMonitorViewModel = new ProgressBarManager<string>(UiDocument, fileNames, UpdateFile, "更新文件");
|
||||
progressMonitorViewModel.ProgressModal();
|
||||
ProgressManager.Run("批量更新文件", (reporter, token) =>
|
||||
{
|
||||
// 利用之前封装的 TransactionExtensions 开启事务
|
||||
Document.InvokeInTransaction(() =>
|
||||
{
|
||||
for (int i = 0; i < fileNames.Count; i++)
|
||||
{
|
||||
// 检查用户是否点击了“取消”
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var fileName = fileNames[i];
|
||||
|
||||
UpdateFile(UiDocument, fileName);
|
||||
|
||||
reporter.Report(i + 1, fileNames.Count, $"正在更新: {fileName}");
|
||||
|
||||
// 如果逻辑非常非常耗时,可以考虑在这里短暂休眠让出一点点CPU(通常不用加)
|
||||
// Thread.Sleep(1);
|
||||
}
|
||||
}, "更新文件");
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -107,7 +134,7 @@ public class UpgradeFamilyCmd : ExternalCommand
|
||||
return list;
|
||||
}
|
||||
|
||||
private void UpdateFile(UIDocument uidoc, string filename, object obj)
|
||||
private void UpdateFile(UIDocument uidoc, string filename)
|
||||
{
|
||||
System.Threading.Thread.Sleep(50);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user