-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplashScreen.cs
170 lines (152 loc) · 6.06 KB
/
SplashScreen.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using System;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
namespace HiraKata_Kaizen {
public partial class SplashScreen : Form {
Label[] labels;
Random random;
public SplashScreen() {
InitializeComponent();
labels = new Label[46];
random = new Random();
for (byte i = 0; i < labels.Length; i++) {
labels[i] = new Label();
labels[i].Font = new Font("Yu Gothic", 14);
int x = random.Next(ClientRectangle.Width - labels[i].Width);
int y = random.Next(ClientRectangle.Height - labels[i].Height);
labels[i].Location = new Point(x, y);
Controls.Add(labels[i]);
}
using (SqlConnection connection = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\HiraKata_Kaizen.mdf;Integrated Security=True;Connect Timeout=30")) {
connection.Open();
string query = "SELECT hiragana, katakana FROM japanese_characters";
using (SqlCommand command = new SqlCommand(query, connection)) {
using (SqlDataReader reader = command.ExecuteReader()) {
int index = 0;
while (reader.Read()) {
bool useHiragana = random.Next(2) == 0; // 50% chance of using Hiragana
labels[index].Text = useHiragana ? reader["hiragana"].ToString() : reader["katakana"].ToString();
index++;
}
}
}
}
timer1.Interval = 12; // adjust the interval as needed
timer1.Start();
}
void timer1_Tick(object sender, EventArgs e) {
panel1.Width += 4;
if (panel1.Width >= 470) {
timer1.Stop();
btnRun.Visible = true;
btnRun.Enabled = true;
}
}
void labelTimer_Tick(object sender, EventArgs e) {
MoveLabels(labels);
}
void MoveLabels(Label[] labels) {
// get the width and height of the form and labels
int formWidth = ClientRectangle.Width;
int formHeight = ClientRectangle.Height;
foreach (Label label in labels) {
int labelWidth = label.Width;
int labelHeight = label.Height;
// Adjust the label size based on the current font size
labelWidth = label.Width;
labelHeight = label.Height;
// calculate the new location of the label
int x = label.Location.X;
int y = label.Location.Y;
if (x + labelWidth < formWidth) {
// move the label to the right
x += 2;
}
else {
// move the label to the left
x = 2;
}
if (y + labelHeight < formHeight) {
// move the label down
y += 2;
}
else {
// move the label up
y = 2;
}
// set the new location of the label
label.Location = new Point(x, y);
}
}
bool increasingWidth = true;
void btnRunTimerX_Tick(object sender, EventArgs e) {
if (btnRun.Visible) {
if (increasingWidth) {
currentFontSize += 0.4f;
btnRun.Font = new Font("Segoe UI", currentFontSize);
if (btnRun.Width < 170) {
btnRun.Width += 2;
btnRun.Height += 1; // Scale the height as well
}
else {
increasingWidth = false;
btnRunTimerX.Stop();
btnRunTimerY.Start();
}
}
else {
currentFontSize -= 0.4f;
btnRun.Font = new Font("Segoe UI", currentFontSize);
if (btnRun.Width > 150) {
btnRun.Width -= 2;
btnRun.Height -= 1; // Scale the height as well
}
else {
increasingWidth = true;
btnRunTimerY.Stop();
btnRunTimerX.Start();
}
}
// center the button horizontally
btnRun.Left = (customPanel2.Width - btnRun.Width) / 2;
}
}
float currentFontSize = 14f;
void btnRunTimerY_Tick(object sender, EventArgs e) {
if (btnRun.Visible) {
if (increasingWidth) {
currentFontSize += 0.4f;
btnRun.Font = new Font("Segoe UI", currentFontSize);
if (btnRun.Height < 40) {
btnRun.Height += 1;
btnRun.Width += 2;
}
else {
increasingWidth = false;
btnRunTimerY.Stop();
}
}
else {
currentFontSize -= 0.4f;
btnRun.Font = new Font("Segoe UI", currentFontSize);
if (btnRun.Height > 40) {
btnRun.Height -= 1;
btnRun.Width -= 2;
}
else {
increasingWidth = true;
btnRunTimerY.Stop();
btnRunTimerX.Start();
}
}
// center the button horizontally
btnRun.Left = (customPanel2.Width - btnRun.Width) / 2;
}
}
void btnRun_Click(object sender, EventArgs e) {
Hide();
new Dashboard().Show();
}
}
}