-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMonthPickerForm.cs
67 lines (53 loc) · 1.59 KB
/
MonthPickerForm.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
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Base;
using TelegramBotBase.Controls.Inline;
using TelegramBotBase.Enums;
using TelegramBotBase.Form;
namespace TelegramBotBase.Example.Tests.Controls;
public class MonthPickerForm : AutoCleanForm
{
public MonthPickerForm()
{
DeleteMode = EDeleteMode.OnLeavingForm;
Init += MonthPickerForm_Init;
}
public MonthPicker Picker { get; set; }
private int? SelectedDateMessage { get; set; }
private Task MonthPickerForm_Init(object sender, InitEventArgs e)
{
Picker = new MonthPicker
{
Title = "Monat auswählen / Pick month"
};
AddControl(Picker);
return Task.CompletedTask;
}
public override async Task Action(MessageResult message)
{
switch (message.RawData)
{
case "back":
var s = new Menu();
await NavigateTo(s);
break;
}
}
public override async Task Render(MessageResult message)
{
var s = "";
s += "Selected month is " + Picker.Culture.DateTimeFormat.MonthNames[Picker.SelectedDate.Month - 1] + "\r\n";
s += "Selected year is " + Picker.VisibleMonth.Year;
var bf = new ButtonForm();
bf.AddButtonRow(new ButtonBase("Back", "back"));
if (SelectedDateMessage != null)
{
await Device.Edit(SelectedDateMessage.Value, s, bf);
}
else
{
var m = await Device.Send(s, bf);
SelectedDateMessage = m.MessageId;
}
}
}