MainForm
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForm_04_Quiz_01 {
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();
MainForm_load();
}
private void MainForm_load() {
timer1.Interval = 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e) {
timeLabel.Text = DateTime.Now.ToString("T");
}
private void button1_MouseHover(object sender, EventArgs e) {
button1.BackgroundImage = Properties.Resources.HoverSTART;
}
private void button1_MouseLeave(object sender, EventArgs e) {
button1.BackgroundImage = Properties.Resources.START;
}
private void button1_MouseDown(object sender, MouseEventArgs e) {
button1.BackgroundImage = Properties.Resources.PressSTART;
}
private void button1_MouseUp(object sender, MouseEventArgs e) {
button1.BackgroundImage = Properties.Resources.START;
}
private void button2_MouseHover(object sender, EventArgs e) {
button2.BackgroundImage = Properties.Resources.HoverEND;
}
private void button2_MouseLeave(object sender, EventArgs e) {
button2.BackgroundImage = Properties.Resources.END;
}
private void button2_MouseUp(object sender, MouseEventArgs e) {
button2.BackgroundImage = Properties.Resources.END;
}
private void button2_MouseDown(object sender, MouseEventArgs e) {
button2.BackgroundImage = Properties.Resources.PressEND;
}
private void button1_Click(object sender, EventArgs e) {
Quiz_01 quiz1 = new Quiz_01();
quiz1.ShowDialog();
}
private void button2_Click(object sender, EventArgs e) {
Application.Exit();
}
}
}
QuizForm1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForm_04_Quiz_01 {
public partial class Quiz_01 : Form {
private int score = 0;
public Quiz_01() {
InitializeComponent();
Quiz_01_load();
}
private int timeLimit = 10;
public int Score { get => score; set => score = value; }
private void Quiz_01_load() {
timer1.Interval = 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e) {
if (timeLimit == 0) {
timer1.Stop();
MessageBox.Show("시간이 초과 되었습니다");
Close();
}
else if (timeLimit > 0) {
timeLimit--;
label5.Text = timeLimit.ToString();
}
}
private void button4_Click(object sender, EventArgs e) {
timer1.Stop();
Close();
}
private void button3_Click(object sender, EventArgs e) {
//다음퀴즈
Dispose();
timer1.Stop();
Quiz_02 quiz2 = new Quiz_02(score);
quiz2.ShowDialog();
}
private void button1_Click(object sender, EventArgs e) {
MessageBox.Show("정답입니다\n다음 퀴즈로 갑시다");
timer1.Stop();
score += 100;
Dispose();
Quiz_02 quiz2 = new Quiz_02(score);
quiz2.ShowDialog();
}
}
}
QuizForm2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinForm_04_Quiz_01 {
public partial class Quiz_02 : Form {
private int score = 0;
private int timeLimit = 10;
public Quiz_02() {
InitializeComponent();
Quiz_02_load();
}
public Quiz_02(int n) {
InitializeComponent();
Quiz_02_load();
score = n;
label4.Text = score.ToString();
}
private void Quiz_02_load() {
timer1.Interval = 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e) {
if (timeLimit == 0) {
timer1.Stop();
MessageBox.Show("시간이 초과 되었습니다");
Close();
}
else if (timeLimit > 0) {
timeLimit--;
label5.Text = timeLimit.ToString();
}
}
private void button3_Click(object sender, EventArgs e) {
//다음퀴즈
Dispose();
timer1.Stop();
Quiz_02 quiz2 = new Quiz_02();
quiz2.ShowDialog();
}
private void button4_Click(object sender, EventArgs e) {
timer1.Stop();
Close();
}
}
}
'C# > C# 연습' 카테고리의 다른 글
WinForm : Video (0) | 2022.12.29 |
---|---|
WinForm : 로그인 (0) | 2022.12.25 |
WinForm : 단순 계산기 (0) | 2022.12.21 |
Class : Student manage (0) | 2022.12.20 |
Class : Student Score (0) | 2022.12.18 |