프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / ConverterDocking.cs @ da1aeb27

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

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Drawing;
5
using System.Data;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10
using System.Threading;
11
using System.IO;
12
using Microsoft.VisualBasic;
13
using Ingr.RAD2D;
14
using Converter.BaseModel;
15
using Converter.SPPID.Properties;
16
using Converter.SPPID.DB;
17
using Converter.SPPID.Util;
18
using Converter.SPPID.Form;
19
using Converter.SPPID.Model;
20
using Plaice;
21
using Llama;
22
using DevExpress.XtraSplashScreen;
23
using Newtonsoft.Json;
24
using System.Runtime.InteropServices;
25
using System.Reflection;
26
using Converter.SPPID.OPC;
27

    
28
namespace Converter.SPPID.Wrapper
29
{
30
    public partial class ConverterDocking : UserControl
31
    {
32
        Ingr.RAD2D.Application application;
33
        internal static bool addEvent = false;
34
        public ConverterDocking()
35
        {
36
            InitializeComponent();
37
            spinEditSymmetry.Properties.Mask.EditMask = "f0";
38
            dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
39
            WrapperApplication wApp = new WrapperApplication(dApplication.Application);
40
            application = wApp.RADApplication;
41
            
42
            ReleaseCOMObjects(dApplication);
43
            dApplication = null;
44
            try
45
            {
46
                Project_Info _ProjectInfo = Project_Info.GetInstance();
47
                _ProjectInfo.DefaultPath = Settings.Default.ProjectPath;
48
                _ProjectInfo.DBType = (ID2DB_Type)Settings.Default.ProjectDBType;
49
                _ProjectInfo.ServerIP = Settings.Default.ProjectServerIP;
50
                _ProjectInfo.Port = Settings.Default.ProjectPort;
51
                _ProjectInfo.DBUser = Settings.Default.ProjectDBUser;
52
                _ProjectInfo.DBPassword = Settings.Default.ProjectDBPassword;
53
                if (Project_DB.ConnTestAndCreateTable())
54
                {
55
                    _ProjectInfo.Enable = true;
56
                    layoutControlGroup3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
57

    
58
                    DataTable dt = Project_DB.SelectSetting();
59
                    foreach (DataRow item in dt.Rows)
60
                    {
61
                        string settingType = item["SettingType"].ToString();
62
                        if (settingType == "ETCSetting")
63
                            SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString());
64
                        else if (settingType == "GridSetting")
65
                            SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString());
66
                    }
67
                }
68
                else
69
                {
70
                    layoutControlGroup3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
71
                }
72

    
73
                if (!addEvent)
74
                {
75
                    application.EventObject.BeforeApplicationExit += ApplicationEvents_ApplicationExit;
76
                    addEvent = true;
77
                }
78
            }
79
            catch (Exception ex)
80
            {
81
                StringBuilder sb = new StringBuilder();
82
                sb.AppendLine(ex.Message);
83
                sb.AppendLine(ex.StackTrace);
84
                MessageBox.Show(sb.ToString());
85
            }
86
        }
87
        private void ApplicationEvents_ApplicationExit(out bool cancel)
88
        {
89
            cancel = false;
90
        }
91
        /// <summary>
92
        /// 선택한 도면들을 읽어서 SPPID로 변환한다.
93
        /// </summary>
94
        /// <param name="sender"></param>
95
        /// <param name="e"></param>
96
        private void btnConverter_Click(object sender, EventArgs e)
97
        {
98
            ConverterForm converterForm = new ConverterForm();
99
            if (converterForm.ShowDialog() == DialogResult.OK)
100
            {
101
                //Ingr.RAD2D.Document doc = application.Documents.Add();
102

    
103
                try
104
                {
105
                    CloseOPCForm.Run();
106

    
107
                    for (int i = 0; i < converterForm.Documents.Count; i++)
108
                    {
109
                        SPPID_Document document = converterForm.Documents[i];
110
                        if (document.SetSPPIDMapping() && document.Enable)
111
                        {
112
                            using (AutoModeling modeling = new AutoModeling(document, converterForm.checkEditCloseDocument.Checked))
113
                            {
114
                                modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count);
115
                                modeling.Run();
116
                            }
117
                        }
118
                    }
119
                }
120
                catch (Exception ex)
121
                {
122
                    MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
123
                }
124
                finally
125
                {
126
                    CloseOPCForm.Stop();
127

    
128
                    //doc.SaveOnClose = false;
129
                    //doc.Close(false);
130

    
131
                    //dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
132
                    //dApplication.Drawings[1].CloseDrawing(false);
133
                    //ReleaseCOMObjects(dApplication);
134
                    //dApplication = null;
135
                }
136

    
137
                MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
138
            }
139
        }
140

    
141
        private void btnLinkOPC_Click(object sender, EventArgs e)
142
        {
143
            DataTable tOPCInfo = Project_DB.SelectOPCInfo();
144
            DataTable tOPCRelations = Project_DB.SelectOPCRelations();
145
            DataTable tDrawingInfo = Project_DB.SelectDrawingInfo();
146
            dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
147

    
148
            foreach (DataRow row in tOPCInfo.Rows)
149
            {
150
                if (!Convert.ToBoolean(row["PAIRED"]))
151
                {
152
                    string drawingUID = row["ID2_DRAWING_UID"].ToString();
153
                    string OPCUID = row["ID2_OPC_UID"].ToString();
154
                    DataRow[] rows = tOPCRelations.Select(string.Format("(From_Drawings_UID = '{0}' AND From_OPC_UID = '{1}') OR (To_Drawings_UID = '{0}' AND To_OPC_UID = '{1}')", drawingUID, OPCUID));
155

    
156
                    if (rows.Length == 2)
157
                    {
158
                        string fromDrawingsUID1 = rows[0]["From_Drawings_UID"].ToString();
159
                        string fromDrawingsUID2 = rows[1]["From_Drawings_UID"].ToString();
160
                        string fromOPCUID1 = rows[0]["From_OPC_UID"].ToString();
161
                        string fromOPCUID2 = rows[1]["From_OPC_UID"].ToString();
162
                        string toDrawingsUID1 = rows[0]["To_Drawings_UID"].ToString();
163
                        string toDrawingsUID2 = rows[1]["To_Drawings_UID"].ToString();
164
                        string toOPCUID1 = rows[0]["To_OPC_UID"].ToString();
165
                        string toOPCUID2 = rows[1]["To_OPC_UID"].ToString();
166

    
167
                        DataRow[] fromDrawing = tDrawingInfo.Select(string.Format("ID2_DRAWING_UID = '{0}'", fromDrawingsUID1));
168
                        DataRow[] toDrawing = tDrawingInfo.Select(string.Format("ID2_DRAWING_UID = '{0}'", toDrawingsUID1));
169
                        DataRow[] fromOPCInfoRows = tOPCInfo.Select(string.Format("ID2_OPC_UID = '{0}'", fromOPCUID1));
170
                        DataRow[] toOPCInfoRows = tOPCInfo.Select(string.Format("ID2_OPC_UID = '{0}'", toOPCUID1));
171

    
172
                        if (fromOPCUID1 == toOPCUID2 && fromOPCUID2 == toOPCUID1 && fromDrawing.Length == 1 && toDrawing.Length == 1 && fromOPCInfoRows.Length == 1 && toOPCInfoRows.Length == 1)
173
                        {
174
                            DataRow fromOPCInfoRow = fromOPCInfoRows[0];
175
                            DataRow toOPCInfoRow = toOPCInfoRows[0];
176
                            string fromOPCModelId = fromOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString();
177
                            string toOPCModelId = toOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString();
178
                            string toDrawingName = toDrawing[0]["DRAWINGNAME"].ToString();
179
                            List<string[]> toOPCAttributes = JsonConvert.DeserializeObject<List<string[]>>(toOPCInfoRow["ATTRIBUTES"].ToString());
180
                            AutoModeling_OPC opc = new AutoModeling_OPC(dApplication, application, fromOPCModelId, toOPCModelId, toDrawingName, toOPCAttributes);
181
                            if (opc.Run())
182
                            {
183
                                fromOPCInfoRow["PAIRED"] = true;
184
                                toOPCInfoRow["PAIRED"] = true;
185

    
186
                                Project_DB.InsertOPCInfo(fromOPCInfoRow["ID2_OPC_UID"].ToString(), fromOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString(), fromOPCInfoRow["ID2_DRAWING_UID"].ToString(), true);
187
                                Project_DB.InsertOPCInfo(toOPCInfoRow["ID2_OPC_UID"].ToString(), toOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString(), toOPCInfoRow["ID2_DRAWING_UID"].ToString(), true);
188
                            }
189
                        }
190
                    }
191
                }
192
            }
193

    
194
            tOPCInfo.Dispose();
195
            tOPCRelations.Dispose();
196
            tDrawingInfo.Dispose();
197
            ReleaseCOMObjects(dApplication);
198
            dApplication = null;
199

    
200
            MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
201
        }
