- change SetKeyboardType method to Property

This commit is contained in:
FlorianDahn 2019-09-27 23:08:55 +02:00
parent 2028e2f9e6
commit 94d22318f8
2 changed files with 21 additions and 16 deletions

View File

@ -24,7 +24,7 @@ namespace TelegramBaseTest.Tests.Controls
{
m_Buttons = new ButtonGrid();
await m_Buttons.SetKeyboardType(TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard);
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
ButtonForm bf = new ButtonForm();
@ -58,10 +58,10 @@ namespace TelegramBaseTest.Tests.Controls
switch (m_Buttons.KeyboardType)
{
case TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard:
await m_Buttons.SetKeyboardType(TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard);
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard;
break;
case TelegramBotBase.Enums.eKeyboardType.InlineKeyBoard:
await m_Buttons.SetKeyboardType(TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard);
m_Buttons.KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard;
break;
}

View File

@ -32,21 +32,26 @@ namespace TelegramBotBase.Controls
/// </summary>
public eKeyboardType KeyboardType
{
get; private set;
get
{
return m_eKeyboardType;
}
set
{
if(m_eKeyboardType != value)
{
this.RenderNecessary = true;
Cleanup().Wait();
m_eKeyboardType = value;
}
}
}
public async Task SetKeyboardType(eKeyboardType type)
{
if (KeyboardType == type)
return;
this.RenderNecessary = true;
Cleanup().Wait();
KeyboardType = type;
}
private eKeyboardType m_eKeyboardType = eKeyboardType.ReplyKeyboard;
private bool m_bVisible = true;