lixiaojun
6 天以前 d6f1a8535c0030e282f823f0e9b3d6e56e32e474
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
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;
        }
 
 
        #region 事件集合
 
        /// <summary>
        /// 添加改变事件
        /// </summary>
        public event Action<VisualL3d> AddChangedEvent;
 
        /// <summary>
        /// 编辑改变事件
        /// </summary>
        public event Action<List<VisualL3d>> EditChangedEvent;
 
        #endregion
 
        protected readonly DrawMoudingHelper _moudingHelper = null;//牟定辅助类
        protected readonly DrawAddHelper _addHelper = null;//添加辅助类
        protected readonly DrawEditHelper _editHelper = 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()
        {
            _editHelper.Start();
        }
 
        /// <summary>
        /// 结束编辑
        /// </summary>
        public virtual void EndEdit()
        {
            _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
 
        /// <summary>
        /// 关闭
        /// </summary>
        public override void Close()
        {
            _addHelper.AddChangedEvent -= OnAddChanged;
            _addHelper.Dispose();
            _editHelper.EditChangedEvent -= OnEditChanged;
            _editHelper.Dispose();
            base.Close();
        }
 
 
 
    }
}