202

    
203
        public void ReleaseCOMObjects(params object[] objVars)
204
        {
205
            int intNewRefCount = 0;
206
            foreach (object obj in objVars)
207
            {
208
                if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj))
209
                    intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
210
            }
211
        }
212

    
213
        
214

    
215
        #region SPPID Utils
216

    
217
        #region Symmetry
218
        private void btnSymmetry_Click(object sender, EventArgs e)
219
        {
220
            if (application.ActiveSelectSet.Count == 1 && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d))
221
            {
222
                int symCount = (int)spinEditSymmetry.Value;
223
                Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
224
                double x, y;
225
                symbol.GetOrigin(out x, out y);
226
                string rep = GetRepresentationId(symbol);
227
                List<string> verticalRepID = new List<string>();
228
                List<string> horizontalRepID = new List<string>();
229

    
230
                if ((symbol.LinearName.Contains("Piping") ||
231
                    symbol.LinearName.Contains("Instrument")) &&
232
                    !string.IsNullOrEmpty(rep))
233
                {
234
                    Placement placement = new Placement();
235
                    LMADataSource dataSource = placement.PIDDataSource;
236
                    List<List<string>> datas = SetSymbol(dataSource, rep, x, y, symCount);
237
                    Dictionary<SymmetryArrow, List<string>> resultDatas = new Dictionary<SymmetryArrow, List<string>>();
238
                    if (datas.Count >= 2 && datas.Find(loop => loop.Count != symCount) == null)
239
                    {
240
                        SymmetryArrow arrow = SymmetryArrow.None;
241
                        foreach (var data in datas)
242
                        {
243
                            LMSymbol firstSymbol = dataSource.GetSymbol(data[0]);
244
                            double fX = firstSymbol.get_XCoordinate();
245
                            double fY = firstSymbol.get_YCoordinate();
246

    
247
                            SlopeType type = SPPIDUtil.CalcSlope(x, y, fX, fY, 1);
248
                            if (type == SlopeType.HORIZONTAL)
249
                            {
250
                                if (fX < x)
251
                                {
252
                                    arrow |= SymmetryArrow.Left;
253
                                    resultDatas.Add(SymmetryArrow.Left, data);
254
                                }
255
                                else
256
                                {
257
                                    arrow |= SymmetryArrow.Right;
258
                                    resultDatas.Add(SymmetryArrow.Right, data);
259
                                }
260

    
261
                            }
262
                            else if (type == SlopeType.VERTICAL)
263
                            {
264
                                if (fY < y)
265
                                {
266
                                    arrow |= SymmetryArrow.Down;
267
                                    resultDatas.Add(SymmetryArrow.Down, data);
268
                                }
269
                                else
270
                                {
271
                                    arrow |= SymmetryArrow.Up;
272
                                    resultDatas.Add(SymmetryArrow.Up, data);
273
                                }
274
                            }
275

    
276
                            ReleaseCOMObjects(firstSymbol);
277
                        }
278

    
279
                        SymmetryForm form = new SymmetryForm(arrow);
280
                        if (form.ShowDialog() == DialogResult.OK)
281
                        {
282
                            MoveByResult(dataSource, resultDatas, x, y, form.Result, rep);
283
                        }
284
                    }
285
                    else
286
                        MessageBox.Show("Check Symmetry Rules", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
287
                    ReleaseCOMObjects(dataSource);
288
                    ReleaseCOMObjects(placement);
289
                }
290
            }
291

    
292
            return;
293

    
294
            List<Symbol2d> symbols = new List<Symbol2d>();
295
            foreach (var item in application.ActiveSelectSet)
296
            {
297
                Type type = item.GetType();
298
                if (type == typeof(Symbol2d))
299
                {
300
                    Symbol2d symbol = item as Symbol2d;
301
                    if (symbol.LinearName.Contains("Piping") ||
302
                        symbol.LinearName.Contains("Instrument"))
303
                        symbols.Add(symbol);
304
                }
305
                //if (item.GetType() == typeof(Symbol2d) || item.GetType() == typeof(Point2d))
306
                //    items.Add(item);
307
            }
308

    
309
            List<Symbol2d> verticalSymbols = new List<Symbol2d>();
310
            List<Symbol2d> horizontalSymbols = new List<Symbol2d>();
311
            Symbol2d mainSymbol = null;
312
            for (int i = 0; i < symbols.Count - 1; i++)
313
            {
314
                Symbol2d symbol1 = symbols[i];
315
                for (int j = 1; j < symbols.Count; j++)
316
                {
317
                    Symbol2d symbol2 = symbols[j];
318

    
319
                    if (symbol1 != symbol2)
320
                    {
321
                        double x1, y1, x2, y2;
322
                        symbol1.GetOrigin(out x1, out y1);
323
                        symbol2.GetOrigin(out x2, out y2);
324
                        SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 1);
325
                        if (slopeType == SlopeType.HORIZONTAL)
326
                        {
327
                            if (!horizontalSymbols.Contains(symbol1))
328
                                horizontalSymbols.Add(symbol1);
329
                            if (!horizontalSymbols.Contains(symbol2))
330
                                horizontalSymbols.Add(symbol2);
331

    
332
                            if (verticalSymbols.Contains(symbol1))
333
                                mainSymbol = symbol1;
334
                            if (verticalSymbols.Contains(symbol2))
335
                                mainSymbol = symbol2;
336
                        }
337
                        else if (slopeType == SlopeType.VERTICAL)
338
                        {
339
                            if (!verticalSymbols.Contains(symbol1))
340
                                verticalSymbols.Add(symbol1);
341
                            if (!verticalSymbols.Contains(symbol2))
342
                                verticalSymbols.Add(symbol2);
343

    
344
                            if (horizontalSymbols.Contains(symbol1))
345
                                mainSymbol = symbol1;
346
                            if (horizontalSymbols.Contains(symbol2))
347
                                mainSymbol = symbol2;
348
                        }
349
                    }
350
                }
351
            }
352

    
353
            application.ActiveSelectSet.RemoveAll();
354
            foreach (var item in verticalSymbols)
355
                application.ActiveSelectSet.Add(item);
356
            foreach (var item in horizontalSymbols)
357
                application.ActiveSelectSet.Add(item);
358
                
