-
Notifications
You must be signed in to change notification settings - Fork 2
/
SplashForm.cs
93 lines (78 loc) · 2.18 KB
/
SplashForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace PCGPS
{
public partial class SplashForm : Form, IDisposable
{
static readonly object syncObj = new object();
static Thread _thread = null;
static SplashForm _form = null;
public static void ShowSplash()
{
if (_form != null || _thread != null)
return;
ThreadStart ts = () =>
{
_form = new SplashForm();
_form.Click += new EventHandler(form_Click);
Application.Run(_form);
};
_thread = new Thread(ts);
_thread.IsBackground = true;
_thread.SetApartmentState(ApartmentState.STA);
_thread.Name = "SplashForm";
_thread.Start();
}
public static void CloseSplash()
{
lock (syncObj)
{
if (_form != null && _form.IsDisposed == false)
{
if (_form.InvokeRequired)
{
_form.Invoke(new MethodInvoker(_form.Close));
}
else
{
_form.Close();
}
}
}
}
static void form_Click(object sender, EventArgs e)
{
CloseSplash();
}
public SplashForm()
{
InitializeComponent();
}
#region IDisposable メンバ
void IDisposable.Dispose()
{
_form = null;
_thread = null;
}
#endregion
private void SplashForm_Load(object sender, EventArgs e)
{
Util.PlaySE("PCGPS.Resources.b_021.wav");
this.timer1.Interval = 5000;
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
CloseSplash();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}