hytos / DTI_PID / APIDConverter / Form / APIDSplashScreen.cs @ d953c0ad
이력 | 보기 | 이력해설 | 다운로드 (3.55 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 AVEVA.PID.CustomizationUtility |
13 |
{ |
14 |
public partial class APIDSplashScreen : DevExpress.XtraSplashScreen.SplashScreen |
15 |
{ |
16 |
System.Diagnostics.Stopwatch sw; |
17 |
public APIDSplashScreen() |
18 |
{ |
19 |
InitializeComponent(); |
20 |
this.labelControl1.Text = "Copyright © 2019-" + DateTime.Now.Year.ToString(); |
21 |
} |
22 |
int allStepCount; |
23 |
int currentCount; |
24 |
private void SPPIDSplashScreen_Load(object sender, EventArgs e) |
25 |
{ |
26 |
|
27 |
} |
28 |
|
29 |
#region Overrides |
30 |
|
31 |
public override void ProcessCommand(Enum cmd, object arg) |
32 |
{ |
33 |
base.ProcessCommand(cmd, arg); |
34 |
SplashScreenCommand command = (SplashScreenCommand)cmd; |
35 |
if (command == SplashScreenCommand.SetProgress) |
36 |
{ |
37 |
int pos = (int)arg; |
38 |
if (progressBarControl.Properties.Maximum >= pos) |
39 |
progressBarControl.Position = pos; |
40 |
} |
41 |
else if (command == SplashScreenCommand.UpProgress) |
42 |
{ |
43 |
if (progressBarControl.Properties.Maximum > progressBarControl.Position) |
44 |
progressBarControl.Position += 1; |
45 |
} |
46 |
else if (command == SplashScreenCommand.SetStep) |
47 |
{ |
48 |
string stepText = (string)arg; |
49 |
labelStep.Text = "Step : " + stepText + string.Format(" ({0}/{1})",++currentCount, allStepCount); |
50 |
} |
51 |
else if (command == SplashScreenCommand.SetAllProgress) |
52 |
{ |
53 |
int pos = (int)arg; |
54 |
progressBarControl.Properties.Maximum = pos; |
55 |
progressBarControl.Position = 0; |
56 |
} |
57 |
else if (command == SplashScreenCommand.SetDocumentName) |
58 |
{ |
59 |
string text = (string)arg; |
60 |
labelDocument.Text = text; |
61 |
} |
62 |
else if (command == SplashScreenCommand.SetParent) |
63 |
{ |
64 |
sw = new System.Diagnostics.Stopwatch(); |
65 |
sw.Start(); |
66 |
timer.Start(); |
67 |
SetParent(Handle, (IntPtr)arg); |
68 |
} |
69 |
else if (command == SplashScreenCommand.ClearParent) |
70 |
{ |
71 |
sw.Stop(); |
72 |
timer.Stop(); |
73 |
SetParent(Handle, (IntPtr)0); |
74 |
} |
75 |
else if (command == SplashScreenCommand.SetAllStepCount) |
76 |
{ |
77 |
allStepCount = (int)arg; |
78 |
currentCount = 0; |
79 |
} |
80 |
else if (command == SplashScreenCommand.SetStepMinus) |
81 |
{ |
82 |
currentCount--; |
83 |
} |
84 |
} |
85 |
|
86 |
[DllImport("user32.dll", SetLastError = true)] |
87 |
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); |
88 |
[DllImport("user32")] |
89 |
public static extern int GetParent(IntPtr hwnd); |
90 |
|
91 |
#endregion |
92 |
|
93 |
public enum SplashScreenCommand |
94 |
{ |
95 |
SetProgress, |
96 |
UpProgress, |
97 |
SetAllProgress, |
98 |
SetAllStepCount, |
99 |
SetStep, |
100 |
SetStepMinus, |
101 |
SetDocumentName, |
102 |
SetParent, |
103 |
ClearParent |
104 |
} |
105 |
|
106 |
private void timer_Tick(object sender, EventArgs e) |
107 |
{ |
108 |
TimeSpan ts = sw.Elapsed; |
109 |
labelTime.Text = string.Format("{0:00} : {1:00} : {2:00}", ts.Hours, ts.Minutes, ts.Seconds); |
110 |
} |
111 |
} |
112 |
} |