프로젝트

일반

사용자정보

개정판 70268347

ID70268347ba30b12fb685c0debc823b2393af93c6
상위 11ff136b
하위 5f01bbc4

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

dev issue #829 : edit source

차이점 보기:

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

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

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

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

  
105 92
            foreach (LineNumber lineNumber in document.LINENUMBERS)
......
112 99
            {
113 100
                text.Modeling(document);
114 101
                if (text.SPPID_ITEM_OBJECT != null || text.IsAssociation)
115
                    Log.WriteLine(new ListBoxItem(string.Format("Create Text UID : {0}", text.UID), Color.Black), logListBox);
102
                {
103

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

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

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

  
140 120

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

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

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

  
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

  
194 159
        #region Modeling
195 160

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

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

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

  
336 290
                    if (lineNumber.SPPID_ITEM_OBJECT != null)
337
                        Log.WriteLine(new ListBoxItem(string.Format("Create Line Number UID : {0}", lineNumber.UID), Color.Black), logListBox);
291
                    {
292

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

  
341
                    Log.ProgressBarIncrement(progressBar);
297
                    }
342 298
                    break;
343 299
                }
344 300
            }
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>
40 36
    <Reference Include="System" />
41 37
    <Reference Include="System.Core" />
42
    <Reference Include="System.Drawing" />
43
    <Reference Include="System.Windows.Forms" />
44 38
    <Reference Include="System.Xml.Linq" />
45 39
    <Reference Include="System.Data.DataSetExtensions" />
46 40
    <Reference Include="Microsoft.CSharp" />
......
64 58
    <Compile Include="Model\SPPID\Symbol.cs" />
65 59
    <Compile Include="Model\SPPID\Text.cs" />
66 60
    <Compile Include="Properties\AssemblyInfo.cs" />
67
    <Compile Include="Utill\ExcelUtill.cs" />
68 61
    <Compile Include="Utill\Log.cs" />
69 62
    <Compile Include="Utill\SPPIDUtill.cs" />
70 63
  </ItemGroup>
DTI_PID/SPPIDConverter_AutoModeling/Utill/Log.cs
1 1
using System;
2
using System.Windows.Forms;
3 2
using System.Collections.Generic;
4 3
using System.Linq;
5 4
using System.Text;
......
30 29
                sw.WriteLine(text);
31 30
            }
32 31
        }
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; }
122 32
    }
123 33
}

내보내기 Unified diff

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