개정판 5f01bbc4
dev issue #829: edit source
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