清理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

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace ShrlAlgoToolkit.RevitAddins.Common.Controls
{
// 用于给外界调用的报告器
public class ProgressReporter
{
private readonly ProgressViewModel _viewModel;
private DateTime _lastUpdate = DateTime.MinValue;
public ProgressReporter(ProgressViewModel viewModel)
{
_viewModel = viewModel;
}
/// <summary>
/// 更新进度 (自带节流控制防止频繁更新导致UI卡顿)
/// </summary>
public void Report(int current, int total, string message = null)
{
// 限制 UI 刷新频率(每 50 毫秒最多刷新一次)
if ((DateTime.Now - _lastUpdate).TotalMilliseconds < 50 && current != total)
return;
_lastUpdate = DateTime.Now;
_viewModel.Update(current, total, message);
}
public void ReportMessage(string message) => _viewModel.UpdateMessage(message);
}
}