hytos / DTI_PID / SPPIDConverter / Form / SPPIDSplashScreen.cs @ 91e72bfe
이력 | 보기 | 이력해설 | 다운로드 (3.99 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Runtime.InteropServices; |
7 |
using System.Text; |
8 |
using System.Windows.Forms; |
9 |
using DevExpress.XtraSplashScreen; |
10 |
|
11 |
|
12 |
namespace Converter.SPPID |
13 |
{ |
14 |
public partial class SPPIDSplashScreen : DevExpress.XtraSplashScreen.SplashScreen |
15 |
{ |
16 |
System.Diagnostics.Stopwatch sw; |
17 |
public SPPIDSplashScreen() |
18 |
{ |
19 |
InitializeComponent(); |
20 |
this.labelControl1.Text = "Copyright © 2018-" + DateTime.Now.Year.ToString(); |
21 |
progressBarControl.CustomDisplayText += ProgressBarControl_CustomDisplayText; |
22 |
} |
23 |
|
24 |
private void ProgressBarControl_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e) |
25 |
{ |
26 |
e.DisplayText = string.Format("[{0}/{1}] {2}", progressBarControl.Position, progressBarControl.Properties.Maximum, e.DisplayText); |
27 |
} |
28 |
|
29 |
int allStepCount; |
30 |
int currentCount; |
31 |
private void SPPIDSplashScreen_Load(object sender, EventArgs e) |
32 |
{ |
33 |
} |
34 |
|
35 |
#region Overrides |
36 |
|
37 |
public override void ProcessCommand(Enum cmd, object arg) |
38 |
{ |
39 |
base.ProcessCommand(cmd, arg); |
40 |
SplashScreenCommand command = (SplashScreenCommand)cmd; |
41 |
if (command == SplashScreenCommand.SetProgress) |
42 |
{ |
43 |
int pos = (int)arg; |
44 |
if (progressBarControl.Properties.Maximum >= pos) |
45 |
progressBarControl.Position = pos; |
46 |
} |
47 |
else if (command == SplashScreenCommand.UpProgress) |
48 |
{ |
49 |
if (progressBarControl.Properties.Maximum > progressBarControl.Position) |
50 |
progressBarControl.Position += 1; |
51 |
} |
52 |
else if (command == SplashScreenCommand.SetStep) |
53 |
{ |
54 |
string stepText = (string)arg; |
55 |
labelStep.Text = "Step : " + stepText + string.Format(" ({0}/{1})",++currentCount, allStepCount); |
56 |
} |
57 |
else if (command == SplashScreenCommand.SetAllProgress) |
58 |
{ |
59 |
int pos = (int)arg; |
60 |
progressBarControl.Properties.Maximum = pos; |
61 |
progressBarControl.Position = 0; |
62 |
} |
63 |
else if (command == SplashScreenCommand.SetDocumentName) |
64 |
{ |
65 |
string text = (string)arg; |
66 |
labelDocument.Text = text; |
67 |
} |
68 |
else if (command == SplashScreenCommand.SetParent) |
69 |
{ |
70 |
sw = new System.Diagnostics.Stopwatch(); |
71 |
sw.Start(); |
72 |
timer.Start(); |
73 |
SetParent(Handle, (IntPtr)arg); |
74 |
} |
75 |
else if (command == SplashScreenCommand.ClearParent) |
76 |
{ |
77 |
sw.Stop(); |
78 |
timer.Stop(); |
79 |
SetParent(Handle, (IntPtr)0); |
80 |
} |
81 |
else if (command == SplashScreenCommand.SetAllStepCount) |
82 |
{ |
83 |
allStepCount = (int)arg; |
84 |
currentCount = 0; |
85 |
} |
86 |
else if (command == SplashScreenCommand.SetStepMinus) |
87 |
{ |
88 |
currentCount--; |
89 |
} |
90 |
|
91 |
//if (!IsTopMost) |
92 |
// this.TopMost = true; |
93 |
} |
94 |
|
95 |
[DllImport("user32.dll", SetLastError = true)] |
96 |
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); |
97 |
[DllImport("user32")] |
98 |
public static extern int GetParent(IntPtr hwnd); |
99 |
|
100 |
#endregion |
101 |
|
102 |
public enum SplashScreenCommand |
103 |
{ |
104 |
SetProgress, |
105 |
UpProgress, |
106 |
SetAllProgress, |
107 |
SetAllStepCount, |
108 |
SetStep, |
109 |
SetStepMinus, |
110 |
SetDocumentName, |
111 |
SetParent, |
112 |
ClearParent |
113 |
} |
114 |
|
115 |
private void timer_Tick(object sender, EventArgs e) |
116 |
{ |
117 |
TimeSpan ts = sw.Elapsed; |
118 |
labelTime.Text = string.Format("{0:00} : {1:00} : {2:00}", ts.Hours, ts.Minutes, ts.Seconds); |
119 |
} |
120 |
} |
121 |
} |