프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (3.61 KB)

1 ca214bc3 gaqhf
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6 f31645b6 gaqhf
using System.Runtime.InteropServices;
7 ca214bc3 gaqhf
using System.Text;
8
using System.Windows.Forms;
9
using DevExpress.XtraSplashScreen;
10
11 f31645b6 gaqhf
12 ca214bc3 gaqhf
namespace Converter.SPPID
13
{
14
    public partial class SPPIDSplashScreen : DevExpress.XtraSplashScreen.SplashScreen
15
    {
16 3e5292ae gaqhf
        System.Diagnostics.Stopwatch sw;
17 ca214bc3 gaqhf
        public SPPIDSplashScreen()
18
        {
19
            InitializeComponent();
20 b2d1c1aa gaqhf
            this.labelControl1.Text = "Copyright © 2018-" + DateTime.Now.Year.ToString();
21
        }
22 f9cc5190 gaqhf
        int allStepCount;
23
        int currentCount;
24 b2d1c1aa gaqhf
        private void SPPIDSplashScreen_Load(object sender, EventArgs e)
25
        {
26 b66a2996 gaqhf
27 ca214bc3 gaqhf
        }
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 f31645b6 gaqhf
                if (progressBarControl.Properties.Maximum >= pos)
39
                    progressBarControl.Position = pos;
40
            }
41 5173ba5d gaqhf
            else if (command == SplashScreenCommand.UpProgress)
42
            {
43
                if (progressBarControl.Properties.Maximum > progressBarControl.Position)
44
                    progressBarControl.Position += 1;
45
            }
46 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetStep)
47
            {
48
                string stepText = (string)arg;
49 f9cc5190 gaqhf
                labelStep.Text = "Step : " + stepText + string.Format(" ({0}/{1})",++currentCount, allStepCount);
50 ca214bc3 gaqhf
            }
51 6db30942 gaqhf
            else if (command == SplashScreenCommand.SetAllProgress)
52 f31645b6 gaqhf
            {
53
                int pos = (int)arg;
54
                progressBarControl.Properties.Maximum = pos;
55
                progressBarControl.Position = 0;
56
            }
57 d5ec4d0f gaqhf
            else if (command == SplashScreenCommand.SetDocumentName)
58
            {
59
                string text = (string)arg;
60
                labelDocument.Text = text;
61
            }
62 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetParent)
63 3e5292ae gaqhf
            {
64
                sw = new System.Diagnostics.Stopwatch();
65
                sw.Start();
66
                timer.Start();
67 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)arg);
68 3e5292ae gaqhf
            }
69 f31645b6 gaqhf
            else if (command == SplashScreenCommand.ClearParent)
70 3e5292ae gaqhf
            {
71
                sw.Stop();
72
                timer.Stop();
73 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)0);
74 3e5292ae gaqhf
            }
75 f9cc5190 gaqhf
            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 02480ac1 gaqhf
85 1ab9a205 gaqhf
            //if (!IsTopMost)
86
            //    this.TopMost = true;
87 ca214bc3 gaqhf
        }
88
89 f31645b6 gaqhf
        [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 ca214bc3 gaqhf
        #endregion
95
96
        public enum SplashScreenCommand
97
        {
98
            SetProgress,
99 5173ba5d gaqhf
            UpProgress,
100 6db30942 gaqhf
            SetAllProgress,
101 f9cc5190 gaqhf
            SetAllStepCount,
102 f31645b6 gaqhf
            SetStep,
103 f9cc5190 gaqhf
            SetStepMinus,
104 f31645b6 gaqhf
            SetDocumentName,
105
            SetParent,
106
            ClearParent
107 ca214bc3 gaqhf
        }
108 3e5292ae gaqhf
109
        private void timer_Tick(object sender, EventArgs e)
110
        {
111
            TimeSpan ts = sw.Elapsed;
112 f9cc5190 gaqhf
            labelTime.Text = string.Format("{0:00} : {1:00} : {2:00}", ts.Hours, ts.Minutes, ts.Seconds);
113 3e5292ae gaqhf
        }
114 ca214bc3 gaqhf
    }
115
}
클립보드 이미지 추가 (최대 크기: 500 MB)