diff --git a/TelegramBotBase/Controls/ButtonGrid.cs b/TelegramBotBase/Controls/ButtonGrid.cs index a8aad43..0c75db4 100644 --- a/TelegramBotBase/Controls/ButtonGrid.cs +++ b/TelegramBotBase/Controls/ButtonGrid.cs @@ -65,6 +65,9 @@ namespace TelegramBotBase.Controls public String SearchQuery { get; set; } + public eNavigationBarVisibility NavigationBarVisibility { get; set; } = eNavigationBarVisibility.always; + + /// /// Index of the current page /// @@ -413,22 +416,24 @@ namespace TelegramBotBase.Controls bf.AddButtonRow(new ButtonBase(NoItemsLabel, "$")); } - //πŸ” - List lst = new List(); - lst.Add(new ButtonBase(PreviousPageLabel, "$previous$")); - lst.Add(new ButtonBase(String.Format(Localizations.Default.Language["ButtonGrid_CurrentPage"], this.CurrentPageIndex + 1, this.PageCount), "$site$")); - lst.Add(new ButtonBase(NextPageLabel, "$next$")); - - - if (this.EnableSearch) + if (this.NavigationBarVisibility == eNavigationBarVisibility.always | (this.NavigationBarVisibility == eNavigationBarVisibility.auto && PagingNecessary)) { - lst.Insert(2, new ButtonBase("πŸ” " + (this.SearchQuery ?? ""), "$search$")); + //πŸ” + List lst = new List(); + lst.Add(new ButtonBase(PreviousPageLabel, "$previous$")); + lst.Add(new ButtonBase(String.Format(Localizations.Default.Language["ButtonGrid_CurrentPage"], this.CurrentPageIndex + 1, this.PageCount), "$site$")); + lst.Add(new ButtonBase(NextPageLabel, "$next$")); + + if (this.EnableSearch) + { + lst.Insert(2, new ButtonBase("πŸ” " + (this.SearchQuery ?? ""), "$search$")); + } + + bf.InsertButtonRow(0, lst); + + bf.AddButtonRow(lst); } - bf.InsertButtonRow(0, lst); - - bf.AddButtonRow(lst); - return bf; } @@ -436,7 +441,12 @@ namespace TelegramBotBase.Controls { get { - if ((this.KeyboardType == eKeyboardType.InlineKeyBoard && ButtonsForm.Rows > Constants.Telegram.MaxInlineKeyBoardRows) | (this.KeyboardType == eKeyboardType.ReplyKeyboard && ButtonsForm.Rows > Constants.Telegram.MaxReplyKeyboardRows)) + if (this.KeyboardType == eKeyboardType.InlineKeyBoard && TotalRows > Constants.Telegram.MaxInlineKeyBoardRows) + { + return true; + } + + if (this.KeyboardType == eKeyboardType.ReplyKeyboard && TotalRows > Constants.Telegram.MaxReplyKeyboardRows) { return true; } @@ -466,6 +476,18 @@ namespace TelegramBotBase.Controls } } + /// + /// Returns the number of all rows (layout + navigation + content); + /// + public int TotalRows + { + get + { + return this.LayoutRows + ButtonsForm.Rows; + } + } + + /// /// Contains the Number of Rows which are used by the layout. /// @@ -473,7 +495,10 @@ namespace TelegramBotBase.Controls { get { - int layoutRows = 2; + int layoutRows = 0; + + if (this.NavigationBarVisibility == eNavigationBarVisibility.always | this.NavigationBarVisibility == eNavigationBarVisibility.auto) + layoutRows += 2; if (this.HeadLayoutButtonRow != null && this.HeadLayoutButtonRow.Count > 0) layoutRows++; diff --git a/TelegramBotBase/Enums/eNavigationBarVisibility.cs b/TelegramBotBase/Enums/eNavigationBarVisibility.cs new file mode 100644 index 0000000..d10e027 --- /dev/null +++ b/TelegramBotBase/Enums/eNavigationBarVisibility.cs @@ -0,0 +1,25 @@ +ο»Ώusing System; +using System.Collections.Generic; +using System.Text; + +namespace TelegramBotBase.Enums +{ + public enum eNavigationBarVisibility + { + /// + /// Shows it depending on the amount of items. + /// + auto = 0, + + /// + /// Will not show it at any time. + /// + never = 1, + + /// + /// Will show it at any time. + /// + always = 2 + + } +}