프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / BaseModel / Document.cs @ 8829d0c5

이력 | 보기 | 이력해설 | 다운로드 (22.6 KB)

1 96a2080c gaqhf
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.IO;
7
using System.Xml.Linq;
8
using System.Windows.Forms;
9
10
namespace Converter.BaseModel
11
{
12
    public class Document
13
    {
14
        private string _DWGNAME;
15
        private string _SIZE;
16 39a2a688 gaqhf
        private double _SIZE_WIDTH;
17
        private double _SIZE_HEIGHT;
18 60244a8b gaqhf
        private List<Symbol> _SYMBOLS = new List<Symbol>();
19
        private List<Text> _TEXTINFOS = new List<Text>();
20
        private List<Note> _NOTES = new List<Note>();
21
        private List<Line> _LINES = new List<Line>();
22
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
23 8aa6f2db gaqhf
        private List<TrimLine> _TRIMLINES = new List<TrimLine>();
24 f1c9dbaa gaqhf
        private List<EndBreak> _EndBreaks = new List<EndBreak>();
25 53c81765 gaqhf
        private List<SpecBreak> _SpecBreaks = new List<SpecBreak>();
26 f1c9dbaa gaqhf
        private List<Equipment> _Equipments = new List<Equipment>();
27 60244a8b gaqhf
        private bool _Enable;
28
29
        public bool Enable { get { return _Enable; } }
30 96a2080c gaqhf
31
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
32
        public List<Text> TEXTINFOS { get => _TEXTINFOS; set => _TEXTINFOS = value; }
33
        public List<Note> NOTES { get => _NOTES; set => _NOTES = value; }
34
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
35
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
36 f1c9dbaa gaqhf
        public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
37 53c81765 gaqhf
        public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; }
38 f1c9dbaa gaqhf
        public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
39 96a2080c gaqhf
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
40 39a2a688 gaqhf
        public string SIZE
41
        {
42
            get
43
            {
44
                return _SIZE;
45
            }
46
            set
47
            {
48
                _SIZE = value;
49
                string[] pointArr = _SIZE.Split(new char[] { ',' });
50
                if (pointArr.Length == 2)
51
                {
52
                    _SIZE_WIDTH = Convert.ToDouble(pointArr[0]);
53
                    _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]);
54
                }
55
            }
56
        }
57
        public double SIZE_WIDTH { get => _SIZE_WIDTH; }
58
        public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
59 8aa6f2db gaqhf
        public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; }
60 e8536f2b gaqhf
        public string PATH { get; set; }
61 96a2080c gaqhf
62
        public Document(string xmlPath)
63
        {
64
            try
65
            {
66 88bac50c gaqhf
                if (xmlPath != null)
67
                {
68
                    PATH = xmlPath;
69
                    XElement xml = XElement.Load(xmlPath);
70
                    DWGNAME = xml.Element("DWGNAME").Value;
71
                    SIZE = xml.Element("SIZE").Value;
72 96a2080c gaqhf
73 88bac50c gaqhf
                    SetText(xml.Element("TEXTINFOS"));
74
                    SetNote(xml.Element("NOTES"));
75
                    SetSymbol(xml.Element("SYMBOLS"));
76
                    SetLine(xml.Element("LINEINFOS"));
77
                    SetLineNumber(xml.Element("LINENOS"));
78
                    SetTrimLine(xml.Element("TRIMLINENOS"));
79 60244a8b gaqhf
80 88bac50c gaqhf
                    _Enable = true;
81
                }
82 96a2080c gaqhf
            }
83
            catch (Exception ex)
84
            {
85 60244a8b gaqhf
                _Enable = false;
86 96a2080c gaqhf
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
87
            }
88
        }
89
90 60244a8b gaqhf
        #region READ XML
91 96a2080c gaqhf
        private void SetSymbol(XElement node)
