-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
73 lines (59 loc) · 2.42 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
66
67
68
69
70
71
72
73
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;
using System.Threading;
namespace DiceGame
{
public partial class Form1 : Form
{
public const string GroupAdress = "224.2.2.4";
public const int ClientReceive = 8000;
public const int ServerReceive = 8001;
private bool InLobby = true;
private bool Watcher = false;
private string Name;
private int RoomId = -1;
ServerForm Server;
ClientForm Client;
Client LocalClient;
Server LocalServer;
EList<EasyRoom> Notes;
public Form1()
{
InitializeComponent();
InitMain();
}
private void InitMain()
{
Controls.Clear();
ClientSize = new Size(400, 200);
Text = "Dice Game. Main";
Button StartClient = new Button() { Parent = this, Location = new Point((ClientRectangle.Width / 2) - 150, (ClientRectangle.Height / 2) - 50), Size = new Size(300, 40), Text = "Запустить клиент" };
Button StartServer = new Button() { Parent = this, Location = new Point((ClientRectangle.Width / 2) - 150, (ClientRectangle.Height / 2) + 10), Size = new Size(300, 40), Text = "Запустить сервер" };
StartClient.Click += (object sender, EventArgs e) => {
if (!(Client is null)) Client.Close();
Client = new ClientForm(GroupAdress, ClientReceive, ServerReceive) { Size = new Size(800, 600), Text = "Client" };
Client.Show();
Client.FormClosing += (object esender, FormClosingEventArgs ee) => {
StartClient.Enabled = true;
};
StartClient.Enabled = false;
};
StartServer.Click += (object sender, EventArgs e) => {
if (!(Server is null)) Server.Close();
Server = new ServerForm(GroupAdress, ServerReceive, ClientReceive) { Size = new Size(400, 600), Text = "Sever" };
Server.SetConsole();
Server.FormClosing += (object esender, FormClosingEventArgs ee) => {
StartServer.Enabled = true;
};
StartServer.Enabled = false;
};
}
}
}