-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathToggleButtonForm.cs
52 lines (42 loc) · 1.13 KB
/
ToggleButtonForm.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
using System;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Controls.Inline;
using TelegramBotBase.Enums;
using TelegramBotBase.Form;
namespace TelegramBotBase.Example.Tests.Controls;
public class ToggleButtonForm : AutoCleanForm
{
public ToggleButtonForm()
{
DeleteMode = EDeleteMode.OnLeavingForm;
Init += ToggleButtons_Init;
}
private Task ToggleButtons_Init(object sender, InitEventArgs e)
{
var tb = new ToggleButton
{
Checked = true
};
tb.Toggled += Tb_Toggled;
AddControl(tb);
tb = new ToggleButton
{
Checked = false
};
tb.Toggled += Tb_Toggled;
AddControl(tb);
tb = new ToggleButton
{
Checked = true
};
tb.Toggled += Tb_Toggled;
AddControl(tb);
return Task.CompletedTask;
}
private void Tb_Toggled(object sender, EventArgs e)
{
var tb = sender as ToggleButton;
Console.WriteLine(tb.Id + " was pressed, and toggled to " + (tb.Checked ? "Checked" : "Unchecked"));
}
}