359

    
360
            if (MessageBox.Show("Continue?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
361
            {
362
                application.ActiveSelectSet.RemoveAll();
363

    
364
            }
365
        }
366
        private void MoveByResult(LMADataSource dataSource,Dictionary<SymmetryArrow, List<string>> resultDatas, double x, double y, SymmetryArrow arrow, string centerRepID)
367
        {
368
            List<string> datas = resultDatas[arrow];
369
            foreach (var item in resultDatas)
370
            {
371
                if (item.Key != arrow)
372
                {
373
                    for (int i = 0; i < item.Value.Count; i++)
374
                    {
375
                        Symbol2d moveSymbol2d = GetSymbol2DByRepID(dataSource, item.Value[i]);
376
                        Symbol2d symbol2d = GetSymbol2DByRepID(dataSource, datas[i]);
377

    
378
                        double x1, y1, x2, y2;
379
                        symbol2d.GetOrigin(out x1, out y1);
380
                        moveSymbol2d.GetOrigin(out x2, out y2);
381
                        double distance = SPPIDUtil.CalcPointToPointdDistance(x, y, x1, y1);
382

    
383
                        string symbol1RepID;
384
                        string symbol2RepID;
385
                        List<Point2d> point2ds;
386
                        if (i == 0)
387
                        {
388
                            symbol1RepID = centerRepID;
389
                            symbol2RepID = item.Value[i];
390
                        }
391
                        else
392
                        {
393
                            symbol1RepID = item.Value[i - 1];
394
                            symbol2RepID = item.Value[i];
395
                        }
396
                        point2ds = FindAllPoint2d(dataSource, symbol1RepID, symbol2RepID);
397
                        double moveX = 0;
398
                        double moveY = 0;
399

    
400
                        if (item.Key == SymmetryArrow.Left)
401
                            moveX = x - distance - x2;
402
                        else if (item.Key == SymmetryArrow.Right)
403
                            moveX = x + distance - x2;
404
                        else if (item.Key == SymmetryArrow.Down)
405
                            moveY = y - distance - y2;
406
                        else if (item.Key == SymmetryArrow.Up)
407
                            moveY = y + distance - y2;
408

    
409
                        moveSymbol2d.Move(0, 0, moveX, moveY);
410
                        MovePoint2d(dataSource, item.Value[i], arrow, moveX, moveY);
411
                        foreach (var point in point2ds)
412
                        {
413
                            LMSymbol branch = dataSource.GetSymbol(GetRepresentationId(point));
414
                            LMSymbol connSymbol = GetFirstSymbolBySlope(dataSource, branch, symbol1RepID, symbol2RepID);
415
                            point.Move(0, 0, moveX, moveY);
416
                            if (connSymbol != null)
417
                            {
418
                                Symbol2d connSymbol2d = GetSymbol2DByRepID(dataSource, connSymbol.AsLMRepresentation().Id);
419
                                connSymbol2d.Move(0, 0, moveX, moveY);
420
                                ReleaseCOMObjects(connSymbol);
421
                            }
422
                            ReleaseCOMObjects(branch);
423
                        }
424
                            
425
                    }
426
                }
427
            }
428
        }
429
        private LMSymbol GetFirstSymbolBySlope(LMADataSource dataSource, LMSymbol branch, string symbol1RepID, string symbol2RepID)
430
        {
431
            LMSymbol result = null;
432
            foreach (LMConnector connector in branch.Connect1Connectors)
433
            {
434
                if (connector.ConnectItem1SymbolObject != null && 
435
                    connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
436
                    connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
437
                {
438
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
439
                    if (repID != symbol1RepID && repID != symbol2RepID)
440
                        result = connector.ConnectItem1SymbolObject;
441
                }
442

    
443
                if (connector.ConnectItem2SymbolObject != null &&
444
                    connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
445
                    connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
446
                {
447
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
448
                    if (repID != symbol1RepID && repID != symbol2RepID)
449
                        result = connector.ConnectItem2SymbolObject;
450
                }
451
            }
452

    
453
            foreach (LMConnector connector in branch.Connect2Connectors)
454
            {
455
                if (connector.ConnectItem1SymbolObject != null &&
456
                    connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
457
                    connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
458
                {
459
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
460
                    if (repID != symbol1RepID && repID != symbol2RepID)
461
                        result = connector.ConnectItem1SymbolObject;
462
                }
463

    
464
                if (connector.ConnectItem2SymbolObject != null &&
465
                    connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
466
                    connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
467
                {
468
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
469
                    if (repID != symbol1RepID && repID != symbol2RepID)
470
                        result = connector.ConnectItem2SymbolObject;
471
                }
472
            }
473

    
474

    
475
            return result;
476
        }
477
        private string GetRepresentationId(Symbol2d symbol)
478
        {
479
            foreach (var attributes in symbol.AttributeSets)
480
            {
481
                foreach (var attribute in attributes)
482
                {
483
                    string name = attribute.Name;
484
                    object value = attribute.GetValue();
485
                    if (name == "DrawingID")
486
                    {
487
                        return value.ToString();  
488
                    }
489
                }
490
            }
491
            return null;
492
        }
493
        private string GetRepresentationId(Point2d point2d)
494
        {
495
            foreach (var attributes in point2d.AttributeSets)
496
            {
497
                foreach (var attribute in attributes)
498
                {
499
                    string name = attribute.Name;
500
                    object value = attribute.GetValue();
501
                    if (name == "DrawingID")
502
                    {
503
                        return value.ToString();
504
                    }
505
                }
506
            }
507
            return null;
508
        }
509
        private List<List<string>> SetSymbol(LMADataSource dataSource, string rep, double x, double y, int count)
510
        {
511
            LMSymbol _LMSymbol = dataSource.GetSymbol(rep);
512
            List<List<string>> result = new List<List<string>>();
513
            List<string> oldIDs = new List<string>() { rep };
514
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
515
            {
516
                if (connector.get_ItemStatus() != "Active")
517
                    continue;
518

    
519
                string repID = connector.AsLMRepresentation().Id;
520
                string status = connector.get_ItemStatus();
521
                if (status == "Active" && !oldIDs.Contains(repID))
522
                {
523
                    List<string> symbols = new List<string>();
524
                    oldIDs.Add(repID);
525
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
526
                    result.Add(symbols);
527
                }
528
            }
529

    
530
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
531
            {
532
                if (connector.get_ItemStatus() != "Active")
533
                    continue;
534

    
535
                string repID = connector.AsLMRepresentation().Id;
536
                string status = connector.get_ItemStatus();
537
                if (status == "Active" && !oldIDs.Contains(repID))
538
                {
539
                    List<string> symbols = new List<string>();
540
                    oldIDs.Add(repID);
541
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
542
                    result.Add(symbols);
543
                }
544
            }
545

    
546
            ReleaseCOMObjects(_LMSymbol);
547
            return result;
548
        }
549
        private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMConnector connector, double x, double y, int count)
550
        {
551
            if (symbols.Count >= count)
552
                return;
553

    
554
            if (connector.ConnectItem1SymbolObject != null && !oldIDs.Contains(connector.ConnectItem1SymbolObject.AsLMRepresentation().Id))
555
            {
556
                string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
557
                oldIDs.Add(repID);
558
                if (connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
559
                {
560
                    double sX = connector.ConnectItem1SymbolObject.get_XCoordinate(), sY = connector.ConnectItem1SymbolObject.get_YCoordinate(); ;
561
                    SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
562
                    if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
563
                        symbols.Add(repID);
564
                }
565

    
566
                loop(dataSource, oldIDs, symbols, connector.ConnectItem1SymbolObject, x, y, count);
567
            }
568

    
569
            if (symbols.Count >= count)
570
                return;
571

    
572
            if (connector.ConnectItem2SymbolObject != null && !oldIDs.Contains(connector.ConnectItem2SymbolObject.AsLMRepresentation().Id))
573
            {
574
                string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
575
                oldIDs.Add(repID);
576
                if (connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
577
                {
578
                    double sX = connector.ConnectItem2SymbolObject.get_XCoordinate(), sY = connector.ConnectItem2SymbolObject.get_YCoordinate(); ;
579
                    SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
580
                    if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
581
                        symbols.Add(repID);
582
                }
583

    
584
                loop(dataSource, oldIDs, symbols, connector.ConnectItem2SymbolObject, x, y, count);
585
            }
586
        }
587
        private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMSymbol _LMSymbol, double x, double y, int count)
588
        {
589
            if (symbols.Count >= count)
590
                return;
591

    
592
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
593
            {
594
                if (connector.get_ItemStatus() != "Active")
595
                    continue;
596

    
597
                string repID = connector.AsLMRepresentation().Id;
598
                string status = connector.get_ItemStatus();
599
                if (status == "Active" && !oldIDs.Contains(repID))
600
                {
601
                    oldIDs.Add(repID);
602
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
603
                }
604
            }
605

    
606
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
607
            {
608
                if (connector.get_ItemStatus() != "Active")
609
                    continue;
610

    
611
                string repID = connector.AsLMRepresentation().Id;
612
                string status = connector.get_ItemStatus();
613
                if (status == "Active" && !oldIDs.Contains(repID))
614
                {
615
                    oldIDs.Add(repID);
616
                    loop(dataSource, oldIDs, symbols, connector, x, y, count);
617
                }
618
            }
619
        }
620
        private Symbol2d GetSymbol2DByRepID(LMADataSource dataSource, string repID)
621
        {
622
            LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
623
            Symbol2d symbol2D = application.ActiveDocument.ActiveSheet.DrawingObjects[_LMSymbol.get_GraphicOID().ToString()];
624
            ReleaseCOMObjects(_LMSymbol);
625
            return symbol2D;
626
        }
627
        private void MovePoint2d(LMADataSource datasource, string repID, SymmetryArrow arrow, double moveX, double moveY)
628
        {
629
            LMSymbol _LMSymbol = datasource.GetSymbol(repID);
630
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
631
            {
632
                if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
633
                {
634
                    if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
635
                    {
636
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
637
                        point.X += moveX;
638
                        point.Y += moveY;
639
                    }
640
                    else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
641
                    {
642
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
643
                        point.X += moveX;
644
                        point.Y += moveY;
645
                    }
646
                }
647
            }
648
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
649
            {
650
                if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
651
                {
652
                    if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
653
                    {
654
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
655
                        point.X += moveX;
656
                        point.Y += moveY;
657
                    }
658
                    else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
659
                    {
660
                        Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
661
                        point.X += moveX;
662
                        point.Y += moveY;
663
                    }
664
                }
665
            }
666
            ReleaseCOMObjects(_LMSymbol);
667
        }
668
        private List<Point2d> FindAllPoint2d(LMADataSource dataSource, string repID, string nextRepID)
669
        {
670
            LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
671
            List<string> endIDs = new List<string>() { repID };
672
            List<string> graphicOIDs = new List<string>();
673
            List<Point2d> result = new List<Point2d>();
674
            FindPointsLoop(dataSource, _LMSymbol, endIDs, nextRepID, graphicOIDs);
675
            ReleaseCOMObjects(_LMSymbol);
676
            foreach (var item in graphicOIDs)
677
            {
678
                Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[item] as Point2d;
679
                result.Add(point);
680
            }
681
            
682
            return result;
683
        }
684
        private bool FindPointsLoop(LMADataSource dataSource, LMSymbol _LMSymbol, List<string> endIDs, string targetRepID, List<string> graphicOIDs)
685
        {
686
            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
687
            {
688
                if (connector.get_ItemStatus() != "Active")
689
                    continue;
690

    
691
                if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
692
                {
693
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
694
                    if (!endIDs.Contains(repID))
695
                    {
696
                        endIDs.Add(repID);
697
                        if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
698
                        {
699
                            if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
700
                            {
701
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
702
                                    graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
703
                                return true;
704
                            }
705
                        }
706
                        else if (targetRepID == repID)
707
                        {
708
                            return true;
709
                        }
710
                    }
711
                }
712
                if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
713
                {
714
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
715
                    if (!endIDs.Contains(repID))
716
                    {
717
                        endIDs.Add(repID);
718
                        if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
719
                        {
720
                            if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
721
                            {
722
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
723
                                    graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
724
                                return true;
725
                            }
726
                        }
727
                        else if (targetRepID == repID)
728
                        {
729
                            return true;
730
                        }
731
                    }
732
                }
733
            }
734
            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
735
            {
736
                if (connector.get_ItemStatus() != "Active")
737
                    continue;
738

    
739
                if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
740
                {
741
                    string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
742
                    if (!endIDs.Contains(repID))
743
                    {
744
                        endIDs.Add(repID);
745
                        if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
746
                        {
747
                            if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
748
                            {
749
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
750
                                    graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
751
                                return true;
752
                            }
753
                        }
754
                        else if (targetRepID == repID)
755
                        {
756
                            return true;
757
                        }
758
                    }
759
                }
760
                if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
761
                {
762
                    string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
763
                    if (!endIDs.Contains(repID))
764
                    {
765
                        endIDs.Add(repID);
766
                        if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
767
                        {
768
                            if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
769
                            {
770
                                if (!Convert.ToBoolean(connector.get_IsZeroLength()))
771
                                    graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
772
                                return true;
773
                            }
774
                        }
775
                        else if (targetRepID == repID)
776
                        {
777
                            return true;
778
                        }
779
                    }
780
                }
781
            }
782

    
783
            return false;
784
        }
785
        #endregion
786

    
787
        #region SpecBreak
788
        private void btnSpecBreakRelocation_Click(object sender, EventArgs e)
789
        {
790
            dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
791
            WrapperApplication wApp = new WrapperApplication(dApplication.Application);
792
            application = wApp.RADApplication;
793

    
794
            int count = application.ActiveSelectSet.Count;
795
            int dependencyCount = 0;
796
            foreach (var item in application.ActiveSelectSet)
797
                if (item.GetType() == typeof(DependencyObject))
798
                    dependencyCount++;
799

    
800
            if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject))
801
            {
802
                MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
803
                return;
804
            }
805

    
806
            if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) &&
807
                (dependencyCount == 2 || dependencyCount == 3))
808
            {
809
                Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
810

    
811
                if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\"))
812
                {
813
                    MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
814
                    return;
815
                }
816

    
817
                DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject;
818
                DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject;
819
                DependencyObject dependency3 = null;
820
                if (count == 4)
821
                    dependency3 = application.ActiveSelectSet[3] as DependencyObject;
822

    
823
                application.ActiveSelectSet.RemoveAll();
824
                double angle = symbol.Angle;
825
                if (symbol.GetTransform().HasReflection)
826
                    angle += Math.PI;
827

    
828
                double degree = double.NaN;
829
                if (angle > -0.1 && angle < 0.1)
830
                    degree = 0;
831
                else if (angle > 1.56 && angle < 1.58)
832
                    degree = 90;
833
                else if (angle > 3.13 && angle < 3.15)
834
                    degree = 180;
835
                else if (angle > 4.7 && angle < 4.72)
836
                    degree = 270;
837
                else if (angle > 6.27 && angle < 6.29)
838
                    degree = 0;
839
                else if (angle > -1.58 && angle < -1.56)
840
                    degree = 270;
841
                else if (angle > -3.15 && angle < -3.13)
842
                    degree = 180;
843
                else
844
                    throw new Exception("Check Angle");
845

    
846

    
847
                double originX, originY;
848
                symbol.GetOrigin(out originX, out originY);
849

    
850
                double crossX = 0;
851
                double crossY = 0;
852
                double topX = 0;
853
                double topY = 0;
854
                foreach (var item in symbol.DrawingObjects)
855
                {
856
                    Line2d line2d = item as Line2d;
857
                    if (line2d != null)
858
                    {
859
                        double x1, y1, x2, y2;
860
                        line2d.GetStartPoint(out x1, out y1);
861
                        line2d.GetEndPoint(out x2, out y2);
862
                        SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1);
863

    
864
                        if (slopeType == SlopeType.HORIZONTAL)
865
                        {
866
                            if (crossY == 0)
867
                                crossY = y1;
868
                            else
869
                                crossY = (crossY + y1) / 2;
870

    
871
                            switch (degree)
872
                            {
873
                                case 90:
874
                                    if (topX == 0)
875
                                        topX = Math.Min(x1, x2);
876
                                    else
877
                                        topX = Math.Min(topX, Math.Min(x1, x2));
878
                                    break;
879
                                case 270:
880
                                    if (topX == 0)
881
                                        topX = Math.Max(x1, x2);
882
                                    else
883
                                        topX = Math.Max(topX, Math.Max(x1, x2));
884
                                    break;
885
                                default:
886
                                    break;
887
                            }
888
                        }
889
                        else if (slopeType == SlopeType.VERTICAL)
890
                        {
891
                            if (crossX == 0)
892
                                crossX = x1;
893
                            else
894
                                crossX = (crossX + x1) / 2;
895

    
896
                            switch (degree)
897
                            {
898
                                case 0:
899
                                    if (topY == 0)
900
                                        topY = Math.Max(y1, y2);
901
                                    else
902
                                        topY = Math.Max(topY, Math.Max(y1, y2));
903
                                    break;
904
                                case 180:
905
                                    if (topY == 0)
906
                                        topY = Math.Min(y1, y2);
907
                                    else
908
                                        topY = Math.Min(topY, Math.Min(y1, y2));
909
                                    break;
910
                                default:
911
                                    break;
912
                            }
913
                        }
914
                    }
915
                }
916
                switch (degree)
917
                {
918
                    case 0:
919
                        crossX = originX;
920
                        topX = crossX;
921
                        break;
922
                    case 90:
923
                        crossY = originY;
924
                        topY = crossY;
925
                        break;
926
                    case 180:
927
                        crossX = originX;
928
                        topX = crossX;
929
                        break;
930
                    case 270:
931
                        crossY = originY;
932
                        topY = crossY;
933
                        break;
934
                    default:
935
                        break;
936
                }
937

    
938
                SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3);
939
                SetSpecBreakParameters(symbol, dependency1, dependency2, degree);
940
            }
