프로젝트

일반

사용자정보

개정판 5f01bbc4

ID5f01bbc4613156d3d121c58f69d35f1cd26d74ec
상위 70268347
하위 1bdb1ec8, 7710b921

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

dev issue #829: edit source

차이점 보기:

DTI_PID/SPPIDConverter_AutoModeling/Modeling/AutoModeling.cs
1 1
using System;
2
using System.Windows.Forms;
2 3
using System.Collections.Generic;
3 4
using System.Drawing;
4 5
using System.Linq;
......
17 18
    public class AutoModeling
18 19
    {
19 20
        private Document document;
21
        private ListBox logListBox;
22
        private ToolStripProgressBar progressBar;
20 23

  
21 24
        public AutoModeling(Document doc)
22 25
        {
......
25 28

  
26 29
        public void Run()
27 30
        {
31
            if (progressBar != null)
32
            {
33
                Log.SetProgressBarValue(0, progressBar);
34
                Log.SetProgressMaximumValue(document.SYMBOLS.Count + document.LINES.Count + document.LINENUMBERS.Count + document.TEXTS.Count + document.SPECBREAK.Count, progressBar);
35
            }
36

  
37
            Log.WriteLine(new ListBoxItem(string.Format("----- START [{0}] -----", document.DWGNAME), Color.Black), logListBox);
28 38
            Stopwatch sw = new Stopwatch();
29 39
            sw.Start();
30 40
            CloseOPCForm.Run();
......
66 76
                    Line line = item as Line;
67 77
                    if (line != null && line.SPPID_ITEM_OBJECT == null)
68 78
                    {
69
                     
79
                        Log.WriteLine(new ListBoxItem(string.Format("Fail Line UID : {0}", line.UID), Color.Red), logListBox);
80
                        Log.ProgressBarIncrement(progressBar);
70 81
                    }
71 82
                }
72 83
            }
......
80 91
                    LMLabelPersist label = result.Value;
81 92
                    if (label != null)
82 93
                    {
83
                        
94
                        Log.WriteLine(new ListBoxItem(string.Format("Create SpecBreak UID : {0}, Type : {1}", item.UID, result.Key), Color.Black), logListBox);
84 95
                    }
85 96
                    else
86 97
                    {
87
                        
98
                        Log.WriteLine(new ListBoxItem(string.Format("Fail SpecBreak UID : {0}, Type : {1}", item.UID, result.Key), Color.Red), logListBox);
88 99
                    }
89 100
                }
101

  
102
                Log.ProgressBarIncrement(progressBar);
90 103
            }
91 104

  
92 105
            foreach (LineNumber lineNumber in document.LINENUMBERS)
......
99 112
            {
100 113
                text.Modeling(document);
101 114
                if (text.SPPID_ITEM_OBJECT != null || text.IsAssociation)
102
                {
103

  
104
                }
115
                    Log.WriteLine(new ListBoxItem(string.Format("Create Text UID : {0}", text.UID), Color.Black), logListBox);
105 116
                else
106 117
                {
107
                    
118
                    Log.WriteLine(new ListBoxItem(string.Format("Fail Text UID : {0}", text.UID), Color.Red), logListBox);
119
                    Log.WriteLine(text.VALUE + "/" + text.SPPIDMAPPINGNAME);
108 120
                }
121

  
122
                Log.ProgressBarIncrement(progressBar);
109 123
            }
110 124

  
125
            if (progressBar != null)
126
            {
127
                Log.SetProgressBarValue(0, progressBar);
128
                Log.SetProgressMaximumValue(document.SYMBOLS.Count, progressBar);
129
            }
111 130
            // attribute
112 131
            foreach (Symbol item in document.SYMBOLS)
113 132
            {
......
115 134
                {
116 135
                    item.SetAttribute(document);
117 136
                }
137
                Log.ProgressBarIncrement(progressBar);
118 138
            }
119 139

  
120 140

  
121 141
            CloseOPCForm.Stop();
122 142
            //
143
            Log.SetProgressBarValue(progressBar.Maximum, progressBar);
144

  
145
            Log.WriteLine(new ListBoxItem(string.Format("----- END [{0}] -----", document.DWGNAME), Color.Black), logListBox);
123 146
            sw.Stop();
124 147
            TimeSpan ts = sw.Elapsed;
