[C#] 纯文本查看 复制代码 bool page_ = true;
private void button2_Click(object sender, EventArgs e)
{
page_ = false;
Point point = new Point(label1.Location.X, label1.Location.Y - textBox1.Size.Height - 5);
label1.Text = "V50后获取密码:";
label1.Location = point;
}
/* 触碰【否】的事件响应 */
private void button1_MouseEnter(object sender, EventArgs e)
{
Random rd = new Random();
int i = rd.Next(0, Size.Width - 15);
int n = rd.Next(0, Size.Height - 40);
button1.Location = new Point(i, n);
/* 将主窗口设置为Maximized可以不需要这两条代码 */
this.WindowState = FormWindowState.Maximized;
label1_Paint(null, null);
}
private void button1_MouseHover(object sender, EventArgs e)
{
Random rd = new Random();
int i = rd.Next(0, Size.Width - 15);
int n = rd.Next(0, Size.Height - 40);
button1.Location = new Point(i, n);
}
private void button1_MouseDown(object sender, MouseEventArgs e)
{
Random rd = new Random();
int i = rd.Next(0, Size.Width - 15);
int n = rd.Next(0, Size.Height - 40);
button1.Location = new Point(i, n);
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
Random rd = new Random();
int i = rd.Next(0, Size.Width - 15);
int n = rd.Next(0, Size.Height - 40);
button1.Location = new Point(i, n);
}
/* 启动和改变状态的时候重新排版一下 */
private void label1_Paint(object sender, PaintEventArgs e)
{
if (page_)
{
Point point = new Point((Size.Width / 2) - (label1.Size.Width / 2), (Size.Height / 2) - (label1.Size.Height / 2));
label1.Location = point;
point = new Point((Size.Width / 2) - (textBox1.Size.Width / 2), (Size.Height / 2) - (textBox1.Size.Height / 2));
textBox1.Location = point;
textBox1.Hide();
point = new Point((Size.Width / 2) - (textBox1.Size.Width / 2) + 13, (Size.Height / 2) + (textBox1.Size.Height));
button3.Location = point;
button3.Hide();
point = new Point((Size.Width / 2) - (panel1.Size.Width / 2), Size.Height - 2 * panel1.Size.Height);
panel1.Location = point;
panel1.Hide();
comboBox1.SelectedIndex = 0;
}
else
{
Point point = new Point(label1.Location.X, label1.Location.Y - textBox1.Size.Height - 5);
label1.Text = "V50后获取密码:";
label1.Location = point;
textBox1.Show();
button1.Hide();
button2.Hide();
button3.Show();
panel1.Show();
}
}
private void button3_Click(object sender, EventArgs e)
{
/* 这里原本是两个密码,发代码的时候扇成一个了 */
if (textBox1.Text == "糟老头子坏得很")
{
MessageBox.Show("每个人都有自己的路\r\n只要不走下面的路就好");
System.Environment.Exit(0);
}
else
{
MessageBox.Show("相信我,真的需要密码");
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
/* 这个if意义不大 */
if (e.KeyCode == Keys.Enter)
{
button3_Click(null, EventArgs.Empty);
}
/* 屏蔽按键响应 */
e.Handled = true;
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
button3_Click(null, EventArgs.Empty);
}
}
/* 第二条路的提交按钮 */
private void button4_Click(object sender, EventArgs e)
{
DialogResult rst = MessageBox.Show(this, "真的打算如此吗?\r\n这条路只有0次和无数次!!!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (rst == DialogResult.Yes)
{
MessageBox.Show("每个人都有自己的路\r\n但你的路太离谱了!!!");
Application.ExitThread();
Application.Exit();
}
}
private void Form1_Load(object sender, EventArgs e)
{
/* 第二条路我放在了一个panel控件里,所以这里只有panel的隐藏 */
panel1.Hide();
/* 隐藏第二条路的提交按钮 */
button4.Hide();
}
/* 当点击第二条路的下拉框时 */
private void comboBox1_Click(object sender, EventArgs e)
{
button4.Show();
} |