941
            else
942
            {
943
                MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
944
            }
945
        }
946
        private void SetSpecBreakParameters(Symbol2d symbol, DependencyObject dependency1, DependencyObject dependency2, double degree)
947
        {
948
            bool mirror = symbol.GetTransform().HasReflection;
949
            string repID = GetRepresentationId(symbol);
950
            Placement placement = new Placement();
951
            LMADataSource dataSource = placement.PIDDataSource;
952

    
953
            LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
954
            if (_LMSymbol != null)
955
            {
956
                double sX1, sY1, sX2, sY2, sOriginX, sOriginY;
957
                symbol.Range(out sX1, out sY1, out sX2, out sY2);
958
                symbol.GetOrigin(out sOriginX, out sOriginY);
959
                double d1X1, d1Y1, d1X2, d1Y2, d2X1, d2Y1, d2X2, d2Y2;
960
                FindRangeWithOutLineString2d(dependency1, out d1X1, out d1Y1, out d1X2, out d1Y2);
961
                FindRangeWithOutLineString2d(dependency2, out d2X1, out d2Y1, out d2X2, out d2Y2);
962

    
963
                double left = 0, right = 0;
964
                switch (degree)
965
                {
966
                    case 0:
967
                        if (!mirror)
968
                        {
969
                            left = Math.Abs(d1X1 - sOriginX);
970
                            right = Math.Abs(d2X2 - sOriginX);
971
                        }
972
                        else
973
                        {
974
                            right = Math.Abs(d1X1 - sOriginX);
975
                            left = Math.Abs(d2X2 - sOriginX);
976
                        }
977
                        break;
978
                    case 90:
979
                        if (!mirror)
980
                        {
981
                            left = Math.Abs(d1Y1 - sOriginY);
982
                            right = Math.Abs(d2Y2 - sOriginY);
983
                        }
984
                        else
985
                        {
986
                            right = Math.Abs(d1Y1 - sOriginY);
987
                            left = Math.Abs(d2Y2 - sOriginY);
988
                        }
989
                        break;
990
                    case 180:
991
                        if (!mirror)
992
                        {
993
                            right = Math.Abs(d1X1 - sOriginX);
994
                            left = Math.Abs(d2X2 - sOriginX);
995
                        }
996
                        else
997
                        {
998
                            left = Math.Abs(d1X1 - sOriginX);
999
                            right = Math.Abs(d2X2 - sOriginX);
1000
                            
1001
                        }
1002
                        break;
1003
                    case 270:
1004
                        if (!mirror)
1005
                        {
1006
                            right = Math.Abs(d1Y1 - sOriginY);
1007
                            left = Math.Abs(d2Y2 - sOriginY);
1008
                        }
1009
                        else
1010
                        {
1011
                            left = Math.Abs(d1Y1 - sOriginY);
1012
                            right = Math.Abs(d2Y2 - sOriginY);
1013
                        }
1014
                        break;
1015
                    default:
1016
                        break;
1017
                }
1018

    
1019
                string[] array1 = new string[] { "", "Left", "Right" };
1020
                string[] array2 = new string[] { "", left.ToString(), right.ToString() };
1021
                placement.PIDApplyParameters(_LMSymbol.AsLMRepresentation(), array1, array2);
1022
            }
1023

    
1024
            ReleaseCOMObjects(_LMSymbol);
1025
            ReleaseCOMObjects(dataSource);
1026
            ReleaseCOMObjects(placement);
1027
        }