92
        {
93
            foreach (XElement item in node.Elements("SYMBOL"))
94
            {
95 f1c9dbaa gaqhf
                string sType = item.Element("TYPE").Value;
96
                if (sType == "Segment Breaks")
97 96a2080c gaqhf
                {
98 53c81765 gaqhf
                    SpecBreak specBreak = new SpecBreak()
99
                    {
100
                        UID = item.Element("UID").Value,
101
                        DBUID = item.Element("DBUID").Value,
102
                        NAME = item.Element("NAME").Value,
103
                        TYPE = item.Element("TYPE").Value,
104
                        OWNER = item.Element("OWNER").Value,
105
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
106
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
107
                        LOCATION = item.Element("LOCATION").Value,
108
                        SIZE = item.Element("SIZE").Value,
109
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
110
                        PARENT = item.Element("PARENT").Value,
111
                        CHILD = item.Element("CHILD").Value,
112
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
113
                        AREA = item.Element("AREA").Value,
114
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
115
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
116
                    };
117
                    SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS);
118
                    SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT);
119
                    SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES);
120
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
121
                    SetSpecBreakAttribute(specBreak);
122
123
                    SpecBreaks.Add(specBreak);
124 f1c9dbaa gaqhf
                }
125
                else if (sType == "End Break")
126
                {
127
                    EndBreak endBreak = new EndBreak()
128
                    {
129
                        UID = item.Element("UID").Value,
130
                        DBUID = item.Element("DBUID").Value,
131
                        NAME = item.Element("NAME").Value,
132
                        TYPE = item.Element("TYPE").Value,
133
                        OWNER = item.Element("OWNER").Value,
134
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
135
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
136
                        LOCATION = item.Element("LOCATION").Value,
137
                        SIZE = item.Element("SIZE").Value,
138
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
139
                        PARENT = item.Element("PARENT").Value,
140
                        CHILD = item.Element("CHILD").Value,
141
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
142
                        AREA = item.Element("AREA").Value,
143
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
144
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
145
                    };
146
                    SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
147
                    SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
148
                    SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
149
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
150
151
                    EndBreaks.Add(endBreak);
152
                }
153
                else if (sType == "Black Box System" ||
154
                    sType == "GGO_Equipment" ||
155
                    sType == "Heat Transfer Equipment" ||
156
                    sType == "Mechanical" ||
157
                    sType == "Other Equipment" ||
158
                    sType == "Vessels")
159
                {
160
                    Equipment equipment = new Equipment()
161
                    {
162
                        UID = item.Element("UID").Value,
163
                        DBUID = item.Element("DBUID").Value,
164
                        NAME = item.Element("NAME").Value,
165
                        TYPE = item.Element("TYPE").Value,
166
                        OWNER = item.Element("OWNER").Value,
167
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
168
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
169
                        LOCATION = item.Element("LOCATION").Value,
170
                        SIZE = item.Element("SIZE").Value,
171
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
172
                        PARENT = item.Element("PARENT").Value,
173
                        CHILD = item.Element("CHILD").Value,
174
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
175
                        AREA = item.Element("AREA").Value,
176
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
177
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
178
                    };
179
                    SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
180
                    SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
181
                    SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
182
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
183 bca81f4c gaqhf
184 f1c9dbaa gaqhf
                    Equipments.Add(equipment);
185
                }
186
                else
187
                {
188
                    Symbol symbol = new Symbol()
189
                    {
190
                        UID = item.Element("UID").Value,
191
                        DBUID = item.Element("DBUID").Value,
192
                        NAME = item.Element("NAME").Value,
193
                        TYPE = item.Element("TYPE").Value,
194
                        OWNER = item.Element("OWNER").Value,
195
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
196
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
197
                        LOCATION = item.Element("LOCATION").Value,
198
                        SIZE = item.Element("SIZE").Value,
199
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
200
                        PARENT = item.Element("PARENT").Value,
201
                        CHILD = item.Element("CHILD").Value,
202
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
203
                        AREA = item.Element("AREA").Value,
204
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
205
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
206
                    };
207 8aa6f2db gaqhf
208 f1c9dbaa gaqhf
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
209
                    SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
210
                    SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
211
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
212
                    SetChildSymbol(symbol);
213
214
                    SYMBOLS.Add(symbol);
215
                }
