프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (3.16 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 3e5292ae gaqhf
23 b2d1c1aa gaqhf
        private void SPPIDSplashScreen_Load(object sender, EventArgs e)
24
        {
25 b66a2996 gaqhf
26 ca214bc3 gaqhf
        }
27
28
        #region Overrides
29
30
        public override void ProcessCommand(Enum cmd, object arg)
31
        {
32
            base.ProcessCommand(cmd, arg);
33
            SplashScreenCommand command = (SplashScreenCommand)cmd;
34
            if (command == SplashScreenCommand.SetProgress)
35
            {
36
                int pos = (int)arg;
37 f31645b6 gaqhf
                if (progressBarControl.Properties.Maximum >= pos)
38
                    progressBarControl.Position = pos;
39
            }
40 5173ba5d gaqhf
            else if (command == SplashScreenCommand.UpProgress)
41
            {
42
                if (progressBarControl.Properties.Maximum > progressBarControl.Position)
43
                    progressBarControl.Position += 1;
44
            }
45 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetStep)
46
            {
47
                string stepText = (string)arg;
48 d5ec4d0f gaqhf
                labelStep.Text = "Step : " + stepText;
49 ca214bc3 gaqhf
            }
50 6db30942 gaqhf
            else if (command == SplashScreenCommand.SetAllProgress)
51 f31645b6 gaqhf
            {
52
                int pos = (int)arg;
53
                progressBarControl.Properties.Maximum = pos;
54
                progressBarControl.Position = 0;
55
            }
56 d5ec4d0f gaqhf
            else if (command == SplashScreenCommand.SetDocumentName)
57
            {
58
                string text = (string)arg;
59
                labelDocument.Text = text;
60
            }
61 f31645b6 gaqhf
            else if (command == SplashScreenCommand.SetParent)
62 3e5292ae gaqhf
            {
63
                sw = new System.Diagnostics.Stopwatch();
64
                sw.Start();
65
                timer.Start();
66 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)arg);
67 3e5292ae gaqhf
            }
68 f31645b6 gaqhf
            else if (command == SplashScreenCommand.ClearParent)
69 3e5292ae gaqhf
            {
70
                sw.Stop();
71
                timer.Stop();
72 f31645b6 gaqhf
                SetParent(Handle, (IntPtr)0);
73 3e5292ae gaqhf
            }
74
                
75 02480ac1 gaqhf
76 1ab9a205 gaqhf
            //if (!IsTopMost)
77
            //    this.TopMost = true;
78 ca214bc3 gaqhf
        }
79
80 f31645b6 gaqhf
        [DllImport("user32.dll", SetLastError = true)]
81
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
82
        [DllImport("user32")]
83
        public static extern int GetParent(IntPtr hwnd);
84
85 ca214bc3 gaqhf
        #endregion
86
87
        public enum SplashScreenCommand
88
        {
89
            SetProgress,
90 5173ba5d gaqhf
            UpProgress,
91 6db30942 gaqhf
            SetAllProgress,
92 f31645b6 gaqhf
            SetStep,
93
            SetDocumentName,
94
            SetParent,
95
            ClearParent
96 ca214bc3 gaqhf
        }
97 3e5292ae gaqhf
98
        private void timer_Tick(object sender, EventArgs e)
99
        {
100
            TimeSpan ts = sw.Elapsed;
101
            labelTime.Text = string.Format("{0:00} : {1:00}", ts.TotalMinutes, ts.Seconds);
102
        }
103 ca214bc3 gaqhf
    }
104
}
클립보드 이미지 추가 (최대 크기: 500 MB)