1028
        private void SpecBreakRelocation(double degree, double originX, double originY, double crossX, double crossY, double topX, double topY, DependencyObject dependency1, DependencyObject dependency2, DependencyObject dependency3)
1029
        {
1030
            double d1X1, d1Y1, d1X2, d1Y2, d2X1, d2Y1, d2X2, d2Y2, d3X1 = 0, d3Y1 = 0, d3X2 = 0, d3Y2 = 0;
1031
            
1032
            FindRangeWithOutLineString2d(dependency1, out d1X1, out d1Y1, out d1X2, out d1Y2);
1033
            FindRangeWithOutLineString2d(dependency2, out d2X1, out d2Y1, out d2X2, out d2Y2);
1034
            if (dependency3 != null)
1035
                FindRangeWithOutLineString2dAndTextBox(dependency3, out d3X1, out d3Y1, out d3X2, out d3Y2);
1036

    
1037
            GridSetting gridSetting = GridSetting.GetInstance();
1038
            double move = gridSetting.Length / 2;
1039
            switch (degree)
1040
            {
1041
                case 0:
1042
                    MoveDependency(dependency1, d1X2, d1Y2, crossX - move, crossY);
1043
                    MoveDependency(dependency2, d2X1, d2Y2, crossX + move, crossY);
1044
                    if (dependency3 != null)
1045
                        MoveDependency(dependency3, (d3X1 + d3X2) / 2, d3Y1, topX, topY);
1046
                    break;
1047
                case 90:
1048
                    MoveDependency(dependency1, d1X1, d1Y2, crossX + move, crossY);
1049
                    MoveDependency(dependency2, d2X1, d2Y1, crossX + move, crossY);
1050
                    if (dependency3 != null)
1051
                        MoveDependency(dependency3, d3X1, (d3Y1 + d3Y2) / 2, originX, originY);
1052
                    break;
1053
                case 180:
1054
                    MoveDependency(dependency1, d1X2, d1Y1, crossX - move, crossY);
1055
                    MoveDependency(dependency2, d2X1, d2Y1, crossX + move, crossY);
1056
                    if (dependency3 != null)
1057
                        MoveDependency(dependency3, (d3X1 + d3X2) / 2, d3Y2, topX, topY);
1058
                    break;
1059
                case 270:
1060
                    MoveDependency(dependency1, d1X2, d1Y2, crossX - move, crossY);
1061
                    MoveDependency(dependency2, d2X2, d2Y1, crossX - move, crossY);
1062
                    if (dependency3 != null)
1063
                        MoveDependency(dependency3, d3X2, (d3Y1 + d3Y2) / 2, originX, originY);
1064
                    break;
1065
                default:
1066
                    break;
1067
            }
1068
        }