216 96a2080c gaqhf
            }
217
        }
218
219
        private void SetLine(XElement node)
220
        {
221
            foreach (XElement item in node.Elements("LINE"))
222
            {
223 60244a8b gaqhf
                Line line = new Line()
224 96a2080c gaqhf
                {
225 60244a8b gaqhf
                    OWNER = item.Attribute("OWNER").Value,
226
                    UID = item.Element("UID").Value,
227
                    STARTPOINT = item.Element("STARTPOINT").Value,
228
                    ENDPOINT = item.Element("ENDPOINT").Value,
229
                    TYPE = item.Element("TYPE").Value,
230 30d2cfcc gaqhf
                    TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value,
231 60244a8b gaqhf
                    AREA = item.Element("AREA").Value,
232
                    THICKNESS = item.Element("THICKNESS").Value,
233
                };
234 b2d1c1aa gaqhf
                int flowMarkPercent = 0;
235
                if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent))
236
                {
237
                    line.FLOWMARK = true;
238
                    line.FLOWMARK_PERCENT = flowMarkPercent;
239
                }
240
                else
241
                    line.FLOWMARK = false;
242
243 0860c756 gaqhf
                SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS);
244 cfda1fed gaqhf
                SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
245 0860c756 gaqhf
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES);
246 60244a8b gaqhf
                LINES.Add(line);
247 96a2080c gaqhf
            }
248
        }
249
250
        private void SetLineNumber(XElement node)
251
        {
252
            foreach (XElement item in node.Elements("LINE_NO"))
253
            {
254 3734dcc5 gaqhf
                LineNumber lineNumber = new LineNumber()
255 96a2080c gaqhf
                {
256 3734dcc5 gaqhf
                    UID = item.Element("UID").Value,
257
                    TEXT = item.Element("TEXT").Value,
258
                    LOCATION = item.Element("LOCATION").Value,
259
                    WIDTH = item.Element("WIDTH").Value,
260
                    HEIGHT = item.Element("HEIGHT").Value,
261
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
262
                    AREA = item.Element("AREA").Value,
263
                    SCENE = item.Element("SCENE").Value
264
                };
265
                if (item.Element("CONNLINE") != null)
266
                    lineNumber.CONNLINE = item.Element("CONNLINE").Value;
267
268
                SetLineNumberRuns(item, lineNumber.RUNS);
269
                SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES);
270
                SetAttributes(item, lineNumber.ATTRIBUTES);
271
                LINENUMBERS.Add(lineNumber);
272 96a2080c gaqhf
            }
273
        }
274
275
        private void SetText(XElement node)
276
        {
277
            foreach (XElement item in node.Elements("ATTRIBUTE"))
278
            {
279 60244a8b gaqhf
                Text text = new Text()
280 96a2080c gaqhf
                {
281 60244a8b gaqhf
                    UID = item.Element("UID").Value,
282 ea80efaa gaqhf
                    OWNER = item.Element("OWNER").Value,
283 60244a8b gaqhf
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
284
                    NAME = item.Element("NAME").Value,
285
                    LOCATION = item.Element("LOCATION").Value,
286
                    VALUE = item.Element("VALUE").Value,
287
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
288
                    WIDTH = item.Element("WIDTH").Value,
289
                    HEIGHT = item.Element("HEIGHT").Value,
290 1a3a74a8 gaqhf
                    AREA = item.Element("AREA").Value,
291
                    SCENE = item.Element("SCENE").Value
292 60244a8b gaqhf
                };
293 96a2080c gaqhf
294 60244a8b gaqhf
                TEXTINFOS.Add(text);
295 96a2080c gaqhf
            }
296
        }
297
298
        private void SetNote(XElement node)
