-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartForm.cs
More file actions
118 lines (105 loc) · 3.88 KB
/
StartForm.cs
File metadata and controls
118 lines (105 loc) · 3.88 KB
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
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 Fenced
{
public partial class StartForm : Form
{
int nBoardWidth = 0;
int nBoardHeight = 0;
bool bFillBorder;
string strNamePlayer1;
string strNamePlayer2;
Color cPlayer1;
Color cPlayer2;
int nFirstPlayer;
public int boardWidth { get { return nBoardWidth; } }
public int boardHeight { get { return nBoardHeight; } }
public bool fillBorder { get { return bFillBorder; } }
public string namePlayer1 { get { return strNamePlayer1; } }
public string namePlayer2 { get { return strNamePlayer2; } }
public Color colorPlayer1 { get { return cPlayer1; } }
public Color colorPlayer2 { get { return cPlayer2; } }
public int firstPlayer { get { return nFirstPlayer; } }
public StartForm()
{
InitializeComponent();
}
public StartForm(int width, int height, bool border, string name1, string name2, Color c1, Color c2)
{
nBoardWidth = width;
nBoardHeight = height;
bFillBorder = border;
strNamePlayer1 = name1;
strNamePlayer2 = name2;
cPlayer1 = c1;
cPlayer2 = c2;
InitializeComponent();
}
private void StartForm_Load(object sender, EventArgs e)
{
if (nBoardWidth > 0 && nBoardHeight > 0)
{
numericUpDownWidth.Value = nBoardWidth;
numericUpDownHeight.Value = nBoardHeight;
checkBoxBorder.Checked = bFillBorder;
textBoxPlayer1.Text = strNamePlayer1;
textBoxPlayer2.Text = strNamePlayer2;
pictureBoxColorPlayer1.BackColor = cPlayer1;
pictureBoxColorPlayer2.BackColor = cPlayer2;
}
}
private void buttonStart_Click(object sender, EventArgs e)
{
nBoardWidth = (int)numericUpDownWidth.Value;
nBoardHeight = (int)numericUpDownHeight.Value;
bFillBorder = checkBoxBorder.Checked;
if (textBoxPlayer1.Text == "")
{
MessageBox.Show("Player 1의 이름을 입력해주세요!", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBoxPlayer1.Focus();
return;
}
else strNamePlayer1 = textBoxPlayer1.Text;
if (textBoxPlayer2.Text == "")
{
MessageBox.Show("Player 2의 이름을 입력해주세요!", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBoxPlayer2.Focus();
return;
}
else strNamePlayer2 = textBoxPlayer2.Text;
cPlayer1 = pictureBoxColorPlayer1.BackColor;
cPlayer2 = pictureBoxColorPlayer2.BackColor;
if (radioButtonFirstPlayer1.Checked) nFirstPlayer = 1;
else nFirstPlayer = 2;
this.DialogResult = DialogResult.OK;
}
private void buttonExit_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.No;
this.Close();
}
private void pictureBoxColorPlayer1_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
{
pictureBoxColorPlayer1.BackColor = cd.Color;
}
}
private void pictureBoxColorPlayer2_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
{
pictureBoxColorPlayer2.BackColor = cd.Color;
}
}
}
}