1069
        private void MoveDependency(DependencyObject dependency, double xFrom, double yFrom, double xTo, double yTo)
1070
        {
1071
            application.ActiveSelectSet.Add(dependency);
1072

    
1073
            Transform transform = dependency.GetTransform();
1074
            transform.DefineByMove2d(xTo - xFrom, yTo - yFrom);
1075
            application.ActiveSelectSet.Transform(transform, false);
1076

    
1077
            application.ActiveSelectSet.RemoveAll();
1078
        }
1079
        private string GetDrawingItemType(DependencyObject dependency)
1080
        {
1081
            string result = string.Empty;
1082

    
1083
            foreach (var attributes in dependency.AttributeSets)
1084
            {
1085
                foreach (var attribute in attributes)
1086
                {
1087
                    if (attribute.Name == "DrawingItemType")
1088
                        return attribute.GetValue().ToString();
1089
                }
1090
            }
1091

    
1092
            return result;
1093
        }
1094
        private void FindRangeWithOutLineString2d(DependencyObject dependency, out double x1, out double y1, out double x2, out double y2)
1095
        {
1096
            x1 = double.MaxValue;
1097
            y1 = double.MaxValue;
1098
            x2 = double.MinValue;
1099
            y2 = double.MinValue;
1100
            foreach (DrawingObjectBase item in dependency.DrawingObjects)
1101
            {
1102
                if (item.GetType() != typeof(LineString2d))
1103
                {
1104
                    double minX, minY, maxX, maxY;
1105
                    item.Range(out minX, out minY, out maxX, out maxY);
1106
                    if (x1 > minX)
1107
                        x1 = minX;
1108
                    if (y1 > minY)
1109
                        y1 = minY;
1110
                    if (x2 < maxX)
1111
                        x2 = maxX;
1112
                    if (y2 < maxY)
1113
                        y2 = maxY;
1114
                }
1115
            }
1116

    
1117
        }
1118
        private void FindWidthHeightWidthOutLineString2d(DependencyObject dependency, out double width, out double height)
1119
        {
1120
            width = 0;
1121
            height = 0;
1122

    
1123
            double x1 = double.MaxValue;
1124
            double y1 = double.MaxValue;
1125
            double x2 = double.MinValue;
1126
            double y2 = double.MinValue;
1127
            foreach (DrawingObjectBase item in dependency.DrawingObjects)
1128
            {
1129
                if (item.GetType() != typeof(LineString2d))
1130
                {
1131
                    double minX, minY, maxX, maxY;
1132
                    item.Range(out minX, out minY, out maxX, out maxY);
1133
                    if (x1 > minX)
1134
                        x1 = minX;
1135
                    if (y1 > minY)
1136
                        y1 = minY;
1137
                    if (x2 < maxX)
1138
                        x2 = maxX;
1139
                    if (y2 < maxY)
1140
                        y2 = maxY;
1141
                }
1142
            }
1143

    
1144
            width = x2 - x1;
1145
            height = y2 - y1;
1146
        }
1147

    
1148
        private void FindRangeWithOutLineString2dAndTextBox(DependencyObject dependency, out double x1, out double y1, out double x2, out double y2)
1149
        {
1150
            x1 = double.MaxValue;
1151
            y1 = double.MaxValue;
1152
            x2 = double.MinValue;
1153
            y2 = double.MinValue;
1154
            foreach (DrawingObjectBase item in dependency.DrawingObjects)
1155
            {
1156
                if (item.GetType() != typeof(LineString2d) && item.GetType() != typeof(Ingr.RAD2D.TextBox))
1157
                {
1158
                    double minX, minY, maxX, maxY;
1159
                    item.Range(out minX, out minY, out maxX, out maxY);
1160
                    if (x1 > minX)
1161
                        x1 = minX;
1162
                    if (y1 > minY)
1163
                        y1 = minY;
1164
                    if (x2 < maxX)
1165
                        x2 = maxX;
1166
                    if (y2 < maxY)
1167
                        y2 = maxY;
1168
                }
1169
            }
1170

    
1171
        }
1172
        #endregion
1173

    
1174
        #region Hot Key
1175
        private void toggleSwitchSnapGrid_Toggled(object sender, EventArgs e)
1176
        {
1177
            if (toggleSwitchSnapGrid.IsOn)
1178
            {
1179
                RegisterHotKey(this.Handle, 0, (int)KeyModifier.Shift, Keys.A.GetHashCode());
1180
            }
1181
            else
1182
            {
1183
                UnregisterHotKey(this.Handle, 0);
1184
            }
1185
        }
1186
        private void toggleSwitchMoveSymbol_Toggled(object sender, EventArgs e)
1187
        {
1188
            if (toggleSwitchMoveSymbol.IsOn)
1189
            {
1190
                RegisterHotKey(this.Handle, 1, (int)KeyModifier.Shift, Keys.Left.GetHashCode());
1191
                RegisterHotKey(this.Handle, 2, (int)KeyModifier.Shift, Keys.Up.GetHashCode());
1192
                RegisterHotKey(this.Handle, 3, (int)KeyModifier.Shift, Keys.Right.GetHashCode());
1193
                RegisterHotKey(this.Handle, 4, (int)KeyModifier.Shift, Keys.Down.GetHashCode());
1194
            }
1195
            else
1196
            {
1197
                UnregisterHotKey(this.Handle, 1);
1198
                UnregisterHotKey(this.Handle, 2);
1199
                UnregisterHotKey(this.Handle, 3);
1200
                UnregisterHotKey(this.Handle, 4);
1201
            }
1202
        }
1203
        public void ClearHotKey()
1204
        {
1205
            if (toggleSwitchMoveSymbol.IsOn)
1206
            {
1207
                UnregisterHotKey(this.Handle, 1);
1208
                UnregisterHotKey(this.Handle, 2);
1209
                UnregisterHotKey(this.Handle, 3);
1210
                UnregisterHotKey(this.Handle, 4);
1211
            }
1212
            if (toggleSwitchSnapGrid.IsOn)
1213
            {
1214
                UnregisterHotKey(this.Handle, 0);
1215
            }
1216
        }
1217
        [System.Runtime.InteropServices.DllImport("user32.dll")]
1218
        private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
1219
        [System.Runtime.InteropServices.DllImport("user32.dll")]
1220
        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
1221
        enum KeyModifier
1222
        {
1223
            None = 0,
1224
            Alt = 1,
1225
            Control = 2,
1226
            Shift = 4,
1227
            WinKey = 8
1228
        }
1229
        protected override void WndProc(ref Message m)
1230
        {
1231
            base.WndProc(ref m);
1232
            if (m.Msg == 0x0312)
1233
            {
1234
                Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
1235
                KeyModifier modifier = (KeyModifier)((int)m.LParam & 0xFFFF);
1236
                int id = m.WParam.ToInt32();
1237
                switch (id)
1238
                {
1239
                    case 0:
1240
                        application.RunCommand(CommandConstants.igcmdGridSnap);
1241
                        break;
1242
                    case 1:
1243
                        MoveSymbol(Arrow.Left);
1244
                        break;
1245
                    case 2:
1246
                        MoveSymbol(Arrow.Up);
1247
                        break;
1248
                    case 3:
1249
                        MoveSymbol(Arrow.Right);
1250
                        break;
1251
                    case 4:
1252
                        MoveSymbol(Arrow.Down);
1253
                        break;
1254
                    default:
1255
                        break;
1256
                }
1257
                
1258
            }
1259

    
1260
        }
1261
        #endregion
1262

    
1263
        #region Move Symbol
1264
        enum Arrow
1265
        {
1266
            Left,
1267
            Up,
1268
            Right,
1269
            Down
1270
        }
