프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Form / SPPIDSplashScreen.cs @ f9cc5190

이력 | 보기 | 이력해설 | 다운로드 (3.61 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
        }
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
            //if (!IsTopMost)
86
            //    this.TopMost = true;
87
        }
88

    
89
        [DllImport("user32.dll", SetLastError = true)]
90
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
91
        [DllImport("user32")]
92
        public static extern int GetParent(IntPtr hwnd);
93

    
94
        #endregion
95

    
96
        public enum SplashScreenCommand
97
        {
98
            SetProgress,
99
            UpProgress,
100
            SetAllProgress,
101
            SetAllStepCount,
102
            SetStep,
103
            SetStepMinus,
104
            SetDocumentName,
105
            SetParent,
106
            ClearParent
107
        }
108

    
109
        private void timer_Tick(object sender, EventArgs e)
110
        {
111
            TimeSpan ts = sw.Elapsed;
112
            labelTime.Text = string.Format("{0:00} : {1:00} : {2:00}", ts.Hours, ts.Minutes, ts.Seconds);
113
        }
114
    }
115
}
클립보드 이미지 추가 (최대 크기: 500 MB)