프로젝트

일반

사용자정보

개정판 21be5063

ID21be5063ab52b9a31486501db2dbdb2a331437f6
상위 c2ee2b00
하위 254f24a8

gaqhf 이(가) 약 6년 전에 추가함

dev issue #728: Convert vb to c#

차이점 보기:

DTI_PID/SPPIDAutoModeling/AutoModeling.cs
3 3
using System.Linq;
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6
using System.Xml;
6
using System.Xml.Linq;
7 7

  
8 8
namespace SPPIDAutoModeling
9 9
{
10 10
    public class AutoModeling
11 11
    {
12 12
        public static Drawing DrawingItem;
13
        XmlReader xml;
13
        private string xmlPath;
14

  
15
        public AutoModeling(string xmlPath)
16
        {
17
            this.xmlPath = xmlPath;
18
            CreateDrawingItem();
19
        }
14 20

  
15 21
        #region Xml Read and Data Setting
16
        public void SetXMLFile(string filePath)
22
        private void CreateDrawingItem()
17 23
        {
18 24
            try
19 25
            {
20
                xml = XmlReader.Create(filePath);
21

  
26
                XElement xml = XElement.Load(xmlPath);
27
                DrawingItem = new Drawing();
28
                DrawingItem.DWGNAME = xml.Element("DWGNAME").Value;
29
                DrawingItem.SIZE = xml.Element("SIZE").Value;
30
                SetSymbol(xml.Element("SYMBOLS"));
31
                SetLine(xml.Element("LINEINFOS"));
32
                SetLineNumber(xml.Element("LINENOS"));
33
                SetText(xml.Element("TEXTINFOS"));
34
                SetTrimLine(xml.Element("TRIMLINENOS"));
35
                SetNote(xml.Element("NOTES"));
22 36
            }
23 37
            catch (Exception)
24 38
            {
25 39

  
26 40
            }
27 41
        }
42

  
43
        private void SetSymbol(XElement node)
44
        {
45
            foreach (XElement item in node.Elements("SYMBOL"))
46
            {
47
                Symbol symbol = new Symbol()
48
                {
49
                    UID = item.Element("UID").Value,
50
                    NAME = item.Element("NAME").Value,
51
                    TYPE = item.Element("TYPE").Value,
52
                    ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
53
                    CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
54
                    LOCATION = item.Element("LOCATION").Value,
55
                    SIZE = item.Element("SIZE").Value,
56
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
57
                    PARENT = item.Element("PARENT").Value,
58
                    CHILD = item.Element("CHILD").Value,
59
                    HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
60
                    AREA = item.Element("AREA").Value
61
                };
62
                SetConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS);
63
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
64
                symbol.AfterSetting();
65
            }
66
        }
67

  
68
        private void SetLine(XElement node)
69
        {
70

  
71
        }
72

  
73
        private void SetLineNumber(XElement node)
74
        {
75

  
76
        }
77

  
78
        private void SetTrimLine(XElement node)
79
        {
80

  
81
        }
82

  
83
        private void SetText(XElement node)
84
        {
85

  
86
        }
87

  
88
        private void SetNote(XElement node)
89
        {
90

  
91
        }
92

  
93
        private void SetConnectors(XElement node, List<Connector> connectors)
94
        {
95
            foreach (XElement item in node.Elements("CONNECTOR"))
96
            {
97
                connectors.Add(new Connector()
98
                {
99
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
100
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
101
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value
102
                });
103
            }
104
        }
105

  
106
        private void SetAttributes(XElement node, List<Attribute> attributes)
107
        {
108

  
109
        }
110

  
28 111
        #endregion
29 112

  
113
        
30 114

  
31 115
        public void Run()
32 116
        {
33

  
117
            foreach (Symbol item in DrawingItem.SYMBOLS)
118
            {
119
                item.Modeling();
120
            }
34 121
        }
35 122
    }
36 123
}
DTI_PID/SPPIDAutoModeling/ItemObject.cs
16 16
        TEXT = 4,
17 17
    }
18 18

  
19
    public class SymbolChild