1271
        private void MoveSymbol(Arrow arrow)
1272
        {
1273
            if (application.ActiveSelectSet.Count > 0)
1274
            {
1275
                Placement placement = new Placement();
1276
                LMADataSource dataSource = placement.PIDDataSource;
1277
                System.Collections.ObjectModel.Collection<DrawingObjectBase> originalDrawingObjectBases = new System.Collections.ObjectModel.Collection<DrawingObjectBase>();
1278
                foreach (var item in application.ActiveSelectSet)
1279
                    originalDrawingObjectBases.Add(item);
1280
                System.Collections.ObjectModel.Collection<DrawingObjectBase> drawingObjectBases = new System.Collections.ObjectModel.Collection<DrawingObjectBase>();
1281
                Transform transform = null;
1282
                foreach (DrawingObjectBase drawingObject in application.ActiveSelectSet)
1283
                {
1284
                    if (drawingObject.GetType() == typeof(Symbol2d))
1285
                    {
1286
                        Symbol2d symbol2D = drawingObject as Symbol2d;
1287
                        if (transform == null)
1288
                            transform = symbol2D.GetTransform();
1289
                        drawingObjectBases.Add(symbol2D);
1290
                        LMSymbol _LMSymbol = dataSource.GetSymbol(GetRepresentationId(symbol2D));
1291
                        if (_LMSymbol != null)
1292
                        {
1293
                            foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
1294
                            {
1295
                                if (connector.get_ItemStatus() == "Active")
1296
                                {
1297
                                    #region Zero Length And Branch
1298
                                    if (Convert.ToBoolean(connector.get_IsZeroLength()))
1299
                                    {
1300
                                        if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolID != _LMSymbol.Id)
1301
                                        {
1302
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
1303
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1304
                                                drawingObjectBases.Add(point2D);
1305
                                        }
1306
                                        else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolID != _LMSymbol.Id)
1307
                                        {
1308
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
1309
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1310
                                                drawingObjectBases.Add(point2D);
1311
                                        }
1312
                                    }
1313
                                    #endregion
1314
                                    #region Not Zero Length And Branch And Vertical,Horizontal
1315
                                    else
1316
                                    {
1317
                                        if (connector.ConnectItem1SymbolObject != null && 
1318
                                            connector.ConnectItem1SymbolID != _LMSymbol.Id &&
1319
                                            connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
1320
                                            connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch" &&
1321
                                            IsMovePoint2D(connector.ConnectItem1SymbolObject, connector, arrow))
1322
                                        {
1323
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
1324
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1325
                                                drawingObjectBases.Add(point2D);
1326
                                        }
1327
                                            
1328
                                        else if (connector.ConnectItem2SymbolObject != null && 
1329
                                            connector.ConnectItem2SymbolID != _LMSymbol.Id &&
1330
                                            connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
1331
                                            connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch" &&
1332
                                            IsMovePoint2D(connector.ConnectItem2SymbolObject, connector, arrow))
1333
                                        {
1334
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
1335
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1336
                                                drawingObjectBases.Add(point2D);
1337
                                        }
1338
                                            
1339
                                    }
1340
                                    #endregion
1341
                                }
1342
                            }
1343
                            foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
1344
                            {
1345
                                if (connector.get_ItemStatus() == "Active")
1346
                                {
1347
                                    #region Zero Length And Branch
1348
                                    if (Convert.ToBoolean(connector.get_IsZeroLength()))
1349
                                    {
1350
                                        if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolID != _LMSymbol.Id)
1351
                                        {
1352
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
1353
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1354
                                                drawingObjectBases.Add(point2D);
1355
                                        }
1356
                                        else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolID != _LMSymbol.Id)
1357
                                        {
1358
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
1359
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1360
                                                drawingObjectBases.Add(point2D);
1361
                                        }
1362
                                    }
1363
                                    #endregion
1364
                                    #region Not Zero Length And Branch And Vertical,Horizontal
1365
                                    else
1366
                                    {
1367
                                        if (connector.ConnectItem1SymbolObject != null &&
1368
                                            connector.ConnectItem1SymbolID != _LMSymbol.Id &&
1369
                                            connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
1370
                                            connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch" &&
1371
                                            IsMovePoint2D(connector.ConnectItem1SymbolObject, connector, arrow))
1372
                                        {
1373
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
1374
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1375
                                                drawingObjectBases.Add(point2D);
1376
                                        }
1377

    
1378
                                        else if (connector.ConnectItem2SymbolObject != null &&
1379
                                            connector.ConnectItem2SymbolID != _LMSymbol.Id &&
1380
                                            connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
1381
                                            connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch" &&
1382
                                            IsMovePoint2D(connector.ConnectItem2SymbolObject, connector, arrow))
1383
                                        {
1384
                                            Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
1385
                                            if (point2D != null && !drawingObjectBases.Contains(point2D))
1386
                                                drawingObjectBases.Add(point2D);
1387
                                        }
1388

    
1389
                                    }
1390
                                    #endregion
1391
                                }
1392
                            }
1393
                        }
1394
                        ReleaseCOMObjects(_LMSymbol);
1395
                    }
1396
                    else if (drawingObject.GetType() == typeof(Point2d))
1397
                    {
1398
                        Point2d point2D = drawingObject as Point2d;
1399
                        if (!drawingObjectBases.Contains(point2D))
1400
                            drawingObjectBases.Add(point2D);
1401
                    }
1402
                }
1403

    
1404
                application.ActiveSelectSet.RemoveAll();
1405
                if (drawingObjectBases.Count > 0 && transform != null)
1406
                {
1407
                    application.ActiveSelectSet.AddObjects(drawingObjectBases);
1408
                    SetTransform(transform, arrow);
1409
                    application.ActiveSelectSet.Transform(transform, false);
1410

    
1411
                    application.ActiveSelectSet.RemoveAll();
1412
                    application.ActiveSelectSet.AddObjects(originalDrawingObjectBases);
1413
                }
1414
                
1415
                //foreach (DrawingObjectBaseEx item in drawingObjectBases)
1416
                //    MoveSymbol(item, arrow);
1417

    
1418
                ReleaseCOMObjects(dataSource);
1419
                ReleaseCOMObjects(placement);
1420
            }
1421
        }
1422
        private bool IsMovePoint2D(LMSymbol branchSymbol, LMConnector targetConnector, Arrow arrow)
1423
        {
1424
            bool result = false;
1425
            
1426
            DependencyObject dependency = application.ActiveDocument.ActiveSheet.DrawingObjects[targetConnector.get_GraphicOID().ToString()] as DependencyObject;
1427
            SlopeType mainSlope = GetLineSlopeType(dependency);
1428

    
1429
            if (mainSlope ==  SlopeType.HORIZONTAL || mainSlope == SlopeType.VERTICAL)
1430
            {
1431
                List<SlopeType> types = new List<SlopeType>();
1432

    
1433
                foreach (LMConnector connector in branchSymbol.Connect1Connectors)
1434
                {
1435
                    if (connector.get_ItemStatus() == "Active" && 
1436
                        connector.Id != targetConnector.Id && 
1437
                        !Convert.ToBoolean(connector.get_IsZeroLength()))
1438
                        types.Add(GetLineSlopeType(application.ActiveDocument.ActiveSheet.DrawingObjects[connector.get_GraphicOID().ToString()] as DependencyObject));
1439
                }
1440

    
1441
                foreach (LMConnector connector in branchSymbol.Connect2Connectors)
1442
                {
1443
                    if (connector.get_ItemStatus() == "Active" &&
1444
                        connector.Id != targetConnector.Id &&
1445
                        !Convert.ToBoolean(connector.get_IsZeroLength()))
1446
                        types.Add(GetLineSlopeType(application.ActiveDocument.ActiveSheet.DrawingObjects[connector.get_GraphicOID().ToString()] as DependencyObject));
1447
                }
1448

    
1449
                foreach (var type in types)
1450
                {
1451
                    if (type == mainSlope)
1452
                    {
1453
                        if (type == SlopeType.HORIZONTAL && (arrow == Arrow.Up || arrow == Arrow.Down))
1454
                            result = true;
1455
                        else if (type == SlopeType.VERTICAL && (arrow == Arrow.Left || arrow == Arrow.Right))
1456
                            result = true;
1457
                        else
1458
                        {
1459
                            result = false;
1460
                            break;
1461
                        }
1462
                    }
1463
                    else
1464
                        result = true;
1465
                }
1466

    
1467
                if (result)
1468
                {
1469
                    if ((arrow == Arrow.Down || arrow == Arrow.Up) && mainSlope == SlopeType.VERTICAL)
1470
                        result = false;
1471
                    else if ((arrow == Arrow.Left || arrow == Arrow.Right) && mainSlope == SlopeType.HORIZONTAL)
1472
                        result = false;
1473
                }
1474
            }
1475

    
1476
            return result;
1477
        }
