lixiaojun
2025-04-14 8b09bd446ed21cc7dc29f301c9102adaa98b76f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
namespace Yw.WpfUI.Hydro
{
    /// <summary>
    /// 抽象覆盖颜色辅助类
    /// </summary>
    internal class LogicalOverrideColorHelper
    {
        private readonly Dictionary<VisualL3d, string> _cache = new();
 
        /// <summary>
        /// 获取颜色
        /// </summary>
        public string GetColor(VisualL3d visual)
        {
            if (!_cache.ContainsKey(visual))
            {
                return default;
            }
            return _cache[visual];
        }
 
        /// <summary>
        /// 设置颜色
        /// </summary>
        public void SetColor(VisualL3d visual, string htmlColor)
        {
            _cache[visual] = htmlColor;
        }
 
        /// <summary>
        /// 设置颜色
        /// </summary>
        public void SetColor(List<VisualL3d> visuals, string htmlColor)
        {
            visuals?.ForEach(x => _cache[x] = htmlColor);
        }
 
        /// <summary>
        /// 清理颜色
        /// </summary>
        public void ClearColor(VisualL3d visual)
        {
            if (!_cache.ContainsKey(visual))
            {
                return;
            }
            _cache.Remove(visual);
        }
 
        /// <summary>
        /// 清理颜色
        /// </summary>
        public void ClearColor(List<VisualL3d> visuals)
        {
            visuals?.ForEach(x => ClearColor(x));
        }
 
 
    }
}