20
    {
21
        private string _Arrow;
22
        private string _Name;
23
        private int _Index;
24
        private string _SPPIDMAPPINGNAME;
25
        private object _SPPID_ITEM_OBJECT;
26

  
27
        public string Arrow { get => _Arrow; set => _Arrow = value; }
28
        public string Name { get => _Name; set => _Name = value; }
29
        public int Index { get => _Index; set => _Index = value; }
30
        public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; }
31
        public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; }
32
    }
33

  
34

  
19 35
    public class Group
20 36
    {
21 37
        private List<Symbol> _SYMBOLS = new List<Symbol>();
......
25 41
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
26 42
    }
27 43

  
44
    
45

  
28 46
    public class Drawing
29 47
    {
30 48
        #region Property
......
126 144
        #region Property
127 145
        private string _ORIGINALPOINT;
128 146
        private List<Connector> _CONNECTORS = new List<Connector>();
147
        private string _CONNECTIONPOINT;
129 148
        private string _LOCATION;
130 149
        private string _SIZE;
131 150
        private double _ANGLE;
132 151
        private string _PARENT;
133
        private List<string> _CHILD = new List<string>();
134
        private List<object> _CHILD_SPPID_ITEM_OBJECT = new List<object>();
152
        private string _CHILD;
153
        private List<SymbolChild> _CHILD_LIST = new List<SymbolChild>();
135 154
        private string _HASINSTRUMENTLABEL;
136 155
        private string _CURRENTPOINTMODEINDEX;
137 156
        private bool _DRAWCHECKED;
......
144 163
        public string SIZE { get => _SIZE; set => _SIZE = value; }
145 164
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
146 165
        public string PARENT { get => _PARENT; set => _PARENT = value; }
147
        public List<string> CHILD { get => _CHILD; set => _CHILD = value; }
148
        public List<object> CHILD_SPPID_ITEM_OBJECT { get => _CHILD_SPPID_ITEM_OBJECT; set => _CHILD_SPPID_ITEM_OBJECT = value; }
166
        public string CHILD { get => _CHILD; set => _CHILD = value; }
149 167
        public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; }
150 168
        public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; }
151 169
        public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; }
......
153 171
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
154 172
        public int MIRROR { get => _MIRROR; set => _MIRROR = value; }
155 173
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
174
        public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; }
175
        public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; }
156 176
        #endregion
157 177
        public override void AfterSetting()
158 178
        {
179
            // SPPIDMAPPINGNAME Setting
180
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
181
            // End
182

  
159 183
            // Angle Setting
160 184
            if (ANGLE == 1.57)
161 185
                ANGLE = 90 * Math.PI / 180;
......
172 196
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
173 197
            // End
174 198

  
175
            // SPPID  Type Setting
199
            // SPPID Type Setting
176 200
            SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL;
177 201
            // End
202

  
203
            // Child Setting
204
            if (!string.IsNullOrEmpty(CHILD) && CHILD != "None")
205
            {
206
                string[] childArray = CHILD.Split(new char[] { ',' });
207
                for (int i = 0; i < childArray.Length; i++)
208
                {
209
                    SymbolChild child = new SymbolChild()
210
                    {
211
                        Arrow = childArray[0],
212
                        Name = childArray[1],
213
                        Index = i
214
                    };
215
                    child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name);
216
                    CHILD_LIST.Add(child);
217
                }
218
            }
219
            // End
220

  
221
            // Input Drawing
222
            AutoModeling.DrawingItem.SYMBOLS.Add(this);
223
            // End
178 224
        }
179 225

  
180 226
        public override void Modeling()
......
213 259
                    // End
214 260

  
215 261
                    // Check Child And Modeling
216
                    foreach (string sChild in CHILD)
262
                    foreach (SymbolChild symoblChild in CHILD_LIST)
