프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Form / SPPIDSplashScreen.cs @ 5173ba5d

이력 | 보기 | 이력해설 | 다운로드 (3.16 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

    
23
        private void SPPIDSplashScreen_Load(object sender, EventArgs e)
24
        {
25

    
26
        }
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
                if (progressBarControl.Properties.Maximum >= pos)
38
                    progressBarControl.Position = pos;
39
            }
40
            else if (command == SplashScreenCommand.UpProgress)
41
            {
42
                if (progressBarControl.Properties.Maximum > progressBarControl.Position)
43
                    progressBarControl.Position += 1;
44
            }
45
            else if (command == SplashScreenCommand.SetStep)
46
            {
47
                string stepText = (string)arg;
48
                labelStep.Text = "Step : " + stepText;
49
            }
50
            else if (command == SplashScreenCommand.SetAllProgress)
51
            {
52
                int pos = (int)arg;
53
                progressBarControl.Properties.Maximum = pos;
54
                progressBarControl.Position = 0;
55
            }
56
            else if (command == SplashScreenCommand.SetDocumentName)
57
            {
58
                string text = (string)arg;
59
                labelDocument.Text = text;
60
            }
61
            else if (command == SplashScreenCommand.SetParent)
62
            {
63
                sw = new System.Diagnostics.Stopwatch();
64
                sw.Start();
65
                timer.Start();
66
                SetParent(Handle, (IntPtr)arg);
67
            }
68
            else if (command == SplashScreenCommand.ClearParent)
69
            {
70
                sw.Stop();
71
                timer.Stop();
72
                SetParent(Handle, (IntPtr)0);
73
            }
74
                
75

    
76
            //if (!IsTopMost)
77
            //    this.TopMost = true;
78
        }
79

    
80
        [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
        #endregion
86

    
87
        public enum SplashScreenCommand
88
        {
89
            SetProgress,
90
            UpProgress,
91
            SetAllProgress,
92
            SetStep,
93
            SetDocumentName,
94
            SetParent,
95
            ClearParent
96
        }
97

    
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
    }
104
}
클립보드 이미지 추가 (최대 크기: 500 MB)