- added ToKeyboardButton to ButtonBase

- added eKeyboardType to switch between Inline and KeykboardButtons
- addes some small functions to ButtonForm
- added new control "ButtonGrid" which manages Button handling with Event Handler for each Button and can switch between InlineMode and KeyboardMode during runtime
- added also Examples to it
This commit is contained in:
FlorianDahn
2019-09-26 20:54:35 +02:00
parent 94195ec5bf
commit 1b811e1786
6 changed files with 368 additions and 2 deletions
+12
View File
@@ -48,5 +48,17 @@ namespace TelegramBotBase.Form
}
public KeyboardButton ToKeyboardButton(ButtonForm form)
{
//String id = (form.DependencyControl != null ? form.DependencyControl.ControlID + "_" : "");
if (this.Url == null)
{
return new KeyboardButton(this.Text);
}
return new KeyboardButton(this.Text);
}
}
}
+32 -2
View File
@@ -60,6 +60,14 @@ namespace TelegramBotBase.Form
return splitted;
}
public int Count
{
get
{
return this.Buttons.Select(a => a.ToArray()).Aggregate((a, b) => a.Union(b).ToArray()).Length;
}
}
/// <summary>
/// Add buttons splitted in the amount of columns (i.e. 2 per row...)
/// </summary>
@@ -75,19 +83,41 @@ namespace TelegramBotBase.Form
}
}
public InlineKeyboardButton[][] ToArray()
public List<ButtonBase> ToList()
{
return this.Buttons.Aggregate((a, b) => a.Union(b).ToList());
}
public InlineKeyboardButton[][] ToInlineButtonArray()
{
var ikb = this.Buttons.Select(a => a.Select(b => b.ToInlineButton(this)).ToArray()).ToArray();
return ikb;
}
public KeyboardButton[][] ToReplyButtonArray()
{
var ikb = this.Buttons.Select(a => a.Select(b => b.ToKeyboardButton(this)).ToArray()).ToArray();
return ikb;
}
public static implicit operator InlineKeyboardMarkup(ButtonForm form)
{
if (form == null)
return null;
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(form.ToArray());
InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(form.ToInlineButtonArray());
return ikm;
}
public static implicit operator ReplyKeyboardMarkup(ButtonForm form)
{
if (form == null)
return null;
ReplyKeyboardMarkup ikm = new ReplyKeyboardMarkup(form.ToReplyButtonArray());
return ikm;
}