-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
65 lines (59 loc) · 1.83 KB
/
Form1.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
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 myMineSweeper
{
public partial class Form1 : Form
{
mineSweeper m;
public Form1()
{
InitializeComponent();
timer1.Interval = 1000;
timer1.Enabled = true;
m = new mineSweeper(30, 16, 99, pictureBox1);
}
private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left) lmb = true;
if (e.Button == MouseButtons.Right) rmb = true;
}
bool lmb = false;
bool rmb = false;
private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
{
if (lmb && rmb) m.doubleClick(e.Location);
else if (lmb) m.leftClick(e.Location);
else if (rmb) m.rightClick(e.Location);
lmb = false; rmb = false;
}
private void Button1_Click(object sender, EventArgs e)
{
try
{
int w, h, n;
w = int.Parse(textBox1.Text);
h = int.Parse(textBox2.Text);
n = int.Parse(textBox3.Text);
m = new mineSweeper(w, h, n, pictureBox1);
}
catch(Exception){
textBox1.Text = 30.ToString();
textBox2.Text = 16.ToString();
textBox3.Text = 99.ToString();
}
}
private void Timer1_Tick(object sender, EventArgs e)
{
DateTime d = m.tick();
label4.Text = d.ToString("HH:mm:ss");
label5.Text = m.remainNum.ToString();
}
}
}