-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyboard.cs
51 lines (42 loc) · 1.21 KB
/
Keyboard.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types.ReplyMarkups;
namespace TelegramKeyboard
{
public class Keyboard : IDisposable
{
public KeyboardButton[,] rows;
public int W;
public int H;
public Keyboard(int W = 3, int H = 3)
{
rows = new KeyboardButton[H, W];
this.W = W;
this.H = H;
for (int y = 0; y < H; y++)
for (int x = 0; x < W; x++)
rows[y, x] = new KeyboardButton(" ");
}
public void Add(int Y, int X, string Text) => rows[Y, X].Text = Text;
public void Dispose()
{
rows = null;
W = 0;
H = 0;
}
public KeyboardButton[][] Get()
{
List<List<KeyboardButton>> keys = new List<List<KeyboardButton>>();
for (int y = 0; y < H; y++)
{
keys.Add(new List<KeyboardButton>());
for (int x = 0; x < W; x++)
keys[y].Add(rows[y, x]);
}
return keys.Select(T => T.ToArray()).ToArray();
}
}
}