299
        {
300
            foreach (XElement item in node.Elements("ATTRIBUTE"))
301
            {
302 60244a8b gaqhf
                Note note = new Note()
303 96a2080c gaqhf
                {
304 60244a8b gaqhf
                    UID = item.Element("UID").Value,
305
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
306
                    NAME = item.Element("NAME").Value,
307
                    LOCATION = item.Element("LOCATION").Value,
308
                    VALUE = item.Element("VALUE").Value,
309
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
310
                    WIDTH = item.Element("WIDTH").Value,
311
                    HEIGHT = item.Element("HEIGHT").Value,
312 1a3a74a8 gaqhf
                    AREA = item.Element("AREA").Value,
313 fc0a8c33 gaqhf
                    SCENE = item.Element("SCENE").Value,
314
                    OWNER = item.Element("OWNER").Value
315 60244a8b gaqhf
                };
316 96a2080c gaqhf
317 60244a8b gaqhf
                NOTES.Add(note);
318
            }
319
        }
320 8aa6f2db gaqhf
321
        private void SetTrimLine(XElement node)
322
        {
323
            foreach (XElement item in node.Elements("TRIM_LINE_NO"))
324
            {
325
                TrimLine trimLine = new TrimLine()
326
                {
327
                    UID = item.Element("UID").Value,
328
                };
329
                SetLineNumberRuns(item, trimLine.RUNS);
330
                TRIMLINES.Add(trimLine);
331
            }
332
        }
333
334 60244a8b gaqhf
        private void SetAssociations(XElement node, List<Association> associations)
335
        {
336
            foreach (XElement item in node.Elements("ASSOCIATION"))
337
            {
338 ea80efaa gaqhf
                Association association = new Association()
339 60244a8b gaqhf
                {
340
                    TYPE = item.Attribute("TYPE").Value,
341
                    VALUE = item.Value
342 ea80efaa gaqhf
                };
343
344
                associations.Add(association);
345 96a2080c gaqhf
            }
346
        }
347 60244a8b gaqhf
348
        private void SetConnectors(XElement node, List<Connector> connectors)
349
        {
350
            foreach (XElement item in node.Elements("CONNECTOR"))
351
            {
352
                connectors.Add(new Connector()
353
                {
354
                    UID = item.Attribute("UID").Value,
355
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
356 bca81f4c gaqhf
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
357
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
358
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
359
                });
360
            }
361
        }
362
363
        private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT)
364
        {
365
            foreach (XElement item in node.Elements("CONNECTOR"))
366
            {
367
                connectors.Add(new Connector()
368
                {
369
                    UID = item.Attribute("UID").Value,
370
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
371 60244a8b gaqhf
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
372
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
373
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
374
                });
375
            }
376
        }
377
378
        private void SetProperties(XElement node, List<Property> properties)
379
        {
380
            foreach (XElement item in node.Elements("PROPERTY"))
381
            {
382 30d2cfcc gaqhf
                properties.Add(new Property()
383 60244a8b gaqhf
                {
384 30d2cfcc gaqhf
                    UID = item.Attribute("UID").Value,
385
                    LENGTH = item.Attribute("Length").Value,
386
                    EXPRESSION = item.Attribute("Expression").Value,
387
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
388
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
389
                    ATTRIBUTE = item.Attribute("Attribute").Value,
390
                    VALUE = item.Value
391
                });
392 60244a8b gaqhf
            }
393
        }
394
395
        private void SetAttributes(XElement node, List<Attribute> attributes)
396
        {
397 30d2cfcc gaqhf
            foreach (XElement item in node.Elements("ATTRIBUTE"))
398 60244a8b gaqhf
            {
399 73415441 gaqhf
                Attribute attribute = new Attribute()
400 60244a8b gaqhf
                {
401
                    UID = item.Attribute("UID").Value,
402
                    LENGTH = item.Attribute("Length").Value,
403
                    EXPRESSION = item.Attribute("Expression").Value,
404
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
405
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
406
                    ATTRIBUTE = item.Attribute("Attribute").Value,
407 30d2cfcc gaqhf
                    ATTRAT = item.Attribute("AttrAt").Value,
408 73415441 gaqhf
                    ASSOCITEM = item.Attribute("AssocItem").Value,
409 60244a8b gaqhf
                    VALUE = item.Value
410 73415441 gaqhf
                };
411
412
                attributes.Add(attribute);
413
414
                if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None")
415
                {
416
                    Text text = _TEXTINFOS.Find(x => x.UID == attribute.ASSOCITEM);
417
                    if (text != null)
418
                        text.ASSOCIATION = true;
419
                }
420 60244a8b gaqhf
            }
421
        }
