프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (3.99 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 88b5fc73 Denny
            progressBarControl.CustomDisplayText += ProgressBarControl_CustomDisplayText;
22 b2d1c1aa gaqhf
        }
23 88b5fc73 Denny
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 f9cc5190 gaqhf
        int allStepCount;
30
        int currentCount;
31 b2d1c1aa gaqhf
        private void SPPIDSplashScreen_Load(object sender, EventArgs e)
32
        {
33 ca214bc3 gaqhf
        }
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 f31645b6 gaqhf
                if (progressBarControl.Properties.Maximum >= pos)
45
                    progressBarControl.Position = pos;
46
            }
47 5173ba5d gaqhf
            else if (command == SplashScreenCommand.UpProgress)
48
            {
49
                if (progressBarControl.Properties.Maximum > progressBarControl.Position)
50
                    progressBarControl.Position += 1;
51
            }
52 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetStep)
53
            {
54
                string stepText = (string)arg;
55 f9cc5190 gaqhf
                labelStep.Text = "Step : " + stepText + string.Format(" ({0}/{1})",++currentCount, allStepCount);
56 ca214bc3 gaqhf
            }
57 6db30942 gaqhf
            else if (command == SplashScreenCommand.SetAllProgress)
58 f31645b6 gaqhf
            {
59
                int pos = (int)arg;
60
                progressBarControl.Properties.Maximum = pos;
61
                progressBarControl.Position = 0;
62
            }
63 d5ec4d0f gaqhf
            else if (command == SplashScreenCommand.SetDocumentName)
64
            {
65
                string text = (string)arg;
66
                labelDocument.Text = text;
67
            }
68 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetParent)
69 3e5292ae gaqhf
            {
70
                sw = new System.Diagnostics.Stopwatch();
71
                sw.Start();
72
                timer.Start();
73 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)arg);
74 3e5292ae gaqhf
            }
75 f31645b6 gaqhf
            else if (command == SplashScreenCommand.ClearParent)
76 3e5292ae gaqhf
            {
77
                sw.Stop();
78
                timer.Stop();
79 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)0);
80 3e5292ae gaqhf
            }
81 f9cc5190 gaqhf
            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 02480ac1 gaqhf
91 1ab9a205 gaqhf
            //if (!IsTopMost)
92
            //    this.TopMost = true;
93 ca214bc3 gaqhf
        }
94
95 f31645b6 gaqhf
        [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 ca214bc3 gaqhf
        #endregion
101
102
        public enum SplashScreenCommand
103
        {
104
            SetProgress,
105 5173ba5d gaqhf
            UpProgress,
106 6db30942 gaqhf
            SetAllProgress,
107 f9cc5190 gaqhf
            SetAllStepCount,
108 f31645b6 gaqhf
            SetStep,
109 f9cc5190 gaqhf
            SetStepMinus,
110 f31645b6 gaqhf
            SetDocumentName,
111
            SetParent,
112
            ClearParent
113 ca214bc3 gaqhf
        }
114 3e5292ae gaqhf
115
        private void timer_Tick(object sender, EventArgs e)
116
        {
117
            TimeSpan ts = sw.Elapsed;
118 f9cc5190 gaqhf
            labelTime.Text = string.Format("{0:00} : {1:00} : {2:00}", ts.Hours, ts.Minutes, ts.Seconds);
119 3e5292ae gaqhf
        }
120 ca214bc3 gaqhf
    }
121
}
클립보드 이미지 추가 (최대 크기: 500 MB)