lixiaojun
2024-11-23 979fa511e23ad4cb8d7e25b813aade4aaec45535
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using Yw.Vmo;
using Yw.WinFrmUI.Bimface;
 
namespace HStation.WinFrmUI
{
    /// <summary>
    /// 监测标记辅助类
    /// </summary>
    public class SimulationMonitorMarkerHelper
    {
        /// <summary>
        /// 
        /// </summary>
        public SimulationMonitorMarkerHelper(SimulationMonitorHelper monitorHelper, ISimulationMonitorMarkerView view)
        {
            _monitorHelper = monitorHelper;
            _views = new List<ISimulationMonitorMarkerView>() { view };
        }
 
        private SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
        private List<ISimulationMonitorMarkerView> _views = null;//视图列表
        private List<LogicMonitorMarker> _allMarkerList = null;//所有标记列表
 
        /// <summary>
        /// 是否可见
        /// </summary>
        public bool Visible
        {
            get { return _visible; }
            set { _visible = value; }
        }
        private bool _visible = false;
 
        /// <summary>
        /// 获取
        /// </summary>
        public async Task<List<LogicMonitorMarker>> Get()
        {
            var allMonitorList = await _monitorHelper.Get();
            _allMarkerList = allMonitorList?.Select(x => new LogicMonitorMarker()
            {
                Id = x.Relation,
                PropName = x.PropName,
                Description = x.Description
            }).ToList();
            return _allMarkerList;
        }
 
        /// <summary>
        /// 更新
        /// </summary>
        public async void Update(string code, List<HydroMonitorVmo> monitorList)
        {
            var allMarkerList = await Get();
            var markerList = allMarkerList.Where(x => x.Id == code).ToList();
            markerList?.ForEach(x =>
            {
                var result = monitorList?.Exists(t => t.Relation == x.Id && t.PropName == x.PropName);
                if (!(result.HasValue && result.Value))
                {
                    allMarkerList.Remove(x);
                }
            });
            monitorList?.ForEach(x =>
            {
                var result = markerList?.Exists(t => t.Id == x.Relation && t.PropName == x.PropName);
                if (!(result.HasValue && result.Value))
                {
                    var vm = new LogicMonitorMarker()
                    {
                        Id = x.Relation,
                        PropName = x.PropName,
                        Description = x.Description
                    };
                    allMarkerList.Add(vm);
                }
            });
        }
 
        /// <summary>
        /// 设置
        /// </summary>
        public async void Set()
        {
            if (this.Visible)
            {
                var allMarkerList = await Get();
                _views.ForEach(x => x.SetLogicMonitors(allMarkerList));
            }
            else
            {
                _views.ForEach(x => x.ClearLogicMonitors());
            }
        }
 
 
 
 
    }
}