422
423 53c81765 gaqhf
        private void SetSpecBreakAttribute(SpecBreak specBreak)
424
        {
425
            string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE;
426
            string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE;
427
428
            specBreak.UpStreamUID = upStream;
429
            specBreak.DownStreamUID = downStream;
430
        }
431
432 8aa6f2db gaqhf
        private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns)
433 60244a8b gaqhf
        {
434
            foreach (XElement item in node.Elements("RUN"))
435
            {
436 8aa6f2db gaqhf
                LineRun run = new LineRun()
437 60244a8b gaqhf
                {
438
                    TYPE = item.Attribute("TYPE").Value
439
                };
440
441
                foreach (XElement element in item.Elements())
442
                {
443
                    if (element.Name == "SYMBOL")
444
                    {
445 c3d2e266 gaqhf
                        Symbol symbol = GetSymbolByUID(element.Element("UID").Value);
446
                        if (symbol == null)
447 3734dcc5 gaqhf
                            throw new Exception("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
448 c3d2e266 gaqhf
                        run.RUNITEMS.Add(symbol);
449 60244a8b gaqhf
                    }
450
                    else if (element.Name == "LINE")
451
                    {
452 c3d2e266 gaqhf
                        Line line = GetLineByUID(element.Element("UID").Value);
453
                        if (line == null)
454 3734dcc5 gaqhf
                            throw new Exception("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
455 c3d2e266 gaqhf
                        run.RUNITEMS.Add(line);
456 60244a8b gaqhf
                    }
457
                }
458
                lineNumberRuns.Add(run);
459
            }
460
        }
461 30d2cfcc gaqhf
462
        private void SetChildSymbol(Symbol symbol)
463
        {
464
            List<ChildSymbol> childList = new List<ChildSymbol>();
465
            if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None")
466
            {
467
                string[] childArray = symbol.CHILD.Split(new char[] { '/' });
468
                foreach (string sChild in childArray)
469
                {
470
                    string[] sChildInfo = sChild.Split(new char[] { ',' });
471
                    childList.Add(new ChildSymbol()
472
                    {
473
                        ParentAt = Convert.ToInt32(sChildInfo[0]),
474
                        Direction = sChildInfo[1],
475
                        NAME = sChildInfo[2]
476
                    });
477
                }
478
479
                foreach (ChildSymbol child in childList)
480
                {
481
                    if (child.ParentAt == 0)
482
                        symbol.ChildSymbols.Add(child);
483
                    else
484
                        childList[child.ParentAt - 1].ChildSymbols.Add(child);
485
                }
486
            }
487
            if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
488
            {
489 f1c9dbaa gaqhf
                // 현재 부모 Symbol에 자식 Connector까지 들어가 있음
490 30d2cfcc gaqhf
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
491
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
492
                for (int i = 0; i < array.Length; i++)
493
                {
494
                    string[] arrConn = array[i].Split(new char[] { ',' });
495
                    int connIndex = Convert.ToInt32(arrConn[3]);
496
                    if (connIndex != 0)
497 5dfb8a24 gaqhf
                    {
498 30d2cfcc gaqhf
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
499 f1c9dbaa gaqhf
                        symbol.CONNECTORS[i].Index = connIndex;
500 5dfb8a24 gaqhf
                    }
501
                }
502 30d2cfcc gaqhf
            }
503
        }
504 60244a8b gaqhf
        #endregion
505
506
        public Symbol GetSymbolByUID(string uid)
507
        {
508
            return SYMBOLS.Find(x => x.UID == uid);
509
        }
510
511
        public Line GetLineByUID(string uid)
512
        {
513
            return LINES.Find(x => x.UID == uid);
514
        }
515 96a2080c gaqhf
    }
516
}
클립보드 이미지 추가 (최대 크기: 500 MB)