lixiaojun
5 天以前 1c4e474ff6a0ae6cf1b1f7a9de71b3246aba29b6
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
namespace Yw.WpfUI.Hydro
{
    /// <summary>
    /// 绘制编辑管理器
    /// </summary>
    internal class DrawEditManager : DrawManager
    {
        /// <summary>
        /// 
        /// </summary>
        public DrawEditManager(HelixViewport3D viewport) : base(viewport)
        {
            _moudingHelper = new DrawMoudingHelper(viewport, _initialHelper);
            _addHelper = new DrawAddHelper(viewport, _initialHelper, _workPanelHelper, _highlightHelper, _selectionHelper, _moudingHelper);
            _addHelper.AddChangedEvent += OnAddChanged;
            _editHelper = new DrawEditHelper(viewport, _initialHelper, _selectionHelper);
            _editHelper.EditChangedEvent += OnEditChanged;
            _removeHelper = new DrawRemoveHelper(viewport, _initialHelper);
            _removeHelper.RemoveChangedEvent += OnRemoveChanged;
        }
 
 
        #region 事件集合
 
        /// <summary>
        /// 添加改变事件
        /// </summary>
        public event Action<VisualL3d> AddChangedEvent;
 
        /// <summary>
        /// 编辑改变事件
        /// </summary>
        public event Action<List<VisualL3d>> EditChangedEvent;
 
        /// <summary>
        /// 移除改变事件
        /// </summary>
        public event Action<List<VisualL3d>> RemoveChangedEvent;
 
        #endregion
 
        protected readonly DrawMoudingHelper _moudingHelper = null;//牟定辅助类
        protected readonly DrawAddHelper _addHelper = null;//添加辅助类
        protected readonly DrawEditHelper _editHelper = null;//编辑辅助类
        protected readonly DrawRemoveHelper _removeHelper = null;//移除辅助类
 
        #region 添加方法
 
        /// <summary>
        /// 设置添加模式
        /// </summary>
        public virtual void SetAddMode(eDrawAddWay addWay, eDrawAddType addType)
        {
            if (!Initialized)
            {
                return;
            }
            _addHelper.SetAddMode(addWay, addType);
        }
 
        /// <summary>
        /// 设置添加方式
        /// </summary>
        public virtual void SetAddWay(eDrawAddWay addWay)
        {
            if (!Initialized)
            {
                return;
            }
            _addHelper.SetAddWay(addWay);
        }
 
        /// <summary>
        /// 设置添加类型
        /// </summary>
        public virtual void SetAddType(eDrawAddType addType)
        {
            if (!Initialized)
            {
                return;
            }
            _addHelper.SetAddType(addType);
        }
 
        //处理添加改变
        protected virtual void OnAddChanged(VisualDraw3D visual3d)
        {
            if (visual3d == null)
            {
                return;
            }
            this.AddChangedEvent?.Invoke(visual3d.Visual);
        }
 
 
        #endregion
 
        #region 编辑方法
 
        /// <summary>
        /// 开始编辑
        /// </summary>
        public virtual void StartEdit()
        {
            if (!Initialized)
            {
                return;
            }
            _editHelper.Start();
        }
 
        /// <summary>
        /// 结束编辑
        /// </summary>
        public virtual void EndEdit()
        {
            if (!Initialized)
            {
                return;
            }
            _editHelper.End();
        }
 
        //处理编辑改变
        protected virtual void OnEditChanged(List<VisualDraw3D> visual3ds)
        {
            if (visual3ds == null || visual3ds.Count < 1)
            {
                return;
            }
            var visuals = visual3ds.Select(x => x.Visual).ToList();
            this.EditChangedEvent?.Invoke(visuals);
        }
 
        #endregion
 
        #region 移除方法
 
        /// <summary>
        /// 移除
        /// </summary>
        public virtual bool RemoveVisual(string Id)
        {
            if (!Initialized)
            {
                return false;
            }
            return _removeHelper.Remove(Id);
        }
 
        /// <summary>
        /// 移除
        /// </summary>
        public virtual bool RemoveVisual(List<string> Ids)
        {
            if (!Initialized)
            {
                return false;
            }
            if (Ids == null || Ids.Count < 1)
            {
                return false;
            }
            return _removeHelper.Remove(Ids);
        }
 
        //处理移除改变
        protected virtual void OnRemoveChanged(List<VisualDraw3D> visual3ds)
        {
            if (visual3ds == null || visual3ds.Count < 1)
            {
                return;
            }
            var visuals = visual3ds.Select(x => x.Visual).ToList();
            this.RemoveChangedEvent?.Invoke(visuals);
        }
 
        #endregion
 
        /// <summary>
        /// 关闭
        /// </summary>
        public override void Close()
        {
            _addHelper.AddChangedEvent -= OnAddChanged;
            _addHelper.Dispose();
            _editHelper.EditChangedEvent -= OnEditChanged;
            _editHelper.Dispose();
            _removeHelper.RemoveChangedEvent -= OnRemoveChanged;
            _removeHelper.Dispose();
            base.Close();
        }
 
 
 
    }
}