217 263
                    {
218 264
                        try
219 265
                        {
220
                            string[] arrChild = sChild.Split(new char[',']);
221
                            string sArrow = arrChild[0];
222
                            string sMappingName = arrChild[1];
266
                            string sArrow = symoblChild.Arrow;
267
                            string sMappingName = symoblChild.SPPIDMAPPINGNAME;
223 268

  
224 269
                            double dChildAngle = 0;
225 270
                            if (sArrow == "UP")
......
233 278

  
234 279
                            LMSymbol _childLmSymbol = _placement.PIDPlaceSymbol(sMappingName, LOCATION_X, LOCATION_Y, Mirror: 0, Rotation: dChildAngle, TargetItem: SPPID_ITEM_OBJECT);
235 280
                            _childLmSymbol.Commit();
236
                            CHILD_SPPID_ITEM_OBJECT.Add(_childLmSymbol);
281
                            symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol;
237 282
                        }
238 283
                        catch (Exception)
239 284
                        {
240
                            
285

  
241 286
                        }
242 287
                    }
243 288
                    // End
......
287 332
        #endregion
288 333
        public override void AfterSetting()
289 334
        {
335
            // SPPIDMAPPINGNAME Setting
336
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
337
            // End
338

  
290 339
            // Point Setting
291 340
            SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y);
292 341
            SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
......
301 350
            // SPPID Type Setting
302 351
            SPPID_TYPE = SPPID_ITEM_TYPE.LINE;
303 352
            // End
353

  
354
            // Input Drawing
355
            AutoModeling.DrawingItem.LINES.Add(this);
356
            // End
304 357
        }
305 358

  
306 359
        public override void Modeling()
......
343 396

  
344 397
        public override void AfterSetting()
345 398
        {
399
            // SPPIDMAPPINGNAME Setting
400
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
401
            // End
402

  
346 403
            // Angle Setting
347 404
            if (ANGLE == 1.57)
348 405
                ANGLE = 90 * Math.PI / 180;
......
362 419
            // SPPID  Type Setting
363 420
            SPPID_TYPE = SPPID_ITEM_TYPE.LABEL;
364 421
            // End
422

  
423
            // Input Drawing
424
            AutoModeling.DrawingItem.LINENUMBERS.Add(this);
425
            // End
365 426
        }
366 427

  
367 428
        public override void Modeling()
......
419 480
        #endregion
420 481
        public override void AfterSetting()
421 482
        {
483
            // SPPIDMAPPINGNAME Setting
484
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
485
            // End
486

  
422 487
            // Angle Setting
423 488
            if (ANGLE == 1.57)
424 489
                ANGLE = 90 * Math.PI / 180;
......
438 503
            // SPPID  Type Setting
439 504
            SPPID_TYPE = SPPID_ITEM_TYPE.TEXT;
440 505
            // End
506

  
507
            // Input Drawing
508
            AutoModeling.DrawingItem.TEXTS.Add(this);
509
            // End
441 510
        }
442 511

  
443 512
        public override void Modeling()
......
445 514
            try
446 515
            {
447 516
                Placement _placement = new Placement();
448
                if (NAME == "TEXT")
517
                if (NAME == "TEXT" || NAME == "NOTE")
449 518
                {
450 519
                    LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE);
451 520
                    LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID);
......
509 578
        private string _CONNECTEDITEM;
510 579
        private string _CONNECTPOINT;
511 580
        private string _SCENECONNECTPOINT;
581
        private string _INDEX;
512 582

  
513 583
        public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; }
514 584
        public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; }
515 585
        public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; }
586
        public string INDEX { get => _INDEX; set => _INDEX = value; }
516 587
        #endregion
517 588
    }
518 589
}
DTI_PID/SPPIDAutoModeling/SPPIDAutoModeling.csproj
9 9
    <AppDesignerFolder>Properties</AppDesignerFolder>
10 10
    <RootNamespace>SPPIDAutoModeling</RootNamespace>
11 11
    <AssemblyName>SPPIDAutoModeling</AssemblyName>
12
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13 13
    <FileAlignment>512</FileAlignment>
14
    <TargetFrameworkProfile />
14 15
  </PropertyGroup>
15 16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 17
    <DebugSymbols>true</DebugSymbols>
DTI_PID/SPPIDAutoModeling/SPPIDUtill.cs
80 80

  
81 81
            return null;
82 82
        }
83

  
84
        public static string GetSPPIDMappingName(string name)
85
        {
86
            string SPPIDName = @"\Piping\Valves\2 Way Common\Ball Valve.sym";
87

  
88

  
89
            return SPPIDName;
90
        }
83 91
    }
84 92
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)