1478
        private SlopeType GetLineSlopeType(DependencyObject dependency)
1479
        {
1480
            if (dependency != null && dependency.DrawingObjects.Count == 1 && dependency.DrawingObjects[0].GetType() == typeof(LineString2d))
1481
            {
1482
                LineString2d line = dependency.DrawingObjects[0] as LineString2d;
1483
                double x1 = 0, y1 = 0, x2 = double.MaxValue, y2 = double.MaxValue;
1484
                for (int i = 0; i < line.KeyPointCount; i++)
1485
                {
1486
                    double x, y, z;
1487
                    KeyPointType keyPointType;
1488
                    HandleType handleType;
1489
                    line.GetKeyPoint(i, out x, out y, out z, out keyPointType, out handleType);
1490
                    if (keyPointType == KeyPointType.igKeyPointStart)
1491
                    {
1492
                        x1 = x;
1493
                        y1 = y;
1494
                    }
1495
                    else if (keyPointType == KeyPointType.igKeyPointEnd)
1496
                    {
1497
                        x2 = x;
1498
                        y2 = y;
1499
                    }
1500
                }
1501
                return SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.5);
1502
            }
1503

    
1504
            return SlopeType.None;
1505
        }
1506
        private void MoveSymbol(DrawingObjectBaseEx drawingObjectBase, Arrow arrow)
1507
        {
1508
            if (drawingObjectBase == null)
1509
                return;
1510

    
1511
            GridSetting gridSetting = GridSetting.GetInstance();
1512
            switch (arrow)
1513
            {
1514
                case Arrow.Left:
1515
                    drawingObjectBase.Move(0, 0, -gridSetting.Length, 0);
1516
                    break;
1517
                case Arrow.Up:
1518
                    drawingObjectBase.Move(0, 0, 0, gridSetting.Length);
1519
                    break;
1520
                case Arrow.Right:
1521
                    drawingObjectBase.Move(0, 0, gridSetting.Length, 0);
1522
                    break;
1523
                case Arrow.Down:
1524
                    drawingObjectBase.Move(0, 0, 0, -gridSetting.Length);
1525
                    break;
1526
                default:
1527
                    break;
1528
            }
1529
        }
1530
        private void SetTransform(Transform transform, Arrow arrow)
1531
        {
1532
            if (transform == null)
1533
                return;
1534

    
1535
            GridSetting gridSetting = GridSetting.GetInstance();
1536
            switch (arrow)
1537
            {
1538
                case Arrow.Left:
1539
                    transform.DefineByMove2d(-gridSetting.Length, 0);
1540
                    break;
1541
                case Arrow.Up:
1542
                    transform.DefineByMove2d(0, gridSetting.Length);
1543
                    break;
1544
                case Arrow.Right:
1545
                    transform.DefineByMove2d(gridSetting.Length, 0);
1546
                    break;
1547
                case Arrow.Down:
1548
                    transform.DefineByMove2d(0, -gridSetting.Length);
1549
                    break;
1550
                default:
1551
                    break;
1552
            }
1553
        }
1554
        #endregion
1555

    
1556
        #endregion
1557

    
1558
        #region TEST
1559

    
1560
        private void simpleButton1_Click(object sender, EventArgs e)
1561
        {
1562
            //SPPIDUtil.test();
1563
            if (application.ActiveSelectSet.Count == 0)
1564
                return;
1565

    
1566
            foreach (DrawingObjectBase item in application.ActiveSelectSet)
1567
            {
1568
                DependencyObject dependency = item as DependencyObject;
1569
                if (dependency != null)
1570
                {
1571
                    foreach (var attributes in dependency.AttributeSets)
1572
                    {
1573
                        foreach (var attribute in attributes)
1574
                        {
1575
                            string name = attribute.Name;
1576
                            object value = attribute.GetValue();
1577
                            if (name == "ModelID")
1578
                            {
1579
                                Placement placement = new Placement();
1580
                                LMADataSource dataSource = placement.PIDDataSource;
1581
                                LMPipeRun pipeRun = dataSource.GetPipeRun(value);
1582
                                string attrName = "PlantGroup.Name";
1583
                                LMAAttribute lMAAttribute = pipeRun.Attributes[attrName];
1584
                                if (lMAAttribute != null)
1585
                                {
1586
                                    lMAAttribute.set_Value("25");
1587
                                    pipeRun.Commit();
1588
                                }
1589
                                else
1590
                                {
1591

    
1592
                                }
1593
                            }
1594
                        }
1595
                    }
1596
                }
1597
            }
1598
            
1599
            
1600

    
1601
            //string a = "0A509911F33441A2AF088BFBA78B770D";
1602
            //LMLabelPersist label = dataSource.GetLabelPersist(a);
1603
            //label.set_XCoordinate(0.4);
1604

    
1605

    
1606

    
1607

    
1608
            //LMOptionSettings
1609

    
1610

    
1611
            //LMAFilter filter = new LMAFilter();
1612
            //LMACriterion criterion = new LMACriterion();
1613
            //filter.ItemType = "Relationship";
1614
            //criterion.SourceAttributeName = "SP_DRAWINGID";
1615
            //criterion.Operator = "=";
1616
            //criterion.set_ValueAttribute(drawingID);
1617
            //filter.get_Criteria().Add(criterion);
1618

    
1619
            //LMRelationships relationships = new LMRelationships();
1620
            //relationships.Collect(dataSource, Filter: filter);
1621

    
1622
        }
1623

    
1624
        private void AutoJoinPipeRun()
1625
        {
1626
            dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
1627
            WrapperApplication wApp = new WrapperApplication(application.Application);
1628
            Ingr.RAD2D.Application radApp = wApp.RADApplication;
1629

    
1630
            string modelItemId = null;
1631
            List<double[]> vertices = new List<double[]>();
1632
            if (radApp.ActiveSelectSet.Count == 0)
1633
            {
1634
                return;
1635
            }
1636
            dynamic OID = radApp.ActiveSelectSet[0].Key();
1637
            DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
1638
            foreach (var attributes in drawingObject.AttributeSets)
1639
            {
1640
                foreach (var attribute in attributes)
1641
                {
1642
                    if (attribute.Name == "ModelID")
1643
                        modelItemId = attribute.GetValue().ToString();
1644
                }
1645
            }
1646
            radApp.ActiveSelectSet.RemoveAll();
1647

    
1648
        }
1649
        #endregion
1650

    
1651

    
1652
        [DllImport("user32.dll")]
1653
        public static extern int FindWindow(string lpClassName, string lpWindowName);
1654

    
1655
        [DllImport("user32.dll", SetLastError = true)]
1656
        static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);
1657

    
1658
        private void ConverterDocking_Load(object sender, EventArgs e)
1659
        {
1660
#if DEBUG
1661
            this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
1662
#else
1663
            this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
1664
#endif
1665

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