-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnterName.cs
55 lines (54 loc) · 1.95 KB
/
EnterName.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
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 MinTetris
{
//Enter name if you got the top score
//Клас для вводу імені при попаданні у список кращих гравців
public partial class EnterName : Form
{
public EnterName()
{
InitializeComponent();
}
//What happens when the form loads
//Події при завантаженні форми
private void EnterName_Load(object sender, EventArgs e)
{
//The field to enter the name becomes active
//При завантаженні поле для вводу імені стає активним
this.ActiveControl = playerName;
}
//'OK' button
//Кнопка "ОК"
private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
//When you enter the field to enter the name, the text becomes highlighted
//При натисканні на полі вводу імені чи переході по клавіші "TAB" на це поле,
//вміст поля виділяється (ім'я за замовчуванням)
private void playerName_Enter(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(playerName.Text))
{
playerName.SelectionStart = 0;
playerName.SelectionLength = playerName.Text.Length;
//playerName.SelectAll();
}
}
//'Cancel' button
//Кнопка "Відміна" у діалоговому вікні
private void btnCancel_Click(object sender, EventArgs e)
{
Close();
}
}
}