schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using DataEntity.Device;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XImagingXhandler.XDAL;
using Newtonsoft.Json;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
 
namespace XImagingXhandler.XDAL
{
    /// <summary>
    /// 绑定到实验方法流程节点的实体基类
    /// </summary>
    public class MethodEx : Method, ICloneable
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MethodEx()
        {
            Children = new ObservableCollection<MethodEx>();
            Parent = null;
            Level = 0;
        }
 
        /// <summary>
        /// 带参构造函数,初始化参数属性值
        /// </summary>
        /// <param name="method">命令方法实体对象</param>
        public MethodEx(Method method)
        {
            this.method_id = method.method_id;
            this.method_name = method.method_name;
            this.method_status = method.method_status;
            this.method_content = method.method_content;
            this.method_Tipcontent = method.method_Tipcontent;
            this.method_ico = method.method_ico;
            this.method_group_id = method.method_group_id;
            this.method_support = method.method_support;
            this.method_type = method.method_type;
            Children = new ObservableCollection<MethodEx>();
            Parent = null;
            Level = 0;
            Moveable = true;
            canDrop = true;
            control = null;
            tag = null;
            isEnabled = true;
        }
 
        /// <summary>
        /// 带参构造函数,初始化参数属性值
        /// </summary>
        /// <param name="method">命令方法实体对象</param>
        /// <param name="parentItem">父节点命令对象</param>
        public MethodEx(Method method, MethodEx parentItem)
        {
            this.method_id = method.method_id;
            this.method_name = method.method_name;
            this.method_status = method.method_status;
            this.method_content = method.method_content;
            this.method_Tipcontent = method.method_Tipcontent;
            this.method_ico = method.method_ico;
            this.method_group_id = method.method_group_id;
            this.method_support = method.method_support;
            this.method_type = method.method_type;
            Children = new ObservableCollection<MethodEx>();
            Parent = parentItem;
            Level = parentItem.Level + 1;
            Moveable = true;
            canDrop = true;
            control = null;
            tag = null;
            isEnabled = true;
        }
        /// <summary>
        /// 带参构造函数,初始化参数属性值
        /// </summary>
        /// <param name="method">命令方法实体对象</param>
        /// <param name="parentItem">父节点命令对象</param>
        /// <param name="isDeepCopy">是否深拷贝,true:false</param>
        public MethodEx(MethodEx method, MethodEx parentItem,bool isDeepCopy)
        {
            this.method_id = method.method_id;
            this.method_name = method.method_name;
            this.method_status = method.method_status;
            this.method_content = method.method_content;
            this.method_Tipcontent = method.method_Tipcontent;
            this.method_ico = method.method_ico;
            this.method_group_id = method.method_group_id;
            this.method_support = method.method_support;
            this.method_type = method.method_type;
            Children = new ObservableCollection<MethodEx>();
            Parent = parentItem;
            Level = parentItem.Level + 1;
            Moveable = true;
            canDrop = true;
            control = method.control;
            tag = method.tag;
            isEnabled = true;
        }
 
        /// <summary>
        /// 运行起点
        /// </summary>
        private string _method_isrun = "";
        public string method_isrun
        {
            get { return _method_isrun; }
            set
            {
                _method_isrun = value;
                OnPropertyChanged(nameof(method_isrun));
            }
        }
 
        /// <summary>
        /// 索引值
        /// </summary>
        private int _index;
        public int Index
        {
            get { return _index; }
            set
            {
                _index = value;
                OnPropertyChanged("Index");
            }
        }
 
        private string _strIndex;
        /// <summary>
        /// 实验流程中节点位置编号
        /// </summary>
        public string strIndex
        {
            get { return _strIndex; }
            set
            {
                _strIndex = value;
                OnPropertyChanged("strIndex");
            }
        }
 
        /// <summary>
        /// 方法的层级
        /// </summary>
        private int _level;
        public int Level
        {
            get { return _level; }
            set
            {
                _level = value;
                OnPropertyChanged("Level");
            }
        }
 
        /// <summary>
        /// 该方法是否可以移动
        /// </summary>
        public bool Moveable { get; set; }
 
        /// <summary>
        /// 父节点对象
        /// </summary>
        public MethodEx Parent
        {
            get;
            set;
        }
 
        /// <summary>
        /// 该方法是否能drop
        /// </summary>
        public bool canDrop { get; set; }
 
        /// <summary>
        /// 孩子节点对象集合
        /// </summary>
        public ObservableCollection<MethodEx> Children
        {
            get;
            set;
        }
 
        /// <summary>
        /// 加载Shared.AllNodeMethod所有子方法时,子方法存储位置。不能存在Children里,不然页面加载会有异常!!!
        /// </summary>
        public MethodEx SubMethod
        {
            get;
            set;
        }
 
        /// <summary>
        /// 设置节点的父节点
        /// </summary>
        /// <param name="parent"></param>
        public void SetParent(MethodEx parent)
        {
            this.Parent = parent;
            this.Level = parent.Level + 1;
        }
 
        private bool _isSelected = false;
        /// <summary>
        /// 节点是否被选中
        /// </summary>
        public bool isSelected
        {
            get { return _isSelected; }
            set
            {
                _isSelected = value;
                OnPropertyChanged("isSelected");
            }
        }
 
        private bool _isEnabled;
        /// <summary>
        /// 是否被禁用
        /// </summary>
        public bool isEnabled
        {
            get { return _isEnabled; }
            set
            {
                _isEnabled = value;
                OnPropertyChanged("isEnabled");
            }
        }
 
        private string _groupID;
        /// <summary>
        /// 用以标注这个方法的开始和结束2个节点是同一组节点
        /// </summary>
        public string groupID
        {
            get { return _groupID; }
            set
            {
                _groupID = value;
                OnPropertyChanged("groupID");
            }
        }
 
        private int _isError;
        /// <summary>
        /// 产生错误节点
        /// </summary>
        public int IsError
        {
            get { return _isError; }
            set
            {
                _isError = value;
                OnPropertyChanged("IsError");
            }
        }
 
        /// <summary>
        /// UI对象
        /// </summary>
        public object control { get; set; }
 
        /// <summary>
        /// 保存属性实体
        /// </summary>
        public object tag { get; set; }
 
        /// <summary>
        /// 设备信息
        /// </summary>
        public DeviceConfigModel device { get; set; }
 
        public object Clone()
        {
            return (object)this.MemberwiseClone();
        }
 
        public object CloneDeep()
        {
            // 将对象转换为JSON字符串
            string json = JsonConvert.SerializeObject(this);
 
            // 将JSON字符串转换回对象
            return JsonConvert.DeserializeObject(json, this.GetType());
        }
 
        public static T DeepCopy<T>(T obj)
        {
            object retval;
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                //序列化成流
                bf.Serialize(ms, obj);
                ms.Seek(0, SeekOrigin.Begin);
                //反序列化成对象
                retval = bf.Deserialize(ms);
                ms.Close();
            }
            return (T)retval;
        }
    }
}