125 148
            string elapsedTime = String.Format("{0:00}:{1:00}.{2:00}",
126 149
            ts.Minutes, ts.Seconds,
127 150
            ts.Milliseconds / 10);
151
            Log.WriteLine(new ListBoxItem(string.Format("Time : {0}", ts), Color.Black), logListBox);
152
            Log.WriteLine(new ListBoxItem("", Color.Black), logListBox);
128 153
        }
129 154

  
130 155
        private bool IsPossibleDrawGroupLine(Group group)
......
156 181
            return true;
157 182
        }
158 183

  
184
        public void SetListBoxLog(ListBox logListBox)
185
        {
186
            this.logListBox = logListBox;
187
        }
188

  
189
        public void SetProgressBar(ToolStripProgressBar progressBar)
190
        {
191
            this.progressBar = progressBar;
192
        }
193

  
159 194
        #region Modeling
160 195

  
161 196
        private bool GroupSymbolModeling(Group group)
......
205 240
                        {
206 241
                            prevSymbol = symbol;
207 242
                            prevIndex = itemIndex;
243
                            Log.WriteLine(new ListBoxItem(string.Format("Create Symbol UID : {0}", symbol.UID), Color.Black), logListBox);
244
                            Log.ProgressBarIncrement(progressBar);
208 245
                        }
209 246
                        else
210 247
                        {
248
                            Log.WriteLine(new ListBoxItem(string.Format("Fail Symbol UID : {0}", symbol.UID), Color.Red), logListBox);
249
                            Log.ProgressBarIncrement(progressBar);
211 250
                            result = false;
212 251
                        }
213 252
                    }
214 253
                }
215 254
                catch (Exception ex)
216 255
                {
256
                    Log.WriteLine(new ListBoxItem(string.Format("Fail Symbol UID : {0}", symbol.UID), Color.Red), logListBox);
257
                    Log.ProgressBarIncrement(progressBar);
258
                    Log.WriteLine(ex);
217 259
                    result = false;
218 260
                    return result;
219 261
                }
......
266 308
                {
267 309
                    line.SPPID_ITEM_OBJECT = modelId;
268 310
                    IfContainLineNumber(line.UID);
311

  
312
                    Log.WriteLine(new ListBoxItem(string.Format("Create Line UID : {0}", line.UID), Color.Black), logListBox);
313
                    Log.ProgressBarIncrement(progressBar);
269 314
                }
270 315
            }
271 316
            else
272 317
            {
273 318
                foreach (Line line in lines)
274 319
                {
275
                 
320
                    Log.WriteLine(new ListBoxItem(string.Format("Fail Line UID : {0}", line.UID), Color.Red), logListBox);
321
                    Log.ProgressBarIncrement(progressBar);
276 322
                }
277 323
            }
278 324

  
......
288 334
                    lineNumber.Modeling(document);
289 335

  
290 336
                    if (lineNumber.SPPID_ITEM_OBJECT != null)
291
                    {
292

  
293
                    }
337
                        Log.WriteLine(new ListBoxItem(string.Format("Create Line Number UID : {0}", lineNumber.UID), Color.Black), logListBox);
294 338
                    else
295
                    {
339
                        Log.WriteLine(new ListBoxItem(string.Format("Fail Line Number UID : {0}", lineNumber.UID), Color.Red), logListBox);
296 340

  
297
                    }
341
                    Log.ProgressBarIncrement(progressBar);
298 342
                    break;
299 343
                }
300 344
            }
DTI_PID/SPPIDConverter_AutoModeling/SPPIDConverter_AutoModeling.csproj
33 33
    <WarningLevel>4</WarningLevel>
34 34
  </PropertyGroup>
35 35
  <ItemGroup>
36
    <Reference Include="GemBox.Spreadsheet, Version=39.3.30.1130, Culture=neutral, PublicKeyToken=b1b72c69714d4847, processorArchitecture=MSIL">
37
      <SpecificVersion>False</SpecificVersion>
38
      <HintPath>..\..\..\S-MAP\GemBox.Spreadsheet.dll</HintPath>
39
    </Reference>
36 40
    <Reference Include="System" />
37 41
    <Reference Include="System.Core" />
42
    <Reference Include="System.Drawing" />
43
    <Reference Include="System.Windows.Forms" />
38 44
    <Reference Include="System.Xml.Linq" />
