alielie
2025-11-21 3a471ae651b228231bebb3a2d438baa1d4ac0261
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
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace HMI.UI.Util
{
    public class MaskHolder
    {
        private static Dictionary<WindowX, List<object>> Container;
        private static Dictionary<object, WindowX> ReverseContainer;
 
        public static void AddMask(WindowX window, object source)
        {
            if (Container.ContainsKey(window))
            {
                Container[window].Add(source);
            }
            else
            {
                Container[window] = new List<object> { source };
            }
            ReverseContainer.Add(source, window);
            window.IsMaskVisible = true;
        }
 
        public static void RemoveMask(object source)
        {
            if (!ReverseContainer.ContainsKey(source))
            {
                return;
            }
            WindowX win = ReverseContainer[source];
            if (!Container.ContainsKey(win) || Container[win] == null || Container[win].Count <= 0)
            {
                win.IsMaskVisible = false;
            }
            ReverseContainer.Remove(source);
        }
    }
}