39 45
    <Reference Include="System.Data.DataSetExtensions" />
40 46
    <Reference Include="Microsoft.CSharp" />
......
58 64
    <Compile Include="Model\SPPID\Symbol.cs" />
59 65
    <Compile Include="Model\SPPID\Text.cs" />
60 66
    <Compile Include="Properties\AssemblyInfo.cs" />
67
    <Compile Include="Utill\ExcelUtill.cs" />
61 68
    <Compile Include="Utill\Log.cs" />
62 69
    <Compile Include="Utill\SPPIDUtill.cs" />
63 70
  </ItemGroup>
DTI_PID/SPPIDConverter_AutoModeling/Utill/Log.cs
1 1
using System;
2
using System.Windows.Forms;
2 3
using System.Collections.Generic;
3 4
using System.Linq;
4 5
using System.Text;
......
29 30
                sw.WriteLine(text);
30 31
            }
31 32
        }
33

  
34
        delegate void SetListBoxItemDelegete(ListBoxItem listboxItem, ListBox listBoxLog);
35
        public static void WriteLine(ListBoxItem item, ListBox listBoxLog)
36
        {
37
            if (listBoxLog != null)
38
            {
39
                if (listBoxLog.InvokeRequired)
40
                {
41
                    listBoxLog.Invoke(new SetListBoxItemDelegete(WriteLine), new object[] { item, listBoxLog });
42
                }
43
                else
44
                {
45
                    bool selectLast = false;
46
                    if (listBoxLog.SelectedIndex == listBoxLog.Items.Count - 1)
47
                        selectLast = true;
48
                    listBoxLog.Items.Add(item.Message);
49
                    if (selectLast)
50
                        listBoxLog.SelectedIndex = listBoxLog.Items.Count - 1;
51

  
52
                    WriteLine(item.Message);
53
                }
54
            }
55
        }
56

  
57
        delegate void SetProgressBarMaximumValueDelegete(int value, ToolStripProgressBar listboxItem);
58
        public static void SetProgressMaximumValue(int value, ToolStripProgressBar progressBar)
59
        {
60
            if (progressBar != null)
61
            {
62
                ToolStrip toolStrip = progressBar.GetCurrentParent();
63
                if (toolStrip.InvokeRequired)
64
                {
65
                    toolStrip.Invoke(new SetProgressBarMaximumValueDelegete(SetProgressMaximumValue), new object[] {value, progressBar });
66
                }
67
                else
68
                {
69
                    progressBar.Maximum = value;
70
                }
71
            }
72
        }
73

  
74
        delegate void ProgressBarIncrementDelegate(ToolStripProgressBar listboxItem);
75
        public static void ProgressBarIncrement(ToolStripProgressBar progressBar)
76
        {
77
            if (progressBar != null)
78
            {
79
                ToolStrip toolStrip = progressBar.GetCurrentParent();
80
                if (toolStrip.InvokeRequired)
81
                {
82
                    toolStrip.Invoke(new ProgressBarIncrementDelegate(ProgressBarIncrement), new object[] { progressBar });
83
                }
84
                else
85
                {
86
                    progressBar.Value = (progressBar.Value + progressBar.Step);
87
                }
88
            }
89
        }
90

  
91
        delegate void SetProgressBarValueDelegate(int value, ToolStripProgressBar listboxItem);
92
        public static void SetProgressBarValue(int value, ToolStripProgressBar progressBar)
93
        {
94
            if (progressBar != null)
95
            {
96
                ToolStrip toolStrip = progressBar.GetCurrentParent();
97
                if (toolStrip.InvokeRequired)
98
                {
99
                    toolStrip.Invoke(new SetProgressBarValueDelegate(SetProgressBarValue), new object[] { value, progressBar });
100
                }
101
                else
102
                {
103
                    if (progressBar.Value <= progressBar.Maximum)
104
                    {
105
                        progressBar.Value = value;
106
                    }
107
                }
108
            }
109
        }
110
    }
111

  
112
    public class ListBoxItem
113
    {
114
        public ListBoxItem(string message, Color color)
115
        {
116
            Message = message;
117
            Color = color;
118
        }
119

  
120
        public string Message { get; set; }
121
        public Color Color { get; set; }
32 122
    }
33 123
}

내보내기 Unified diff

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